ysono / pancake

7 stars 1 forks source link

Serializable Snapshot Isolation #56

Closed ysono closed 2 years ago

ysono commented 3 years ago

(Scroll down to see the latest version.)

LSM evolution outonly drawio

SSI ontonly drawio

The first diagram is a documentation of basically what we have so far. We have secondary indexes and serial execution, and it resembles the box on the third row in the diagram. Also presented is a simple concurrently executed design, which provides no isolation; this design has not been implemented.

The second diagram is a proposal for adding Serializable Snapshot Isolation (SSI) on top of what we have so far.

Motivation

If we are to add concurrent execution, I believe it is optimal to jump straight to SSI. Because we have secondary indexes, data are distributed across indexes, and it is wise to synchronize comitting across them. And, if we want to synchronize committing, a snapshot-based isolation seems natural (Read Uncommitted and Read Committed depend on per-PrimaryKey lock; and I believe secondary indexes are not locked). And, if we use snapshots, we only need to add conflict checks and retries in order to guarantee SSI.

Correctness

There has been no formal check on the correctness of any of the design. However, there are several perspectives by which correctness can be assessed (in a non-rigorous way).

Future evolution

Some ideas are included in the bottom of the SSI diagram. IMO either we add more async/await concurrency, using asynchronous file I/O (io_uring), or we partition operations by data and run single-thread (actor) per core.

etc

(I have a suspicion that this design is better utilized on multiple different tables or datastores, and it's fine to stick with serial execution per table. But since this is a learning project, I want to implement this design anyway.)

ysono commented 3 years ago

LSM evolution outonly drawio

Changes:


SSI ontonly drawio

Changes above:

Further changes:

ysono commented 3 years ago

SSI ontonly drawio

Changes:

ysono commented 2 years ago

Closing in favor of https://github.com/ysono/pancake/issues/59. Delta between this design and that design: