summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2016-11-01 20:20:44 -0400
committerSiyuan Zhou <siyuan.zhou@mongodb.com>2016-11-08 18:08:25 -0500
commitcb83a4e076c09bacc8c9eef1236b8d12efc10b82 (patch)
treea3b50d6077c9828b68bb2a4cfb3d0111f0a36872
parent3220495083b0d678578a76591f54ee1d7a5ec5df (diff)
downloadmongo-cb83a4e076c09bacc8c9eef1236b8d12efc10b82.tar.gz
SERVER-26118 Ignore IndexNotFound error when applying ttl-time change.
-rw-r--r--src/mongo/db/repl/oplog.cpp10
-rw-r--r--src/mongo/db/repl/sync_tail_test.cpp41
2 files changed, 47 insertions, 4 deletions
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index ff45edb0fc1..a9c29c2791d 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -593,10 +593,12 @@ std::map<std::string, ApplyOpMetadata> opsMap = {
return createCollection(txn, nss.db().toString(), cmd, idIndexSpecBuilder.done());
},
{ErrorCodes::NamespaceExists}}},
- {"collMod", {[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
- BSONObjBuilder resultWeDontCareAbout;
- return collMod(txn, parseNs(ns, cmd), cmd, &resultWeDontCareAbout);
- }}},
+ {"collMod",
+ {[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
+ BSONObjBuilder resultWeDontCareAbout;
+ return collMod(txn, parseNs(ns, cmd), cmd, &resultWeDontCareAbout);
+ },
+ {ErrorCodes::IndexNotFound, ErrorCodes::NamespaceNotFound}}},
{"dropDatabase",
{[](OperationContext* txn, const char* ns, BSONObj& cmd) -> Status {
return dropDatabase(txn, NamespaceString(ns).db().toString());
diff --git a/src/mongo/db/repl/sync_tail_test.cpp b/src/mongo/db/repl/sync_tail_test.cpp
index 6c4c0aa8d52..786485a0279 100644
--- a/src/mongo/db/repl/sync_tail_test.cpp
+++ b/src/mongo/db/repl/sync_tail_test.cpp
@@ -997,6 +997,9 @@ OplogEntry IdempotencyTest::dropIndex(const std::string& indexName) {
std::string IdempotencyTest::validate() {
auto collection = AutoGetCollectionForRead(_txn.get(), nss).getCollection();
+ if (!collection) {
+ return "CollectionNotFound";
+ }
ValidateResults validateResults;
BSONObjBuilder bob;
@@ -1179,6 +1182,44 @@ TEST_F(IdempotencyTest, IndexWithDifferentOptions) {
ASSERT_EQ(status.code(), ErrorCodes::IndexOptionsConflict);
}
+TEST_F(IdempotencyTest, CollModNamespaceNotFound) {
+ getGlobalReplicationCoordinator()->setFollowerMode(MemberState::RS_RECOVERING);
+
+ ASSERT_OK(runOp(createCollection()));
+ ASSERT_OK(runOp(buildIndex(BSON("createdAt" << 1), BSON("expireAfterSeconds" << 3600))));
+
+ auto indexChange = fromjson("{keyPattern: {createdAt:1}, expireAfterSeconds:4000}}");
+ auto collModCmd = BSON("collMod" << nss.coll() << "index" << indexChange);
+ auto collModOp = makeCommandOplogEntry(nextOpTime(), nss, collModCmd);
+ auto dropCollOp = makeCommandOplogEntry(nextOpTime(), nss, BSON("drop" << nss.coll()));
+
+ auto ops = {collModOp, dropCollOp};
+
+ ASSERT_OK(runOps(ops));
+ auto hash = validate();
+ ASSERT_OK(runOps(ops));
+ ASSERT_EQUALS(hash, validate());
+}
+
+TEST_F(IdempotencyTest, CollModIndexNotFound) {
+ getGlobalReplicationCoordinator()->setFollowerMode(MemberState::RS_RECOVERING);
+
+ ASSERT_OK(runOp(createCollection()));
+ ASSERT_OK(runOp(buildIndex(BSON("createdAt" << 1), BSON("expireAfterSeconds" << 3600))));
+
+ auto indexChange = fromjson("{keyPattern: {createdAt:1}, expireAfterSeconds:4000}}");
+ auto collModCmd = BSON("collMod" << nss.coll() << "index" << indexChange);
+ auto collModOp = makeCommandOplogEntry(nextOpTime(), nss, collModCmd);
+ auto dropIndexOp = dropIndex("createdAt_index");
+
+ auto ops = {collModOp, dropIndexOp};
+
+ ASSERT_OK(runOps(ops));
+ auto hash = validate();
+ ASSERT_OK(runOps(ops));
+ ASSERT_EQUALS(hash, validate());
+}
+
TEST_F(IdempotencyTest, ResyncOnRenameCollection) {
ReplicationCoordinator::get(_txn.get())->setFollowerMode(MemberState::RS_RECOVERING);