1111
1212
1313class BaseQueryTxMode (IToProto ):
14+ """Abstract class for Query Transaction Modes."""
1415 @property
1516 @abc .abstractmethod
1617 def name (self ) -> str :
1718 pass
1819
1920
2021class QuerySnapshotReadOnly (BaseQueryTxMode ):
22+ """All the read operations within a transaction access the database snapshot.
23+ All the data reads are consistent. The snapshot is taken when the transaction begins,
24+ meaning the transaction sees all changes committed before it began.
25+ """
2126 def __init__ (self ):
2227 self ._name = "snapshot_read_only"
2328
@@ -30,6 +35,9 @@ def to_proto(self) -> ydb_query_pb2.SnapshotModeSettings:
3035
3136
3237class QuerySerializableReadWrite (BaseQueryTxMode ):
38+ """This mode guarantees that the result of successful parallel transactions is equivalent
39+ to their serial execution, and there are no read anomalies for successful transactions.
40+ """
3341 def __init__ (self ):
3442 self ._name = "serializable_read_write"
3543
@@ -42,6 +50,15 @@ def to_proto(self) -> ydb_query_pb2.SerializableModeSettings:
4250
4351
4452class QueryOnlineReadOnly (BaseQueryTxMode ):
53+ """Each read operation in the transaction is reading the data that is most recent at execution time.
54+ The consistency of retrieved data depends on the allow_inconsistent_reads setting:
55+ * false (consistent reads): Each individual read operation returns consistent data,
56+ but no consistency is guaranteed between reads.
57+ Reading the same table range twice may return different results.
58+ * true (inconsistent reads): Even the data fetched by a particular
59+ read operation may contain inconsistent results.
60+ """
61+
4562 def __init__ (self , allow_inconsistent_reads : bool = False ):
4663 self .allow_inconsistent_reads = allow_inconsistent_reads
4764 self ._name = "online_read_only"
@@ -55,6 +72,11 @@ def to_proto(self) -> ydb_query_pb2.OnlineModeSettings:
5572
5673
5774class QueryStaleReadOnly (BaseQueryTxMode ):
75+ """Read operations within a transaction may return results that are slightly out-of-date
76+ (lagging by fractions of a second). Each individual read returns consistent data,
77+ but no consistency between different reads is guaranteed.
78+ """
79+
5880 def __init__ (self ):
5981 self ._name = "stale_read_only"
6082
0 commit comments