From dbf6e7832948aef18a2bde086f6e8de20d65b2f1 Mon Sep 17 00:00:00 2001 From: Tess Avitabile Date: Wed, 13 Feb 2019 13:45:32 -0500 Subject: SERVER-39418 Ban atClusterTime with enableMajorityReadConcern=false --- jstests/noPassthrough/crud_timestamps.js | 2 +- jstests/noPassthrough/readConcern_atClusterTime.js | 20 +++++++++++++++++++- .../readConcern_atClusterTime_noop_write.js | 2 +- jstests/noPassthrough/readConcern_snapshot_mongos.js | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) (limited to 'jstests/noPassthrough') 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"; -- cgit v1.2.1