11
11
12
12
13
13
class BaseQueryTxMode (IToProto ):
14
+ """Abstract class for Query Transaction Modes."""
14
15
@property
15
16
@abc .abstractmethod
16
17
def name (self ) -> str :
17
18
pass
18
19
19
20
20
21
class 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
+ """
21
26
def __init__ (self ):
22
27
self ._name = "snapshot_read_only"
23
28
@@ -30,6 +35,9 @@ def to_proto(self) -> ydb_query_pb2.SnapshotModeSettings:
30
35
31
36
32
37
class 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
+ """
33
41
def __init__ (self ):
34
42
self ._name = "serializable_read_write"
35
43
@@ -42,6 +50,15 @@ def to_proto(self) -> ydb_query_pb2.SerializableModeSettings:
42
50
43
51
44
52
class 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
+
45
62
def __init__ (self , allow_inconsistent_reads : bool = False ):
46
63
self .allow_inconsistent_reads = allow_inconsistent_reads
47
64
self ._name = "online_read_only"
@@ -55,6 +72,11 @@ def to_proto(self) -> ydb_query_pb2.OnlineModeSettings:
55
72
56
73
57
74
class 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
+
58
80
def __init__ (self ):
59
81
self ._name = "stale_read_only"
60
82
0 commit comments