Skip to content

Commit

Permalink
Add Snapshot-read-only isolation support
Browse files Browse the repository at this point in the history
You can read more about this type of isolation here https://ydb.tech/docs/en/concepts/transactions#modes
  • Loading branch information
jorki02 committed Jun 26, 2024
1 parent 56fd568 commit b984de4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ private TxControl<?> getTxControl() {
case ONLINE_CONSISTENT_READ_ONLY -> TxControl.onlineRo().setAllowInconsistentReads(false);
case ONLINE_INCONSISTENT_READ_ONLY -> TxControl.onlineRo().setAllowInconsistentReads(true);
case STALE_CONSISTENT_READ_ONLY -> TxControl.staleRo();
case SNAPSHOT -> {
TxControl<?> txControl = (txId != null ? TxControl.id(txId) : TxControl.snapshotRo());
yield txControl.setCommitTx(false);
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ public enum IsolationLevel {
* An <em>almost</em> recent consistent state of the database. Read only.
* This level is faster then {@code ONLINE_CONSISTENT_READ_ONLY}, but may return stale data.
*/
STALE_CONSISTENT_READ_ONLY("SC");
STALE_CONSISTENT_READ_ONLY("SC"),

/**
* All the read operations within a transaction access the database snapshot. Read only.
* All the data reads are consistent. The snapshot is taken when the transaction begins,
* meaning the transaction sees all changes committed before it began.
*/
SNAPSHOT("SP");

@Getter
private final String txIdSuffix;
Expand Down

0 comments on commit b984de4

Please sign in to comment.