Record Locking

From Daxipedia

Jump to: navigation, search


Contents

[edit] Overview

To prevent multiple users from trying to modify the same record at the same time, 4D Ajax Framework implements a record locking system. This system keeps track of records and the users editing them to prevent conflicts. It is important to understand that the 4D Ajax Framework record locking system does not actually lock records at the Engine level. The system uses interprocess arrays to handle the states of 4D Ajax Framework locks. This means that it is not compatible with multiple 4D servers (or Client servers) running in a Round Robin setup.

[edit] Implementation

Every time a 4D Ajax Framework user attempts to load a record for editing the locked status of that record is checked. If the record is not currently locked by another user, a lock is set for the requesting user. If the record is currently locked by another user the requesting user is shown the record in Read Only mode. If the record is already locked by the requesting user the lock is refreshed.

When a user closes the detail for a record the lock that was set for that user is released. A lock is also automatically released after a set period of inactivity which can be set in the method DAX_DevHook_Preferences using the variable <>DAX_LOCK_TIMEOUT_m (by default 5 minutes). Set <>DAX_LOCK_TIMEOUT_m to ?00:00:00? to never timeout a lock.

[edit] Developer Responsibilities

While 4D Ajax Framework handles all necessary record locking tasks within its own processes, it is up to the developer to respect these locks in any code that does not interact with 4D Ajax Framework. If your database has Client/Server connections or handles web connections outside of the 4D Ajax Framework you will need to add calls to check the locked status of records with 4D Ajax Framework.

When you are loading a record for the user to edit in one of your own processes you should call DAX_Dev_Lock_IsRecordLocked to verify that 4D Ajax Framework has not currently given a web user exclusive access to the record. If the method returns True then you should not allow editing of the record. Note that DAX_Dev_Lock_IsRecordLocked checks both the 4D Engine locked state and the 4D Ajax Framework locked state to determine locked status of a record.

Example:

$locked_b:=DAX_Dev_Lock_IsRecordLocked($tableNumber_l;$recordNumber_l)

[edit] See Also

DAX_Dev_Lock_IsRecordLocked

[edit] External Links

Record Locking
Triggers

Personal tools