commit 0a8ab6677c341079d55c25f868307eda6c304fa4 Author: Minji Date: Thu Jul 26 12:09:56 2018 -0400 Changed tests for readConcern diff --git a/jstests/noPassthrough/read_majority_out.js b/jstests/noPassthrough/read_majority_out.js index 34a4fe4..ed8d0d7 100644 --- a/jstests/noPassthrough/read_majority_out.js +++ b/jstests/noPassthrough/read_majority_out.js @@ -43,15 +43,31 @@ // These test cases are functions that return a cursor of the documents in collections without // fetching them yet. var cursorTestCases = { - aggregate: function(coll) { + aggregate: function(coll, finishColl) { + + assert.commandWorked(coll.runCommand( + 'aggregate', + {readConcern: {level: 'majority'}, cursor: {}, pipeline: [{$match: {_id: 1}},{$out: finishColl.getName()}]})); + jsTestLog(tojson(coll.findOne({_id: 1}))); + jsTestLog(tojson(finishColl.findOne())); + return makeCursor( + finishColl.getDB(), + assert.commandWorked(finishColl.runCommand( + 'find', + {readConcern: {level: 'local'}}))); + } + /* + aggregate: function(coll) { return makeCursor( coll.getDB(), assert.commandWorked(coll.runCommand( - {aggregate: coll.getName(), /*readConcern: {level: 'majority'}, */cursor: {batchSize: 0}, pipeline: [{$match : { a : 1 }},{$out: "finishColl"}]}))); - }, + 'aggregate', + {readConcern: {level: 'majority'}, cursor: {batchSize: 0}, pipeline: [{$match: {_id: 1}}]}))); + }*/ + }; - function runTests(coll, mongodConnection) { + function runTests(coll, finishColl, mongodConnection) { function makeSnapshot() { return assert.commandWorked(mongodConnection.adminCommand("makeSnapshot")).name; } @@ -62,32 +78,36 @@ for (var testName in cursorTestCases) { jsTestLog('Running ' + testName + ' against ' + coll.toString()); var getCursor = cursorTestCases[testName]; - assert.commandWorked(coll.getDB().adminCommand({setParameter: 1, traceExceptions: true})); + //assert.commandWorked(coll.getDB().adminCommand({setParameter: 1, traceExceptions: true})); // Setup initial state. + assert.writeOK(coll.remove({})); + for (var i = 0; i < 10; i++) + coll.insert({a: i}); + assert.writeOK(coll.save({_id: 1, state: 'before'})); setCommittedSnapshot(makeSnapshot()); - // Check initial conditions. - assert.eq(getCursor(coll).next().state, 'before'); - + // jsTestLog(tojson(getCursor(coll, finishColl).next().state)); + assert.eq(getCursor(coll, finishColl).next().state, 'before'); +/* // Change state without making it committed. - assert.writeOK(coll.save({_id: 1, state: 'after'})); + assert.writeOK(finishColl.save({_id: 1, state: 'after'})); // Cursor still sees old state. - assert.eq(getCursor(coll).next().state, 'before'); + assert.eq(getCursor(coll, finishColl).next().state, 'before'); // Create a cursor before the update is visible. - var oldCursor = getCursor(coll); + var oldCursor = getCursor(coll, finishColl); // Making a snapshot doesn't make the update visible yet. var snapshot = makeSnapshot(); - assert.eq(getCursor(coll).next().state, 'before'); + assert.eq(getCursor(coll, finishColl).next().state, 'before'); // Setting it as committed does for both new and old cursors. setCommittedSnapshot(snapshot); - assert.eq(getCursor(coll).next().state, 'after'); - assert.eq(oldCursor.next().state, 'after'); + assert.eq(getCursor(coll, finishColl).next().state, 'after'); + assert.eq(oldCursor.next().state, 'after');*/ } assert.commandWorked(coll.ensureIndex({point: '2dsphere'})); @@ -100,7 +120,8 @@ nodeOptions: { setParameter: 'testingSnapshotBehaviorInIsolation=true', enableMajorityReadConcern: '', - shardsvr: '' + shardsvr: '', + vvv: "" } }); replTest.startSet(); @@ -109,10 +130,10 @@ null, "replSetInitiate", {doNotWaitForStableCheckpoint: true}); var mongod = replTest.getPrimary(); - + assert.commandWorked(mongod.getDB("admin").runCommand({setParameter: 1, traceExceptions:true})); (function testSingleNode() { var db = mongod.getDB("singleNode"); - runTests(db.collection, mongod); + runTests(db.collection, db.finishColl, mongod); })(); var shardingTest = new ShardingTest({ @@ -123,21 +144,21 @@ (function testUnshardedDBThroughMongos() { var db = shardingTest.getDB("throughMongos"); - runTests(db.unshardedDB, mongod); + runTests(db.unshardedDB, db.finishColl, mongod); })(); shardingTest.adminCommand({enableSharding: 'throughMongos'}); (function testUnshardedCollectionThroughMongos() { var db = shardingTest.getDB("throughMongos"); - runTests(db.unshardedCollection, mongod); + runTests(db.unshardedCollection, db.finishColl, mongod); })(); (function testShardedCollectionThroughMongos() { var db = shardingTest.getDB("throughMongos"); var collection = db.shardedCollection; shardingTest.adminCommand({shardCollection: collection.getFullName(), key: {_id: 1}}); - runTests(collection, mongod); + runTests(collection, db.finishColl, mongod); })(); shardingTest.stop(); diff --git a/src/mongo/db/storage/kv/kv_catalog.cpp b/src/mongo/db/storage/kv/kv_catalog.cpp index 3fcab58..79ae5b0 100644 --- a/src/mongo/db/storage/kv/kv_catalog.cpp +++ b/src/mongo/db/storage/kv/kv_catalog.cpp @@ -534,6 +534,7 @@ Status KVCatalog::renameCollection(OperationContext* opCtx, bool stayTemp) { RecordId loc; BSONObj old = _findEntry(opCtx, fromNS, &loc).getOwned(); + LOG(3) << "minji: " << old; { BSONObjBuilder b;