Commit 20626e7b authored by Carsten  Rose's avatar Carsten Rose

Update Developer doc for record locking.

parent 643e2191
Pipeline #3099 passed with stages
in 1 minute and 53 seconds
<!-- -*- markdown -*- -->
# Record locking
## Concept: Late locking
* A lock is required on first modification.
* Multiple forms might open the same record, all seems to have write access. The first one who modifies the record
get the lock, all following will switch to form=readonly on their first try to modify the record.
## Lock mode: Exclusive
* A lock can't be overwritten.
## Lock mode: Advisory
* A lock can be ignored.
* Last save win's.
## Lock mode: None
* No locking at all.
# Workarounds
* At least one Browser (FF 71, maybe other in the future too), do not allow to wrap the 'leave page' dialog anymore.
This might result in stale lock files (modified record, click on browser tab close or any link), cause the lock
logic does not know that the user leaves the page.
* Workaround: before 'do you want to leave the page' appears, the lock is released, independent if the user answers 'no'.
As soon as the users modifies the record again, a new lock is acquired. This is better than a stale record lock.
* Reload a page (F5) on a modified record, opens the form in readonly mode (record lock found).
* Reason: the lock release is fired by the browser AFTER form load - than the lock-logic reports 'record is already locked'.
* Workaround: with the above workaround, this does not happen anymore. Nevertheless, a 'tabUniqId' has been implemented.
That one is saved as record lock and a page reload origin can be identified as the same tab as where the lock has been
acquired.
= State Diagram =
See `Documentation-develop/diagram` for a state diagram.
......@@ -2255,7 +2255,7 @@ If a timeout expires, the lock becomes invalid. During the next change in a form
A lock is assigned to a record of a table. Multiple forms, with the same primary table, uses the same lock for a given record.
If a `Form` acts on further records (e.g. via FE action), those records are not protected by this basic record locking.
If a `Form` acts on further records (e.g. via FE action), those further records are not protected by this basic record locking.
If a user tries to delete a record and another user already owns a lock on that record, the delete action is denied.
......
......@@ -1816,7 +1816,7 @@ const DIRTY_API_ACTION_EXTEND = 'extend';
const LOCK_NOT_FOUND = 0;
const LOCK_FOUND_OWNER = 1;
const LOCK_FOUND_CONFLICT = 2;
const TAB_UNIQ_ID = 'tabUniqId'; // Currently only only a uniq identifier: no values stored behind the identifier - might change.
const TAB_UNIQ_ID = 'tabUniqId'; // Uniq identifier per tab: no values stored behind the identifier - might change.
// AutoCron
const AUTOCRON_MAX_AGE_MINUTES = 10;
......
......@@ -146,7 +146,7 @@ class Dirty {
}
/**
* Tries to get a 'DirtyRecord'. Returns an array (becomes JSON) about success or failure.
* Tries to get a lock ('dirty record'). Returns an array (becomes JSON) about success or failure.
*
* @param int $recordId
* @param array $tableVars
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment