diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-11-09 04:47:48 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-11-11 02:20:22 -0500 |
commit | efea76aea1b32b56503a1ecb954f8e14b8415eae (patch) | |
tree | fba41ea476b4c423ea09a40d6026d40adf259362 /src/mongo/db/s | |
parent | 77fbada9b93dfa474d41216baa19f556e75bc8ca (diff) | |
download | mongo-efea76aea1b32b56503a1ecb954f8e14b8415eae.tar.gz |
SERVER-31873 Make mongos retry findAndModify with txnNumber
Diffstat (limited to 'src/mongo/db/s')
-rw-r--r-- | src/mongo/db/s/collection_range_deleter.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/s/collection_range_deleter.h | 19 | ||||
-rw-r--r-- | src/mongo/db/s/metadata_manager.cpp | 4 |
3 files changed, 17 insertions, 19 deletions
diff --git a/src/mongo/db/s/collection_range_deleter.cpp b/src/mongo/db/s/collection_range_deleter.cpp index 66ed5783a95..7bf41703968 100644 --- a/src/mongo/db/s/collection_range_deleter.cpp +++ b/src/mongo/db/s/collection_range_deleter.cpp @@ -431,19 +431,16 @@ void CollectionRangeDeleter::_pop(Status result) { // DeleteNotification CollectionRangeDeleter::DeleteNotification::DeleteNotification() - : notification(std::make_shared<Notification<Status>>()) {} + : _notification(std::make_shared<Notification<Status>>()) {} CollectionRangeDeleter::DeleteNotification::DeleteNotification(Status status) - : notification(std::make_shared<Notification<Status>>()) { - notify(status); -} + : _notification(std::make_shared<Notification<Status>>(std::move(status))) {} Status CollectionRangeDeleter::DeleteNotification::waitStatus(OperationContext* opCtx) { try { - return notification->get(opCtx); - } catch (...) { - notification = std::make_shared<Notification<Status>>(); - notify({ErrorCodes::Interrupted, "Wait for range delete request completion interrupted"}); + return _notification->get(opCtx); + } catch (const DBException& ex) { + _notification = std::make_shared<Notification<Status>>(ex.toStatus()); throw; } } diff --git a/src/mongo/db/s/collection_range_deleter.h b/src/mongo/db/s/collection_range_deleter.h index 32bd61e2133..f3b020be971 100644 --- a/src/mongo/db/s/collection_range_deleter.h +++ b/src/mongo/db/s/collection_range_deleter.h @@ -55,7 +55,8 @@ public: * It is an error to destroy a returned CleanupNotification object n unless either n.ready() * is true or n.abandon() has been called. After n.abandon(), n is in a moved-from state. */ - struct DeleteNotification { + class DeleteNotification { + public: DeleteNotification(); DeleteNotification(Status status); @@ -68,12 +69,12 @@ public: DeleteNotification& operator=(DeleteNotification const& notifn) = default; ~DeleteNotification() { - // can be null only if moved from - dassert(!notification || *notification || notification.use_count() == 1); + // Can be null only if moved from + dassert(!_notification || *_notification || _notification.use_count() == 1); } void notify(Status status) const { - notification->set(status); + _notification->set(status); } /** @@ -83,20 +84,20 @@ public: Status waitStatus(OperationContext* opCtx); bool ready() const { - return bool(*notification); + return bool(*_notification); } void abandon() { - notification = nullptr; + _notification = nullptr; } bool operator==(DeleteNotification const& other) const { - return notification == other.notification; + return _notification == other._notification; } bool operator!=(DeleteNotification const& other) const { - return notification != other.notification; + return _notification != other._notification; } private: - std::shared_ptr<Notification<Status>> notification; + std::shared_ptr<Notification<Status>> _notification; }; struct Deletion { diff --git a/src/mongo/db/s/metadata_manager.cpp b/src/mongo/db/s/metadata_manager.cpp index 3ad381e04c4..18c53b50fd1 100644 --- a/src/mongo/db/s/metadata_manager.cpp +++ b/src/mongo/db/s/metadata_manager.cpp @@ -510,8 +510,8 @@ auto MetadataManager::cleanUpRange(ChunkRange const& range, Date_t whenToDelete) // Put it on the oldest metadata permissible; the current one might live a long time. auto& orphans = overlapMetadata->_tracker.orphans; - orphans.emplace_back( - Deletion{ChunkRange(range.getMin().getOwned(), range.getMax().getOwned()), whenToDelete}); + orphans.emplace_back(ChunkRange(range.getMin().getOwned(), range.getMax().getOwned()), + whenToDelete); return orphans.back().notification; } |