By default, access to external resources (files on hard disk, HTTP requests, ...) is not controlled by the transaction monitor of BaseX. You can use custom XQuery locks to do so:
===Option DeclarationsOptions, Pragmas, Function Annotations===
{{Mark|Introduced with Version 9.1}}: locks via pragmas and function annotations.
* You can declare custom read and write locks via options, pragmas or function annotations.* The value of the lock may contain one or multiple lock keys (separated with commas). The default value is an empty string.
* Similar to the internal database locks, write locks block all other operations while read locks allow parallel access.
* The internal locks and XQuery locks can co-exist (there will be no conflicts, even if your lock string equals the name of a database that will be locked by the transaction manager).
{{Code|basex:read-lock}} and {{Code|basex:write-lock}} options in the query prolog
In the following module, lock annotations are used to prevent concurrent write operations on the same file:
<pre class="brush:xquery">
(# basex:write-lock CONFIGLOCK CONFIG #) {
file:write('config.xml', <config/>)
}
<pre class="brush:xquery">
declare option basex:write-lock 'HTTPLOCKCONFIG';
file:write('config.xml', <config/>)
</pre>