diff options
author | Kevin Pulo <kevin.pulo@mongodb.com> | 2020-09-17 19:30:00 +1000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-17 13:36:47 +0000 |
commit | b2bc7afd7e063b5baf8a8c05e2589f840f0d9050 (patch) | |
tree | 037cd56056aae161b9bb868551e9330773318ca0 /src | |
parent | 2c446f3f587f406c23cdfca87f227ee5cd466fa8 (diff) | |
download | mongo-b2bc7afd7e063b5baf8a8c05e2589f840f0d9050.tar.gz |
SERVER-50998 Remove getClusterTimeForReplicaSet()
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/catalog/index_build_block.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_catalog_impl.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/commands/drop_indexes.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/commands/snapshot_management.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/repair.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/vector_clock.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/vector_clock.h | 7 |
7 files changed, 11 insertions, 27 deletions
diff --git a/src/mongo/db/catalog/index_build_block.cpp b/src/mongo/db/catalog/index_build_block.cpp index 9fa6361b82b..8226c415c4d 100644 --- a/src/mongo/db/catalog/index_build_block.cpp +++ b/src/mongo/db/catalog/index_build_block.cpp @@ -228,7 +228,8 @@ void IndexBuildBlock::success(OperationContext* opCtx, Collection* collection) { // timestamp. We use the cluster time since it's guaranteed to be greater than the // time of the index build. It is possible the cluster time could be in the future, // and we will need to do another write to reach the minimum visible snapshot. - commitTime = VectorClock::getClusterTimeForReplicaSet(svcCtx).asTimestamp(); + const auto currentTime = VectorClock::get(svcCtx)->getTime(); + commitTime = currentTime.clusterTime().asTimestamp(); } LOGV2(20345, diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index 7855f9afb4d..0a1254805c8 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -1026,7 +1026,8 @@ public: // a commit timestamp. We use the cluster time since it's guaranteed to be greater // than the time of the index removal. It is possible the cluster time could be in the // future, and we will need to do another write to reach the minimum visible snapshot. - commitTime = VectorClock::getClusterTimeForReplicaSet(_opCtx).asTimestamp(); + const auto currentTime = VectorClock::get(_opCtx)->getTime(); + commitTime = currentTime.clusterTime().asTimestamp(); } _entry->setDropped(); _collection->setMinimumVisibleSnapshot(commitTime.get()); diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp index b0d2a25e7e6..a6dde286748 100644 --- a/src/mongo/db/commands/drop_indexes.cpp +++ b/src/mongo/db/commands/drop_indexes.cpp @@ -262,8 +262,9 @@ public: // This was also done when dropAllIndexes() committed, but we need to ensure that no one // tries to read in the intermediate state where all indexes are newer than the current // snapshot so are unable to be used. - auto clusterTime = VectorClock::getClusterTimeForReplicaSet(opCtx).asTimestamp(); - collection.getWritableCollection()->setMinimumVisibleSnapshot(clusterTime); + const auto currentTime = VectorClock::get(opCtx)->getTime(); + collection.getWritableCollection()->setMinimumVisibleSnapshot( + currentTime.clusterTime().asTimestamp()); collection.commitToCatalog(); result.append("nIndexes", static_cast<int>(swIndexesToRebuild.getValue().size())); diff --git a/src/mongo/db/commands/snapshot_management.cpp b/src/mongo/db/commands/snapshot_management.cpp index 43e2a07e01a..fc72c038c14 100644 --- a/src/mongo/db/commands/snapshot_management.cpp +++ b/src/mongo/db/commands/snapshot_management.cpp @@ -77,7 +77,8 @@ public: Lock::GlobalLock lk(opCtx, MODE_IX); - auto name = VectorClock::getClusterTimeForReplicaSet(opCtx).asTimestamp(); + const auto currentTime = VectorClock::get(opCtx)->getTime(); + const auto name = currentTime.clusterTime().asTimestamp(); result.append("name", static_cast<long long>(name.asULL())); return true; diff --git a/src/mongo/db/repair.cpp b/src/mongo/db/repair.cpp index 770b3866dc1..0b3dfca8ebb 100644 --- a/src/mongo/db/repair.cpp +++ b/src/mongo/db/repair.cpp @@ -170,13 +170,13 @@ Status repairDatabase(OperationContext* opCtx, StorageEngine* engine, const std: // Set the minimum snapshot for all Collections in this db. This ensures that readers // using majority readConcern level can only use the collections after their repaired // versions are in the committed view. - auto clusterTime = VectorClock::getClusterTimeForReplicaSet(opCtx).asTimestamp(); + const auto currentTime = VectorClock::get(opCtx)->getTime(); for (auto collIt = db->begin(opCtx); collIt != db->end(opCtx); ++collIt) { auto collection = collIt.getWritableCollection(opCtx, CollectionCatalog::LifetimeMode::kInplace); if (collection) { - collection->setMinimumVisibleSnapshot(clusterTime); + collection->setMinimumVisibleSnapshot(currentTime.clusterTime().asTimestamp()); } } diff --git a/src/mongo/db/vector_clock.cpp b/src/mongo/db/vector_clock.cpp index abbc490d586..ba65d0acaa9 100644 --- a/src/mongo/db/vector_clock.cpp +++ b/src/mongo/db/vector_clock.cpp @@ -33,7 +33,6 @@ #include "mongo/bson/util/bson_extract.h" #include "mongo/db/auth/authorization_session.h" -#include "mongo/db/global_settings.h" #include "mongo/db/logical_clock_gen.h" #include "mongo/db/logical_time_validator.h" #include "mongo/db/vector_clock_document_gen.h" @@ -80,18 +79,6 @@ VectorClock::VectorTime VectorClock::getTime() const { return VectorTime(_vectorTime); } -LogicalTime VectorClock::getClusterTimeForReplicaSet(ServiceContext* svcCtx) { - if (getGlobalReplSettings().usingReplSets()) { - auto now = get(svcCtx)->getTime(); - return now.clusterTime(); - } - return {}; -} - -LogicalTime VectorClock::getClusterTimeForReplicaSet(OperationContext* opCtx) { - return getClusterTimeForReplicaSet(opCtx->getClient()->getServiceContext()); -} - bool VectorClock::_lessThanOrEqualToMaxPossibleTime(LogicalTime time, uint64_t nTicks) { return time.asTimestamp().getSecs() <= kMaxValue && time.asTimestamp().getInc() <= (kMaxValue - nTicks); diff --git a/src/mongo/db/vector_clock.h b/src/mongo/db/vector_clock.h index b33151f3a3e..9cf544a06c0 100644 --- a/src/mongo/db/vector_clock.h +++ b/src/mongo/db/vector_clock.h @@ -136,13 +136,6 @@ public: VectorTime getTime() const; /** - * Returns the current cluster time if this is a replica set node, otherwise returns a null - * logical time. - */ - static LogicalTime getClusterTimeForReplicaSet(ServiceContext* svcCtx); - static LogicalTime getClusterTimeForReplicaSet(OperationContext* opCtx); - - /** * Adds the necessary fields to outMessage to gossip the current time to another node, taking * into account if the gossiping is to an internal or external client (based on the session * tags). Returns true if the ClusterTime was output into outMessage, or false otherwise. |