HarperFast / HarperFast/harper

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

Open
#483 3 comments 0 reactions 1 assignee Claimed by @kriszyp View on GitHub
Dominant language
JavaScript
Stars
89
Forks
10
Avg merge
2d 6h
Merged PRs (30d)
200

Description

This will be another method on the Table/Resource interface, with the form of:

`table.lock(primaryKey): Promise`

(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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.