@@ -3639,7 +3639,8 @@ update_employee_info (mongoc_client_session_t *cs, bson_t *reply, bson_error_t *
3639
3639
rc = mongoc_read_concern_new ();
3640
3640
mongoc_read_concern_set_level (rc , MONGOC_READ_CONCERN_LEVEL_SNAPSHOT );
3641
3641
wc = mongoc_write_concern_new ();
3642
- mongoc_write_concern_set_w (wc , MONGOC_WRITE_CONCERN_W_MAJORITY );
3642
+ mongoc_write_concern_set_w (
3643
+ wc , MONGOC_WRITE_CONCERN_W_MAJORITY ); /* Atlas connection strings include majority by default*/
3643
3644
txn_opts = mongoc_transaction_opts_new ();
3644
3645
mongoc_transaction_opts_set_read_concern (txn_opts , rc );
3645
3646
mongoc_transaction_opts_set_write_concern (txn_opts , wc );
@@ -3781,8 +3782,6 @@ with_transaction_example (bson_error_t *error)
3781
3782
{
3782
3783
mongoc_client_t * client = NULL ;
3783
3784
mongoc_write_concern_t * wc = NULL ;
3784
- mongoc_read_concern_t * rc = NULL ;
3785
- mongoc_read_prefs_t * rp = NULL ;
3786
3785
mongoc_collection_t * coll = NULL ;
3787
3786
bool success = false;
3788
3787
bool ret = false;
@@ -3804,9 +3803,11 @@ with_transaction_example (bson_error_t *error)
3804
3803
3805
3804
client = get_client ();
3806
3805
3807
- /* Prereq: Create collections. */
3806
+ /* Prereq: Create collections. Note Atlas connection strings include a majority write
3807
+ * concern by default.
3808
+ */
3808
3809
wc = mongoc_write_concern_new ();
3809
- mongoc_write_concern_set_wmajority (wc , 1000 );
3810
+ mongoc_write_concern_set_wmajority (wc , 0 );
3810
3811
insert_opts = bson_new ();
3811
3812
mongoc_write_concern_append (wc , insert_opts );
3812
3813
coll = mongoc_client_get_collection (client , "mydb1" , "foo" );
@@ -3832,11 +3833,6 @@ with_transaction_example (bson_error_t *error)
3832
3833
3833
3834
/* Step 2: Optional. Define options to use for the transaction. */
3834
3835
txn_opts = mongoc_transaction_opts_new ();
3835
- rp = mongoc_read_prefs_new (MONGOC_READ_PRIMARY );
3836
- rc = mongoc_read_concern_new ();
3837
- mongoc_read_concern_set_level (rc , MONGOC_READ_CONCERN_LEVEL_LOCAL );
3838
- mongoc_transaction_opts_set_read_prefs (txn_opts , rp );
3839
- mongoc_transaction_opts_set_read_concern (txn_opts , rc );
3840
3836
mongoc_transaction_opts_set_write_concern (txn_opts , wc );
3841
3837
3842
3838
/* Step 3: Use mongoc_client_session_with_transaction to start a transaction,
@@ -3851,8 +3847,6 @@ with_transaction_example (bson_error_t *error)
3851
3847
bson_destroy (doc );
3852
3848
mongoc_collection_destroy (coll );
3853
3849
bson_destroy (insert_opts );
3854
- mongoc_read_concern_destroy (rc );
3855
- mongoc_read_prefs_destroy (rp );
3856
3850
mongoc_write_concern_destroy (wc );
3857
3851
mongoc_transaction_opts_destroy (txn_opts );
3858
3852
mongoc_client_session_destroy (session );
0 commit comments