Skip to main content

Object Locking

Object Locking provides a mechanism to prevent concurrent modifications to objects, ensuring data integrity in multi-user environments.

Overview

The locking system provides:

  • Temporary exclusive access to objects
  • Lock duration management
  • Lock ownership tracking
  • Automatic lock expiration

Key Benefits

  1. Data Integrity

    • Prevent concurrent modifications
    • Avoid data conflicts
    • Maintain consistency
  2. Process Management

    • Support long-running operations
    • Coordinate multi-step updates
    • Manage workflow dependencies
  3. User Coordination

    • Clear ownership indication
    • Transparent lock status
    • Managed access control

Lock Information Structure

When an object is locked, the following metadata is stored:

{
'user': 'user_id',
'process': 'optional_process_name',
'created': 'timestamp',
'duration': 'seconds',
'expiration': 'timestamp'
}
FieldTypeDescription
userstringThe ID of the user who created the lock
systemstringTODO: The ID of the system that created the lock
processstringOptional name of the process that created the lock
createdtimestampWhen the lock was created
durationintegerHow long the lock should last in seconds
expirationtimestampWhen the lock will automatically expire

The user, system and process fields follow the definition set by Audit Trails and SHOULD match the same input.

Lock Logic

When an object is locked, the following logic is applied:

  1. On object is considerd 'locked' when the object has a lock metadata field set to a diferend vallue then null.
  2. When an object is locked, the object is only editable or deletable by the user who created the lock.
  3. Only the user who created the lock OR the system that created the lock can unlock the object.
  4. When an locked objets is updated, the lock is automatically extended by the duration of the update.
  5. Locks my be set for any duration, but the default duration is 1 hour.