Skip to content

Commit cdae01e

Browse files
committed
Add query tx modes to docs
1 parent 3f81746 commit cdae01e

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

docs/apireference.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,44 @@ QueryTxContext (AsyncIO)
128128
:undoc-members:
129129

130130

131+
Query Tx Mode
132+
^^^^^^^^^^^^^
133+
134+
.. autoclass:: ydb.BaseQueryTxMode
135+
:members:
136+
:inherited-members:
137+
:undoc-members:
138+
:exclude-members: name, to_proto
139+
140+
141+
.. autoclass:: ydb.QueryOnlineReadOnly
142+
:members:
143+
:inherited-members:
144+
:undoc-members:
145+
:exclude-members: name, to_proto
146+
147+
148+
.. autoclass:: ydb.QuerySerializableReadWrite
149+
:members:
150+
:inherited-members:
151+
:undoc-members:
152+
:exclude-members: name, to_proto
153+
154+
155+
.. autoclass:: ydb.QuerySnapshotReadOnly
156+
:members:
157+
:inherited-members:
158+
:undoc-members:
159+
:exclude-members: name, to_proto
160+
161+
162+
.. autoclass:: ydb.QueryStaleReadOnly
163+
:members:
164+
:inherited-members:
165+
:undoc-members:
166+
:exclude-members: name, to_proto
167+
168+
131169
------------------------
132170

133171
Table Service

ydb/_grpc/grpcwrapper/ydb_query_public_types.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@
1111

1212

1313
class BaseQueryTxMode(IToProto):
14+
"""Abstract class for Query Transaction Modes."""
1415
@property
1516
@abc.abstractmethod
1617
def name(self) -> str:
1718
pass
1819

1920

2021
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+
"""
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

3237
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+
"""
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

4452
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+
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

5774
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+
5880
def __init__(self):
5981
self._name = "stale_read_only"
6082

ydb/query/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
__all__ = [
2+
"BaseQueryTxMode",
23
"QueryOnlineReadOnly",
34
"QuerySerializableReadWrite",
45
"QuerySnapshotReadOnly",
56
"QueryStaleReadOnly",
67
"QuerySessionPool",
7-
"QueryClientSync",
8+
"QueryClientSettings",
89
"QuerySession",
910
"QueryTxContext",
1011
]
@@ -20,6 +21,7 @@
2021

2122
from .._grpc.grpcwrapper import common_utils
2223
from .._grpc.grpcwrapper.ydb_query_public_types import (
24+
BaseQueryTxMode,
2325
QueryOnlineReadOnly,
2426
QuerySerializableReadWrite,
2527
QuerySnapshotReadOnly,

0 commit comments

Comments
 (0)