summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Andrei <mihai.andrei@mongodb.com>2019-09-04 21:05:25 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-27 20:25:42 +0000
commitcdb931fdbf3dcb7dbc24067e83ba7fd350033eb9 (patch)
tree400986255c0e9c12d78a190f1236a3070a9cf1ce
parent0df06232295d40295d874fe97fd532f107b4557f (diff)
downloadmongo-cdb931fdbf3dcb7dbc24067e83ba7fd350033eb9.tar.gz
SERVER-35050 Don't abort collection clone due to negative document count
(cherry picked from commit 5ed5b857aaf2e2fbf443588e9b4cbb359fbd1f4d)
-rw-r--r--src/mongo/db/repl/collection_cloner.cpp12
-rw-r--r--src/mongo/db/repl/collection_cloner_test.cpp5
2 files changed, 9 insertions, 8 deletions
diff --git a/src/mongo/db/repl/collection_cloner.cpp b/src/mongo/db/repl/collection_cloner.cpp
index 0cfb0eb46c0..ee3b0c78a9f 100644
--- a/src/mongo/db/repl/collection_cloner.cpp
+++ b/src/mongo/db/repl/collection_cloner.cpp
@@ -352,13 +352,13 @@ void CollectionCloner::_countCallback(
}
}
+ // The count command may return a negative value after an unclean shutdown,
+ // so we set it to zero here to avoid aborting the collection clone.
+ // Note that this count value is only used for reporting purposes.
if (count < 0) {
- _finishCallback({ErrorCodes::BadValue,
- str::stream() << "Count call on collection " << _sourceNss.ns() << " from "
- << _source.toString()
- << " returned negative document count: "
- << count});
- return;
+ warning() << "Count command returned negative value. Updating to 0 to allow progress "
+ "meter to function properly. ";
+ count = 0;
}
{
diff --git a/src/mongo/db/repl/collection_cloner_test.cpp b/src/mongo/db/repl/collection_cloner_test.cpp
index 23a15426583..246e9f44d21 100644
--- a/src/mongo/db/repl/collection_cloner_test.cpp
+++ b/src/mongo/db/repl/collection_cloner_test.cpp
@@ -326,15 +326,16 @@ TEST_F(CollectionClonerTest, CollectionClonerReturnsNoSuchKeyOnMissingDocumentCo
ASSERT_EQUALS(ErrorCodes::NoSuchKey, getStatus());
}
-TEST_F(CollectionClonerTest, CollectionClonerReturnsBadValueOnNegativeDocumentCount) {
+TEST_F(CollectionClonerTest, CollectionClonerDoesNotAbortOnNegativeDocumentCount) {
ASSERT_OK(collectionCloner->startup());
{
executor::NetworkInterfaceMock::InNetworkGuard guard(getNet());
processNetworkResponse(createCountResponse(-1));
}
+ getExecutor().shutdown();
collectionCloner->join();
- ASSERT_EQUALS(ErrorCodes::BadValue, getStatus());
+ ASSERT_EQUALS(0U, collectionCloner->getStats().documentToCopy);
}
class TaskExecutorWithFailureInScheduleRemoteCommand : public unittest::TaskExecutorProxy {