Read the latest version from the DB (check if locked, if so abort)
Request a lock from the leader (consensus occurs)
On lock commit, update metadata and return the file's blobs.
On a write access (close):
store the blobs and the write metadata into the cache (read your writes)
forward the remote write to the leader
if leader is unavailable, keep retrying both version decision and lock release occur simultaneously
if leader rejects the write (e.g. the lock was removed before the write), mark the conflict on the file (similar to the Git method of marking merge conflicts).
Create version replication with write locks:
Note that there are actually three modes of operation:
The procedure is documented as follows:
On a read access (open):
On a write access (close):