Changes

Jump to navigation Jump to search
722 bytes added ,  17:21, 26 October 2017
* If an updating transaction comes in, it will be queued and executed after all previous read transaction have been executed.
* Subsequent operations (read or write) will be queued until the updating transaction has completed.
 
Each database has its own queue: An update on database A will not block operations on database B. This is under the premise that it can be statically determined, i.e., before the transaction is evaluated, which databases will be accessed by a transaction (see [[#Limitations|below]]). The number of maximum parallel transactions can be adjusted with the [[Options#PARALLEL|PARALLEL]] option.
 
With {{Version|8.6}}, locking has been improved:
 
* Jobs without database access will never be locked. Globally locking jobs can now be executed in parallel with non-locking jobs.
* Each database has its own queue: An update on database A will not block operations on database B. This is under the premise that it can be statically determined, i.e., before the transaction is evaluated, which databases will be accessed by a transaction (see [[#Limitations|below]]).* The number of maximum parallel transactions can be adjusted with the {{Option|FAIRLOCKPARALLEL}} option has been added: .* By default, read transactions will now be are favored, and transactions that access no databases can be evaluated even if the transactions limit has been reached. This behavior can be changed via the {{Option|FAIRLOCK}} option.
==XQuery Locks==
===Query Options===
* The You can declare custom locks are declared as options via the {{Code|query:read-lock}} and {{Code|query:write-lock}} options in the query prolog.* Multiple The value of the option declarations can be specified in a modulecontains the lock string, or values can also be multiple ones (separated with commas in a single declaration).* XQuery locks are in a separate namespace, such that there will be no conflicts with Similar to the internal database locks.* Similar to internal 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).
In the following moduletwo example modules, a locks have been added to prevent concurrent write lock is declared to avoid multiple clients reading or writing to a config file at operations on the same timefile:
<pre class="brush:xquery">
module namespace config read = 'configread';
(:~ Write Read lock for all functions of the moduleon CONFIG key. :)declare option query:writeread-lock "files";(:~ Config file. :)declare variable $config:file := 'config.txtCONFIG';
declare function read:config:write($config) { file:writeread-text($config:file, $'config.txt')
};
</pre>
 
<pre class="brush:xquery">
module namespace write = 'write';
(:~ Write lock on CONFIG key. :)declare option query:write-lock 'CONFIG'; declare function configwrite:readfile($data) { file:readwrite-text('config.txt', $config:filedata)
};
</pre>
 
Some explanations:
 
* If a query is parsed that is going to call the <code>read:file</code> function, a read lock will be acquired for the user-defined {{Code|CONFIG}} lock string before query evaluation.
* If <code>write:file</code> is referenced by a query, a write lock on this lock string will be set for this query.
* If a query references <code>write:file</code>, it will be queued until there is no running query left that has {{Code|files}} locked.
* If the writing query will be evaluated, all other queries that will set a {{Code|files}} lock (reading or writing) will have to wait.
 
In practice, it’s often sufficient to only work with (exclusive) write locks.
===Java Modules===
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu