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
Data Integrity
- Prevent concurrent modifications
- Avoid data conflicts
- Maintain consistency
Process Management
- Support long-running operations
- Coordinate multi-step updates
- Manage workflow dependencies
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'
}
Field | Type | Description |
---|---|---|
user | string | The ID of the user who created the lock |
system | string | TODO: The ID of the system that created the lock |
process | string | Optional name of the process that created the lock |
created | timestamp | When the lock was created |
duration | integer | How long the lock should last in seconds |
expiration | timestamp | When 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:
- On object is considerd 'locked' when the object has a lock metadata field set to a diferend vallue then null.
- When an object is locked, the object is only editable or deletable by the user who created the lock.
- Only the user who created the lock OR the system that created the lock can unlock the object.
- When an locked objets is updated, the lock is automatically extended by the duration of the update.
- Locks my be set for any duration, but the default duration is 1 hour.
Related Features
- Audit Trails - Track lock operations
- Access Control - Manage lock permissions