diff options
author | Nathan Myers <nathan.myers@10gen.com> | 2017-05-25 18:00:24 -0400 |
---|---|---|
committer | Nathan Myers <nathan.myers@10gen.com> | 2017-05-26 11:24:57 -0400 |
commit | 5e964d9b0f1e79f9e3d556ce8962340573790a54 (patch) | |
tree | 57d8caa9e7a3366ffed82fa685fad6409e5464e2 | |
parent | 68b0d672078f4c3041a25cebb9843b00de20f198 (diff) | |
download | mongo-5e964d9b0f1e79f9e3d556ce8962340573790a54.tar.gz |
SERVER-29378 Wait for write concern with current optime
-rw-r--r-- | src/mongo/db/s/collection_range_deleter.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/mongo/db/s/collection_range_deleter.cpp b/src/mongo/db/s/collection_range_deleter.cpp index d967a7f8bbc..df690affe3d 100644 --- a/src/mongo/db/s/collection_range_deleter.cpp +++ b/src/mongo/db/s/collection_range_deleter.cpp @@ -93,8 +93,8 @@ bool CollectionRangeDeleter::cleanUpNextRange(OperationContext* opCtx, { auto scopedCollectionMetadata = css->getMetadata(); if ((!collection || !scopedCollectionMetadata) && !rangeDeleterForTestOnly) { - log() << "Abandoning collection " << nss.ns() - << " range deletions left over from sharded state"; + log() << "Abandoning range deletions in collection " << nss.ns() + << " left over from sharded state"; stdx::lock_guard<stdx::mutex> lk(css->_metadataManager->_managerLock); css->_metadataManager->_clearAllCleanups(); return false; // collection was unsharded @@ -136,15 +136,14 @@ bool CollectionRangeDeleter::cleanUpNextRange(OperationContext* opCtx, } // drop scopedCollectionMetadata } // drop autoColl - dassert(range); - dassert(wrote.getStatus().isOK()); - dassert(wrote.getValue() > 0); + invariant(range); + invariantOK(wrote.getStatus()); + invariant(wrote.getValue() > 0); - log() << "Deleted " << wrote.getValue() << " documents in " << nss.ns() << " range " - << redact(range->toString()); + repl::ReplClientInfo::forClient(opCtx->getClient()).setLastOpToSystemLastOpTime(opCtx); + const auto clientOpTime = repl::ReplClientInfo::forClient(opCtx->getClient()).getLastOp(); // Wait for replication outside the lock - const auto clientOpTime = repl::ReplClientInfo::forClient(opCtx->getClient()).getLastOp(); WriteConcernResult unusedWCResult; Status status = Status::OK(); try { @@ -152,10 +151,9 @@ bool CollectionRangeDeleter::cleanUpNextRange(OperationContext* opCtx, } catch (const DBException& e) { status = e.toStatus(); } - if (!status.isOK()) { - warning() << "Error when waiting for write concern after removing " << nss << " range " - << redact(range->toString()) << " : " << redact(status.reason()); + log() << "Error when waiting for write concern after removing " << nss << " range " + << redact(range->toString()) << " : " << redact(status.reason()); AutoGetCollection autoColl(opCtx, nss, MODE_IX); auto* css = CollectionShardingState::get(opCtx, nss); @@ -165,10 +163,16 @@ bool CollectionRangeDeleter::cleanUpNextRange(OperationContext* opCtx, // its notification would have been triggered, so this check suffices to ensure that it is // safe to pop the range here. if (!notification.ready()) { - dassert(!self->isEmpty() && self->_orphans.front().notification == notification); + invariant(!self->isEmpty() && self->_orphans.front().notification == notification); + log() << "Abandoning deletion of latest range in " << nss.ns() << " after " + << wrote.getValue() << " local deletions because of replication failure"; self->_pop(status); } + } else { + log() << "Deleted " << wrote.getValue() << " documents in " << nss.ns() << " range " + << redact(range->toString()); } + notification.abandon(); return true; } |