summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2013-01-07 14:41:49 -0500
committerGreg Studer <greg@10gen.com>2013-01-07 18:20:42 -0500
commitc5f1c1474b182143690867760253b0c99ab1fc5b (patch)
tree3d7b263679651db5055c458c5b5d1ab76a2aec4c
parentcdc2db7f6b3da66ff7743a06f7852d1343057719 (diff)
downloadmongo-c5f1c1474b182143690867760253b0c99ab1fc5b.tar.gz
SERVER-8097 increment writebackSince on every request but GLE
-rw-r--r--jstests/sharding/wbl_not_cleared.js62
-rw-r--r--src/mongo/db/lasterror.cpp2
-rw-r--r--src/mongo/db/lasterror.h1
3 files changed, 64 insertions, 1 deletions
diff --git a/jstests/sharding/wbl_not_cleared.js b/jstests/sharding/wbl_not_cleared.js
new file mode 100644
index 00000000000..ff2ebf61898
--- /dev/null
+++ b/jstests/sharding/wbl_not_cleared.js
@@ -0,0 +1,62 @@
+/**
+ * Tests whether the WBL gets reset without subsequent events.
+ */
+
+var st = new ShardingTest({ shards : 2, mongos : 2, other : { mongosOptions : { verbose : 5 } } });
+
+st.stopBalancer();
+
+var mongos = st.s0;
+var staleMongos = st.s1;
+var admin = mongos.getDB("admin");
+var config = mongos.getDB("config");
+var shards = config.shards.find().toArray();
+var coll = mongos.getCollection("foo.bar");
+
+jsTest.log("Sharding collection...");
+
+printjson(admin.runCommand({ enableSharding : coll.getDB() + "" }));
+printjson(admin.runCommand({ movePrimary : coll.getDB() + "", to : shards[0]._id }));
+printjson(admin.runCommand({ shardCollection : coll + "", key : { _id : 1 } }));
+printjson(admin.runCommand({ split : coll + "", middle : { _id : 0 } }));
+printjson(admin.runCommand({ moveChunk : coll + "", find : { _id : 0 }, to : shards[1]._id }));
+
+jsTest.log("Collection now sharded...");
+st.printShardingStatus();
+
+jsTest.log("Making mongos stale...");
+
+coll.insert({ _id : 0 });
+
+// Make sure the stale mongos knows about the collection at the original version
+assert.neq(null, staleMongos.getCollection(coll + "").findOne());
+
+printjson(admin.runCommand({ moveChunk : coll + "", find : { _id : 0 }, to : shards[0]._id, _waitForDelete : true }));
+printjson(admin.runCommand({ moveChunk : coll + "", find : { _id : 0 }, to : shards[1]._id, _waitForDelete : true }));
+
+jsTest.log("Running a stale insert...");
+
+staleMongos.getCollection(coll + "").insert({ _id : 0, dup : "key" });
+
+jsTest.log("Getting initial GLE result...");
+
+printjson(staleMongos.getDB(coll.getDB() + "").getLastErrorObj());
+printjson(staleMongos.getDB(coll.getDB() + "").getLastErrorObj());
+st.printShardingStatus();
+
+jsTest.log("Performing insert op on the same shard...");
+
+staleMongos.getCollection(coll + "").insert({ _id : 1, key : "isOk" })
+
+jsTest.log("Getting GLE result...");
+
+printjson(staleMongos.getDB(coll.getDB() + "").getLastErrorObj());
+assert.eq(null, staleMongos.getDB(coll.getDB() + "").getLastError());
+
+jsTest.log("DONE!");
+
+st.stop();
+
+
+
+
diff --git a/src/mongo/db/lasterror.cpp b/src/mongo/db/lasterror.cpp
index a3741cbcb7b..d56e0479f08 100644
--- a/src/mongo/db/lasterror.cpp
+++ b/src/mongo/db/lasterror.cpp
@@ -94,6 +94,7 @@ namespace mongo {
uassert(13649, "no operation yet", le);
le->disabled = true;
le->nPrev--; // caller is a command that shouldn't count as an operation
+ le->writebackSince--; // same as above
return le;
}
@@ -136,6 +137,7 @@ namespace mongo {
else {
err->disabled = false;
err->nPrev++;
+ err->writebackSince++;
}
}
diff --git a/src/mongo/db/lasterror.h b/src/mongo/db/lasterror.h
index 02340471e1b..afcb2a1bb52 100644
--- a/src/mongo/db/lasterror.h
+++ b/src/mongo/db/lasterror.h
@@ -66,7 +66,6 @@ namespace mongo {
updatedExisting = NotUpdate;
nObjects = 0;
nPrev = 1;
- writebackSince++;
valid = _valid;
disabled = false;
upsertedId.clear();