diff options
author | Greg Studer <greg@10gen.com> | 2014-03-31 11:10:12 -0400 |
---|---|---|
committer | Greg Studer <greg@10gen.com> | 2014-03-31 13:35:36 -0400 |
commit | 2927031d377002fd483ada3d63c2a58a3fa8b0b7 (patch) | |
tree | 53f5da6281d12cef73f272f442dc03df84071064 | |
parent | a12d09c9757301c3872cf4b45027d287e3dcc366 (diff) | |
download | mongo-2927031d377002fd483ada3d63c2a58a3fa8b0b7.tar.gz |
SERVER-13413 profiling should not do version checks against op namespace
(cherry picked from commit 7ccb298ff2790f4d4b5e844e4124f9051a4ec437)
-rw-r--r-- | jstests/sharding/sharded_profile.js | 39 | ||||
-rw-r--r-- | src/mongo/db/introspect.cpp | 4 |
2 files changed, 42 insertions, 1 deletions
diff --git a/jstests/sharding/sharded_profile.js b/jstests/sharding/sharded_profile.js new file mode 100644 index 00000000000..b1b2c3d3107 --- /dev/null +++ b/jstests/sharding/sharded_profile.js @@ -0,0 +1,39 @@ +// +// Tests whether profiling can trigger stale config errors and interfere with write batches +// SERVER-13413 +// + +var options = { separateConfig : true }; + +var st = new ShardingTest({ shards : 1, mongos : 2, other : options }); +st.stopBalancer(); + +var mongos = st.s0; +var admin = mongos.getDB( "admin" ); +var shards = mongos.getCollection( "config.shards" ).find().toArray(); +var coll = mongos.getCollection( "foo.bar" ); + +assert( admin.runCommand({ enableSharding : coll.getDB() + "" }).ok ); +assert( admin.runCommand({ shardCollection : coll + "", key : { _id : 1 } }).ok ); + +st.printShardingStatus(); + +jsTest.log( "Turning on profiling..." ); + +st.shard0.getDB(coll.getDB().toString()).setProfilingLevel(2); +var profileColl = st.shard0.getDB(coll.getDB().toString()).system.profile; + +var inserts = [{ _id : 0 }, { _id : 1 }, { _id : 2 }]; +var staleColl = st.s1.getCollection(coll.toString()); + +staleColl.insert(inserts); +assert.gleOK(staleColl.getDB().getLastErrorObj()); + +printjson(profileColl.find().toArray()); + +for (var i = 0; i < inserts.length; i++) { + assert.neq(null, profileColl.findOne({ 'query._id' : i })); +} + +jsTest.log( "DONE!" ); +st.stop(); diff --git a/src/mongo/db/introspect.cpp b/src/mongo/db/introspect.cpp index 0ce6075928d..674b43ee8f3 100644 --- a/src/mongo/db/introspect.cpp +++ b/src/mongo/db/introspect.cpp @@ -132,9 +132,11 @@ namespace { BufBuilder profileBufBuilder(1024); try { + // NOTE: It's kind of weird that we lock the op's namespace, but have to for now since + // we're sometimes inside the lock already Lock::DBWrite lk( currentOp.getNS() ); if (dbHolder()._isLoaded(nsToDatabase(currentOp.getNS()), storageGlobalParams.dbpath)) { - Client::Context cx(currentOp.getNS(), storageGlobalParams.dbpath); + Client::Context cx(currentOp.getNS(), storageGlobalParams.dbpath, false); _profile(c, currentOp, profileBufBuilder); } else { |