You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ydb/docs/en/core/concepts/_includes/transactions.md
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,8 @@ For more information about YQL support in {{ ydb-short-name }}, see the [YQL doc
47
47
48
48
## Distributed transactions {#distributed-tx}
49
49
50
-
A database table in {{ ydb-short-name }} can be sharded by the range of the primary key values. Different table shards can be served by different distributed database servers (including ones in different locations). They can also move independently between servers to enable rebalancing or ensure shard operability if servers or network equipment goes offline.
50
+
A database [table](../datamodel/table.md) in {{ ydb-short-name }} can be sharded by the range of the primary key values. Different table shards can be served by different distributed database servers (including ones in different locations). They can also move independently between servers to enable rebalancing or ensure shard operability if servers or network equipment goes offline.
51
51
52
-
{{ ydb-short-name }} supports distributed transactions. Distributed transactions are transactions that affect more than one shard of one or more tables. They require more resources and take more time. While point reads and writes may take up to 10 ms in 99 percentile, distributed transactions typically take from 20 to 500 ms.
52
+
A [topic](../topic.md) in {{ ydb-short-name }} can be sharded into several partitions. Different topic partitions, similar to table shards, can be served by different distributed database servers.
53
+
54
+
{{ ydb-short-name }} supports distributed transactions. Distributed transactions are transactions that affect more than one shard of one or more tables and topics. They require more resources and take more time. While point reads and writes may take up to 10 ms in the 99th percentile, distributed transactions typically take from 20 to 500 ms.
Copy file name to clipboardExpand all lines: ydb/docs/en/core/reference/ydb-sdk/topic.md
+56Lines changed: 56 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1167,6 +1167,8 @@ You can read messages without a [commit](#no-commit) as well. In this case, all
1167
1167
1168
1168
Information about which messages have already been processed can be [saved on the client side](#client-commit) by sending the starting consumer offset to the server when creating a new connection. This does not change the consumer offset on the server.
1169
1169
1170
+
Data from topics can be read in the context of [transactions](#read-tx). In this case, the reading offset will only advance when the transaction is committed. On reconnect, all uncommitted messages will be read again.
1171
+
1170
1172
{%list tabs %}
1171
1173
1172
1174
- C++
@@ -1572,6 +1574,60 @@ Reading progress is usually saved on a server for each Consumer. However, such p
1572
1574
1573
1575
{%list tabs %}
1574
1576
1577
+
- C++
1578
+
1579
+
Before reading messages, the client code must pass a transaction object reference to the reading session settings.
auto events = ReadSession->GetEvents(topicSettings);
1614
+
1615
+
for (auto& event : events) {
1616
+
if (auto* e = std::get_if<TStopPartitionSessionEvent>(&event) {
1617
+
stopPartitionSessionEvent = std::move(*e);
1618
+
} else {
1619
+
// process the event and write results to a table
1620
+
}
1621
+
}
1622
+
1623
+
NYdb::NTable::TCommitTxSettings commitSettings;
1624
+
auto commitResult = Transaction.Commit(commitSettings).GetValueSync();
1625
+
1626
+
if (stopPartitionSessionEvent) {
1627
+
stopPartitionSessionEvent->Commit();
1628
+
}
1629
+
```
1630
+
1575
1631
- Java (sync)
1576
1632
1577
1633
[Example on GitHub](https://github.com/ydb-platform/ydb-java-examples/blob/develop/ydb-cookbook/src/main/java/tech/ydb/examples/topic/transactions/TransactionReadSync.java)
0 commit comments