This will be another method on the Table/Resource interface, with the form of:
table.lock(primaryKey): Promise<WritableRecord>
(this is very similar interface to the update method, and returns the same record type).
If a node already has an exclusive lock on a record, it can immediately proceed.
If a node does not have an exclusive lock, but has a shared lock, it needs to broadcast a request to all nodes that it wants to acquire an exclusive lock. Once all other nodes have responded and granted this request, the operation can proceed. If an exclusive lock is held by one other node, the lock can be requested from that node.
We may support local-only locks for some use cases as well.
There may need to be a distinction between a node’s lock ownership (is retained after commit) and the transaction’s lock ownership (released after commit).
Changing a record from locked to unlocked should trigger a version change (but possibly only an audit entry for when a node is locking), to ensure no concurrent attempts to change.
Locking will be recorded in record metadata, and should delay any other writes that are attempted on that record.
This will be another method on the Table/Resource interface, with the form of:
table.lock(primaryKey): Promise<WritableRecord>(this is very similar interface to the update method, and returns the same record type).
If a node already has an exclusive lock on a record, it can immediately proceed.
If a node does not have an exclusive lock, but has a shared lock, it needs to broadcast a request to all nodes that it wants to acquire an exclusive lock. Once all other nodes have responded and granted this request, the operation can proceed. If an exclusive lock is held by one other node, the lock can be requested from that node.
We may support local-only locks for some use cases as well.
There may need to be a distinction between a node’s lock ownership (is retained after commit) and the transaction’s lock ownership (released after commit).
Changing a record from locked to unlocked should trigger a version change (but possibly only an audit entry for when a node is locking), to ensure no concurrent attempts to change.
Locking will be recorded in record metadata, and should delay any other writes that are attempted on that record.