Kinto / Kinto/kinto.js

Prevent concurrent conflicting transactions by incrementing a local revision number

Open
#34 1 comment 0 reactions 0 assignees View on GitHub
stale
Dominant language
TypeScript
Stars
330
Forks
75
Avg merge
3d 5h
Merged PRs (30d)
4

Description

#### Use case
- We have an edition form for a given record in state A, and we don't have submitted the form yet;
- Concurrently, a worker modifies this record and turns it into state B;
- We now submit the form, which overrides what's just been updated by the worker, which is the problem we're trying to solve here.
#### Flow
- Form loads existing record with `local_rev==1` (eg. that value is contained in some hidden `input` field, CSRF-token protection style or any other way, eg in React component's props);
- Worker loads existing record with `local_rev==1`;
- Worker updates existing record, persistence layer bumps local_rev to `2`;
- Form is submitted, data are sent to the local persistence layer adapter;
- Persistence layer knows that local_rev for that record is `2`, but form has just sent local_rev==`1`: an error is raised.
##### Notes
- **Do not** synchronize the local revision number to the server;
- Each time we synchronize a remote record from the server to the local database, we reset its local revision number;
- Any synchronized remote records should bump matching local equivalent record's `local_rev` number.

We'd love hearing thoughts and feedback from @daleharvey, @leplatrem, @Natim, @michielbdejong

Contributor guide

Open the contributing guide

Research direction

Start by tracing the local persistence adapter and the remote-record synchronization flow described in the issue. Determine where local records are loaded, updated, and synchronized, then define how local_rev is reset or incremented and how a submitted stale revision is rejected. Done requires the conflict case to raise an error without synchronizing the local revision to the server.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.