Skip to content

Commit 8edbf66

Browse files
Nathan BlinnNBSquare
authored andcommitted
RUST-734 Document support for sharded transactions
1 parent 30def14 commit 8edbf66

File tree

81 files changed

+18
-9513
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+18
-9513
lines changed

src/client/executor.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ impl Client {
9797
.into());
9898
}
9999
}
100-
101100
self.execute_operation_with_retry(op, Some(session)).await
102101
}
103102
None => {

src/client/session/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ lazy_static! {
4747
/// collections atomically. For more information about when and how to use transactions in MongoDB,
4848
/// see the [manual](https://docs.mongodb.com/manual/core/transactions/).
4949
///
50-
/// Replica set transactions are supported on MongoDB 4.0+. Transactions are associated with a
51-
/// `ClientSession`. To begin a transaction, call [`ClientSession::start_transaction`] on a
52-
/// `ClientSession`. The `ClientSession` must be passed to operations to be executed within the
53-
/// transaction.
50+
/// Replica set transactions are supported on MongoDB 4.0+. Sharded transactions are supported on
51+
/// MongoDDB 4.2+. Transactions are associated with a `ClientSession`. To begin a transaction, call
52+
/// [`ClientSession::start_transaction`] on a `ClientSession`. The `ClientSession` must be passed to
53+
/// operations to be executed within the transaction.
5454
///
5555
/// ```rust
5656
/// use mongodb::{
@@ -99,9 +99,6 @@ lazy_static! {
9999
/// }
100100
/// }
101101
/// ```
102-
// TODO RUST-734 Remove this note and adjust the above description to indicate that sharded
103-
// transactions are supported on 4.2+
104-
/// Note: the driver does not currently support transactions on sharded clusters.
105102
#[derive(Clone, Debug)]
106103
pub struct ClientSession {
107104
cluster_time: Option<ClusterTime>,

src/concern/test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ async fn snapshot_read_concern() {
179179
.database(function_name!())
180180
.collection::<Document>(function_name!());
181181

182-
// TODO RUST-734: Run this test on sharded clusters when transactions are complete.
183-
if client.is_replica_set() && client.server_version_gte(4, 0) {
182+
if client.supports_transactions() {
184183
let mut session = client.start_session(None).await.unwrap();
185184
let options = TransactionOptions::builder()
186185
.read_concern(ReadConcern::snapshot())

src/sdam/description/topology/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,6 @@ impl TopologyDescription {
326326
self.transaction_support_status = TransactionSupportStatus::Unsupported;
327327
}
328328
if let Ok(Some(max_wire_version)) = server_description.max_wire_version() {
329-
// TODO RUST-734: Evaluate whether we should permanently support sharded transactions.
330-
// If we leave the feature as unsupported, we should revert this code.
331329
self.transaction_support_status = if max_wire_version < 7
332330
|| (max_wire_version < 8 && self.topology_type == TopologyType::Sharded)
333331
{
@@ -742,8 +740,8 @@ pub(crate) enum TransactionSupportStatus {
742740
Unsupported,
743741

744742
/// Transactions are supported by this topology. A topology supports transactions if it
745-
/// supports sessions and its maxWireVersion >= 7. Transactions are not currently supported
746-
/// on sharded clusters (TODO RUST-734).
743+
/// supports sessions and its maxWireVersion >= 7. If the topology is sharded, maxWireVersion
744+
/// must be >= 8 for transactions to be supported.
747745
///
748746
/// Note that meeting these conditions does not guarantee that a deployment
749747
/// supports transactions; any other missing qualification will be reported by the server.

src/sync/test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ fn transactions() {
202202

203203
let should_skip = RUNTIME.block_on(async {
204204
let test_client = AsyncTestClient::new().await;
205-
// TODO RUST-734: Unskip this test on sharded clusters when transactions are complete.
206-
!test_client.is_replica_set() || test_client.server_version_lt(4, 0)
205+
!test_client.supports_transactions()
207206
});
208207
if should_skip {
209208
return;

0 commit comments

Comments
 (0)