Skip to content

Add ability to exclusively lock a record for performing a safe operation #483

Description

@kriszyp

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Fields

Priority

P3

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions