Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunsk committed Apr 14, 2024
1 parent 9109751 commit 74e5c88
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ In this project we try to implement `Serializable Snapshot Isolation` from Badge
- [MatrixOrigin](https://github.com/arjunsk/matrixone/blob/c80e5add3048e656aac805ae6849d724cb0309dd/pkg/txn/client/types.go#L173)
- [Serializable Snapshot Isolation Paper](https://github.com/db-modules/awesome-dbdev/blob/master/papers/serializable-snapshot-isolation.pdf)
- [Write Snapshot Isolation Paper](https://github.com/dbminions/awesome-dbdev/blob/master/papers/write-snapshot-isolation.pdf)
- [SurrealKV](https://github.com/surrealdb/surrealkv/pull/5/files)
- [SurrealKV](https://github.com/surrealdb/surrealkv/pull/5/files)


### Flow

Reference: [Sarthak Makhija's Blog](https://tech-lessons.in/en/blog/serializable_snapshot_isolation/)

![img.png](img.png)
Binary file added img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions pkg/txn/b_txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ func (txn *Txn) Commit() error {
}

commitTs, err := txn.scheduler.NewCommitTs(txn)
if err != nil {
return err
}

{
// WAL start entry | START
// WAL write entry | DATA
}

if err != nil {
return err
}
doneCh := txn.executor.sendToWriteCh(txn.writeSet.ToExecutorReq(commitTs))

{
Expand Down
9 changes: 5 additions & 4 deletions pkg/txn/c_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ func (o *Scheduler) DoneCommit(commitTs uint64) {
}

func (o *Scheduler) hasConflictFor(txn *Txn) bool {
currTxnBeginTs := txn.snapshot.ts

for _, readyToCommitTxn := range o.readyToCommitTxns {
txnBeginTs := txn.snapshot.ts
if readyToCommitTxn.commitTs <= txnBeginTs {
if readyToCommitTxn.commitTs <= currTxnBeginTs {
continue
}

Expand All @@ -102,10 +103,10 @@ func (o *Scheduler) hasConflictFor(txn *Txn) bool {

func (o *Scheduler) gcOldReadyToCommitTxns() {
updatedReadyToCommitTxns := o.readyToCommitTxns[:0]
lastCommittedTxnTs := o.readTsMarker.DoneTill()
lastActiveReadTs := o.readTsMarker.DoneTill()

for _, readyToCommitTxn := range o.readyToCommitTxns {
if readyToCommitTxn.commitTs <= lastCommittedTxnTs {
if readyToCommitTxn.commitTs <= lastActiveReadTs {
continue
}
updatedReadyToCommitTxns = append(updatedReadyToCommitTxns, readyToCommitTxn)
Expand Down
1 change: 1 addition & 0 deletions pkg/txn/d_ts_waiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (w *TsWaiter) Run() {
}
}
}

func (w *TsWaiter) processWaitEvent(event Event) {
doneTill := w.DoneTill()
if doneTill >= event.ts {
Expand Down

0 comments on commit 74e5c88

Please sign in to comment.