| 864 | /// List of valid isolation levels. |
| 865 | #[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] |
| 866 | pub enum IsolationLevel { |
| 867 | ReadUncommitted, |
| 868 | ReadCommitted, |
| 869 | RepeatableRead, |
| 870 | Serializable, |
| 871 | /* TODO(jkosh44) Move this comment to user facing docs when this isolation level becomes available to users. |
| 872 | * The Strong Session Serializable isolation level combines the Serializable isolation level |
| 873 | * (https://jepsen.io/consistency/models/serializable) with the Sequential consistency model |
| 874 | * (https://jepsen.io/consistency/models/sequential). See |
| 875 | * http://dbmsmusings.blogspot.com/2019/06/correctness-anomalies-under.html and |
| 876 | * https://cs.uwaterloo.ca/~kmsalem/pubs/DaudjeeICDE04.pdf. Operations within a single session |
| 877 | * are linearizable, but operations across sessions are not linearizable. |
| 878 | * |
| 879 | * Operations in sessions that use Strong Session Serializable are not linearizable with |
| 880 | * operations in sessions that use Strict Serializable. For example, consider the following |
| 881 | * sequence of events in order: |
| 882 | * |
| 883 | * 1. Session s0 executes read at timestamp t0 under Strong Session Serializable. |
| 884 | * 2. Session s1 executes read at timestamp t1 under Strict Serializable. |
| 885 | * |
| 886 | * If t0 > t1, then this is not considered a consistency violation. This matches with the |
| 887 | * semantics of Serializable, which can execute queries arbitrarily in the future without |
| 888 | * violating the consistency of Strict Serializable queries. |
| 889 | * |
| 890 | * All operations within a session that use Strong Session Serializable are only |
| 891 | * linearizable within operations within the same session that also use Strong Session |
| 892 | * Serializable. For example, consider the following sequence of events in order: |
| 893 | * |
| 894 | * 1. Session s0 executes read at timestamp t0 under Strong Session Serializable. |
| 895 | * 2. Session s0 executes read at timestamp t1 under I. |
| 896 | * |
| 897 | * If I is Strong Session Serializable then t0 > t1 is guaranteed. If I is any other isolation |
| 898 | * level then t0 < t1 is not considered a consistency violation. This matches the semantics of |
| 899 | * Serializable, which can execute queries arbitrarily in the future without violating the |
| 900 | * consistency of Strict Serializable queries within the same session. |
| 901 | * |
| 902 | * The items left TODO before this is considered ready for prod are: |
| 903 | * |
| 904 | * - Add more tests. |
| 905 | * - Linearize writes to system tables under this isolation (most of these are the side effect |
| 906 | * of some DDL). |
| 907 | */ |
| 908 | StrongSessionSerializable, |
| 909 | StrictSerializable, |
| 910 | /// Bounded staleness — pick `T` such that `T >= now_ms - D` and the |
| 911 | /// query does not wait on input frontiers. Errors if no such `T` exists |
| 912 | /// in the no-wait window. See |
| 913 | /// `doc/developer/design/20260429_bounded_staleness_isolation.md`. |
| 914 | BoundedStaleness(std::time::Duration), |
| 915 | } |
| 916 | |
| 917 | impl IsolationLevel { |
| 918 | const READ_UNCOMMITTED: &'static str = "read uncommitted"; |
no outgoing calls
no test coverage detected