Hi all,
We have identified that we need the ability to mark certain records in arbitrary DB tables of the OpenPetra Database as 'locked' or 'checked out', indicating to the whole application that some user needs to work exclusively on this record and that therefore no other user must be able to edit it. For that ability we not only need to be able to 'lock' a certain DB record in a certain DB table, but we also need to be able to check whether a certain DB record in a certain DB table is currently 'locked' (and preferable also find out who locked it, and when).
Examples of OpenPetra DB Tables where such a 'locking' / 'checking out' would be needed in the : a_batch, a_gift_batch, a_ledger.
OpenPetra has a well working system for 'non-optimistic' record locking (which is the default locking mechanism we use with OpenPetra for speed and concurrency reasons). It is also possible to acquire 'pessimistic' record locks using a DB Transaction with the desired IsolationLevel, so those aspects of usual DB record locking are already catered for within OpenPetra.
The problem comes in when a need arises to check whether a certain record in a certain DB table is 'locked' or 'checked out' by a user. Also, a provision needs to exist to 'unlock' a single or all 'locked' DB record(s) in case (1) a user does no longer need the 'lock', (2) in case the user's client crashes, (3) after a server restart [all locks need to be removed then], (4) an administrator wants to manually remove lock(s).
There are various approaches to solve this problem: