diff options
23 files changed, 69 insertions, 25 deletions
diff --git a/etc/evergreen.yml b/etc/evergreen.yml index dbca2b1e6f1..331fb165544 100644 --- a/etc/evergreen.yml +++ b/etc/evergreen.yml @@ -5615,6 +5615,14 @@ tasks: resmoke_args: --suites=sharded_jscore_txns --storageEngine=wiredTiger - <<: *task_template + name: sharded_jscore_txns_without_snapshot + commands: + - func: "do setup" + - func: "run tests" + vars: + resmoke_args: --suites=sharded_jscore_txns --storageEngine=wiredTiger --excludeWithAnyTags=uses_snapshot_read_concern + +- <<: *task_template name: sharded_jscore_txns_sharded_collections commands: - func: "do setup" @@ -5638,6 +5646,15 @@ tasks: resmoke_args: --storageEngine=wiredTiger fallback_num_sub_suites: 1 +- name: sharded_causally_consistent_jscore_txns_passthrough_without_snapshot_gen + commands: + - func: "generate resmoke tasks" + vars: + task: sharded_causally_consistent_jscore_txns_passthrough_without_snapshot + suite: sharded_causally_consistent_jscore_txns_passthrough + resmoke_args: --storageEngine=wiredTiger --excludeWithAnyTags=uses_snapshot_read_concern + fallback_num_sub_suites: 1 + - <<: *task_template name: sharded_collections_causally_consistent_jscore_txns_passthrough commands: @@ -10685,7 +10702,7 @@ buildvariants: # enableMajorityReadConcern:"false" (SERVER-37559). test_flags: >- --majorityReadConcern=off - --excludeWithAnyTags=requires_majority_read_concern,uses_prepare_transaction,uses_multi_shard_transaction + --excludeWithAnyTags=requires_majority_read_concern,uses_prepare_transaction,uses_multi_shard_transaction,uses_atclustertime compile_flags: >- -j$(grep -c ^processor /proc/cpuinfo) --ssl @@ -10829,8 +10846,11 @@ buildvariants: - name: sasl - name: session_jscore_passthrough - name: sharded_collections_jscore_passthrough - - name: sharded_causally_consistent_jscore_txns_passthrough_gen - - name: sharded_jscore_txns + # Sharded transactions suites exclude tests that use snapshot read concern, since snapshot read + # concern uses 'atClusterTime' in sharded clusters, and this is not supported with + # enableMajorityReadConcern=false. + - name: sharded_causally_consistent_jscore_txns_passthrough_without_snapshot_gen + - name: sharded_jscore_txns_without_snapshot - name: sharded_multi_stmt_txn_jscore_passthrough - name: sharding_gen - name: sharding_auth_gen diff --git a/jstests/core/txns/aggregation_in_transaction.js b/jstests/core/txns/aggregation_in_transaction.js index 5cd5285a6b5..4ddc9a6a11a 100644 --- a/jstests/core/txns/aggregation_in_transaction.js +++ b/jstests/core/txns/aggregation_in_transaction.js @@ -1,5 +1,5 @@ // Tests that aggregation is supported in transactions. -// @tags: [uses_transactions] +// @tags: [uses_transactions, uses_snapshot_read_concern] (function() { "use strict"; diff --git a/jstests/core/txns/basic_causal_consistency.js b/jstests/core/txns/basic_causal_consistency.js index a14b0899dab..d83ed4cf85b 100644 --- a/jstests/core/txns/basic_causal_consistency.js +++ b/jstests/core/txns/basic_causal_consistency.js @@ -1,5 +1,5 @@ // Test that the shell helper supports causal consistency. -// @tags: [uses_transactions] +// @tags: [uses_transactions, uses_snapshot_read_concern] (function() { "use strict"; diff --git a/jstests/core/txns/commands_not_allowed_in_txn.js b/jstests/core/txns/commands_not_allowed_in_txn.js index d86d06e775a..075918627e3 100644 --- a/jstests/core/txns/commands_not_allowed_in_txn.js +++ b/jstests/core/txns/commands_not_allowed_in_txn.js @@ -1,5 +1,5 @@ // Test commands that are not allowed in multi-document transactions. -// @tags: [uses_transactions] +// @tags: [uses_transactions, uses_snapshot_read_concern] (function() { "use strict"; diff --git a/jstests/core/txns/concurrent_drops_and_creates.js b/jstests/core/txns/concurrent_drops_and_creates.js index 8bcca5ba0d8..b025f5a33c3 100644 --- a/jstests/core/txns/concurrent_drops_and_creates.js +++ b/jstests/core/txns/concurrent_drops_and_creates.js @@ -1,6 +1,6 @@ // Test that a transaction cannot write to a collection that has been dropped or created since the // transaction started. -// @tags: [uses_transactions] +// @tags: [uses_transactions, uses_snapshot_read_concern] (function() { "use strict"; diff --git a/jstests/core/txns/finished_transaction_error_handling.js b/jstests/core/txns/finished_transaction_error_handling.js index 487f6b12207..f0907998578 100644 --- a/jstests/core/txns/finished_transaction_error_handling.js +++ b/jstests/core/txns/finished_transaction_error_handling.js @@ -1,5 +1,5 @@ // Test committed and aborted transactions cannot be changed but commitTransaction is retryable. -// @tags: [uses_transactions] +// @tags: [uses_transactions, uses_snapshot_read_concern] (function() { "use strict"; diff --git a/jstests/core/txns/list_collections_not_blocked_by_txn.js b/jstests/core/txns/list_collections_not_blocked_by_txn.js index 246cf2ec201..d1384136b07 100644 --- a/jstests/core/txns/list_collections_not_blocked_by_txn.js +++ b/jstests/core/txns/list_collections_not_blocked_by_txn.js @@ -1,4 +1,4 @@ -// @tags: [uses_transactions] +// @tags: [uses_transactions, uses_snapshot_read_concern] // This test ensures that listCollections does not conflict with multi-statement transactions // as a result of taking MODE_S locks that are incompatible with MODE_IX needed for writes. (function() { diff --git a/jstests/core/txns/multi_statement_transaction_abort.js b/jstests/core/txns/multi_statement_transaction_abort.js index 470fd3bd57a..3e8e8a62758 100644 --- a/jstests/core/txns/multi_statement_transaction_abort.js +++ b/jstests/core/txns/multi_statement_transaction_abort.js @@ -1,5 +1,5 @@ // Test basic multi-statement transaction abort. -// @tags: [uses_transactions] +// @tags: [uses_transactions, uses_snapshot_read_concern] (function() { "use strict"; diff --git a/jstests/core/txns/multi_statement_transaction_command_args.js b/jstests/core/txns/multi_statement_transaction_command_args.js index abffa8ec1b5..1ef9f6468ca 100644 --- a/jstests/core/txns/multi_statement_transaction_command_args.js +++ b/jstests/core/txns/multi_statement_transaction_command_args.js @@ -1,7 +1,7 @@ /** * Verify that multi-statement transaction command arguments behave correctly. * - * @tags: [uses_transactions] + * @tags: [uses_transactions, uses_snapshot_read_concern] */ (function() { diff --git a/jstests/core/txns/multi_statement_transaction_using_api.js b/jstests/core/txns/multi_statement_transaction_using_api.js index ed279677a46..c598318aec8 100644 --- a/jstests/core/txns/multi_statement_transaction_using_api.js +++ b/jstests/core/txns/multi_statement_transaction_using_api.js @@ -1,5 +1,5 @@ // Test basic transaction write ops, reads, and commit/abort using the shell helper. -// @tags: [uses_transactions] +// @tags: [uses_transactions, uses_snapshot_read_concern] (function() { "use strict"; diff --git a/jstests/core/txns/no_read_or_write_concern_inside_txn.js b/jstests/core/txns/no_read_or_write_concern_inside_txn.js index c3c5a83b5b0..31e29117f81 100644 --- a/jstests/core/txns/no_read_or_write_concern_inside_txn.js +++ b/jstests/core/txns/no_read_or_write_concern_inside_txn.js @@ -2,7 +2,7 @@ * Verify that readConcern and writeConcern are not allowed in transactions other than the * first statement (for readConcern) and the commit (for writeConcern) * - * @tags: [uses_transactions] + * @tags: [uses_transactions, uses_snapshot_read_concern] */ (function() { diff --git a/jstests/core/txns/no_reads_from_system_dot_views_in_txn.js b/jstests/core/txns/no_reads_from_system_dot_views_in_txn.js index 2040ee8f8f3..280b4f0f1bf 100644 --- a/jstests/core/txns/no_reads_from_system_dot_views_in_txn.js +++ b/jstests/core/txns/no_reads_from_system_dot_views_in_txn.js @@ -1,5 +1,5 @@ // Tests that it is illegal to read from system.views within a transaction. -// @tags: [uses_transactions] +// @tags: [uses_transactions, uses_snapshot_read_concern] (function() { "use strict"; diff --git a/jstests/core/txns/no_writes_to_system_collections_in_txn.js b/jstests/core/txns/no_writes_to_system_collections_in_txn.js index 5b4c70d0b64..4b13908773e 100644 --- a/jstests/core/txns/no_writes_to_system_collections_in_txn.js +++ b/jstests/core/txns/no_writes_to_system_collections_in_txn.js @@ -1,5 +1,5 @@ // Tests that it is illegal to write to system collections within a transaction. -// @tags: [uses_transactions] +// @tags: [uses_transactions, uses_snapshot_read_concern] (function() { "use strict"; diff --git a/jstests/core/txns/non_transactional_operations_on_session_with_transaction.js b/jstests/core/txns/non_transactional_operations_on_session_with_transaction.js index 43a67c3dfd3..74ef4228362 100644 --- a/jstests/core/txns/non_transactional_operations_on_session_with_transaction.js +++ b/jstests/core/txns/non_transactional_operations_on_session_with_transaction.js @@ -3,7 +3,7 @@ * are non-transactional, and do not see or affect any transaction state. This test avoids using * shell helpers to not inherit transaction state. * - * @tags: [uses_transactions] + * @tags: [uses_transactions, uses_snapshot_read_concern] */ (function() { diff --git a/jstests/core/txns/read_concerns.js b/jstests/core/txns/read_concerns.js index 7d70ea4c8dc..ffdd381128a 100644 --- a/jstests/core/txns/read_concerns.js +++ b/jstests/core/txns/read_concerns.js @@ -1,6 +1,6 @@ // Verifies which read concern levels transactions support, with and without afterClusterTime. // -// @tags: [uses_transactions] +// @tags: [uses_transactions, uses_snapshot_read_concern] (function() { "use strict"; diff --git a/jstests/core/txns/repeatable_reads_in_transaction.js b/jstests/core/txns/repeatable_reads_in_transaction.js index 9b6ace73ee9..5fe2d8bf624 100644 --- a/jstests/core/txns/repeatable_reads_in_transaction.js +++ b/jstests/core/txns/repeatable_reads_in_transaction.js @@ -1,6 +1,6 @@ // Test to guarantee read repeatability, meaning that while in a transaction, we should repeatedly // read the same data even if it was modified outside of the transaction. -// @tags: [uses_transactions] +// @tags: [uses_transactions, uses_snapshot_read_concern] (function() { "use strict"; diff --git a/jstests/core/txns/view_reads_in_transaction.js b/jstests/core/txns/view_reads_in_transaction.js index ea70c5f333a..68c7ad91172 100644 --- a/jstests/core/txns/view_reads_in_transaction.js +++ b/jstests/core/txns/view_reads_in_transaction.js @@ -1,5 +1,5 @@ // Tests that reads on views are supported in transactions. -// @tags: [uses_transactions] +// @tags: [uses_transactions, uses_snapshot_read_concern] (function() { "use strict"; diff --git a/jstests/libs/txns/txn_override.js b/jstests/libs/txns/txn_override.js index 931d49d7ec9..35e711a9cb7 100644 --- a/jstests/libs/txns/txn_override.js +++ b/jstests/libs/txns/txn_override.js @@ -55,11 +55,12 @@ // the entire transaction. For help with debugging. let transientErrorToLog; - // Default read concern level to use for transactions. + // Default read concern level to use for transactions. Snapshot read concern is not supported in + // sharded transactions when majority reads are disabled. const kDefaultTransactionReadConcernLevel = TestData.hasOwnProperty("defaultTransactionReadConcernLevel") ? TestData.defaultTransactionReadConcernLevel - : "snapshot"; + : (TestData.enableMajorityReadConcern !== false ? "snapshot" : "local"); const kDefaultTransactionWriteConcernW = TestData.hasOwnProperty("defaultTransactionWriteConcernW") diff --git a/jstests/noPassthrough/crud_timestamps.js b/jstests/noPassthrough/crud_timestamps.js index 390a85727a2..acefe323cac 100644 --- a/jstests/noPassthrough/crud_timestamps.js +++ b/jstests/noPassthrough/crud_timestamps.js @@ -1,4 +1,4 @@ -// @tags: [requires_replication, uses_transactions] +// @tags: [requires_replication, uses_transactions, uses_atclustertime] // Test the correct timestamping of insert, update, and delete writes along with their accompanying // index updates. diff --git a/jstests/noPassthrough/readConcern_atClusterTime.js b/jstests/noPassthrough/readConcern_atClusterTime.js index b2e5b6ac9f8..ec38d6d776a 100644 --- a/jstests/noPassthrough/readConcern_atClusterTime.js +++ b/jstests/noPassthrough/readConcern_atClusterTime.js @@ -2,7 +2,7 @@ // // Only run this test with the WiredTiger storage engine, since we expect other storage engines to // return early because they do not support snapshot read concern. -// @tags: [requires_wiredtiger, uses_transactions] +// @tags: [requires_wiredtiger, uses_transactions, uses_atclustertime] function _getClusterTime(rst) { const pingRes = assert.commandWorked(rst.getPrimary().adminCommand({ping: 1})); @@ -149,4 +149,22 @@ function _getClusterTime(rst) { rst.stopSet(); } + // readConcern with 'atClusterTime' is not allowed when enableMajorityReadConcern=false. + { + let rst = new ReplSetTest({nodes: [{"enableMajorityReadConcern": "false"}]}); + rst.startSet(); + rst.initiate(); + let session = + rst.getPrimary().getDB(dbName).getMongo().startSession({causalConsistency: false}); + let sessionDb = session.getDatabase(dbName); + session.startTransaction( + {readConcern: {level: "snapshot", atClusterTime: _getClusterTime(rst)}}); + assert.commandFailedWithCode(sessionDb.runCommand({find: collName}), + ErrorCodes.InvalidOptions); + assert.commandFailedWithCode(session.abortTransaction_forTesting(), + ErrorCodes.NoSuchTransaction); + session.endSession(); + rst.stopSet(); + } + }()); diff --git a/jstests/noPassthrough/readConcern_atClusterTime_noop_write.js b/jstests/noPassthrough/readConcern_atClusterTime_noop_write.js index 00899fc0eda..4c6308d38ee 100644 --- a/jstests/noPassthrough/readConcern_atClusterTime_noop_write.js +++ b/jstests/noPassthrough/readConcern_atClusterTime_noop_write.js @@ -1,7 +1,7 @@ // Test that 'atClusterTime' triggers a noop write to advance the lastApplied optime if // necessary. This covers the case where a read is done at a cluster time that is only present // as an actual opTime on another shard. -// @tags: [requires_sharding, uses_transactions] +// @tags: [requires_sharding, uses_transactions, uses_atclustertime] (function() { "use strict"; load("jstests/replsets/rslib.js"); diff --git a/jstests/noPassthrough/readConcern_snapshot_mongos.js b/jstests/noPassthrough/readConcern_snapshot_mongos.js index 539857a8fff..e318cf75932 100644 --- a/jstests/noPassthrough/readConcern_snapshot_mongos.js +++ b/jstests/noPassthrough/readConcern_snapshot_mongos.js @@ -1,5 +1,5 @@ // Test parsing of readConcern level 'snapshot' on mongos. -// @tags: [requires_replication,requires_sharding, uses_transactions] +// @tags: [requires_replication,requires_sharding, uses_transactions, uses_atclustertime] (function() { "use strict"; diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index 2e38b8ba7e8..66eb2e08246 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -1269,6 +1269,11 @@ Status ReplicationCoordinatorImpl::_validateReadConcern(OperationContext* opCtx, << readConcern.toString()}; } + if (readConcern.getArgsAtClusterTime() && !serverGlobalParams.enableMajorityReadConcern) { + return {ErrorCodes::InvalidOptions, + "'atClusterTime' is not supported when enableMajorityReadConcern=false"}; + } + return Status::OK(); } |