Skip to content

Commit

Permalink
SERVER-32284 rename ReplicationCoordinator::reserveSnapshotName() to …
Browse files Browse the repository at this point in the history
…getMinimumVisibleSnapshot()
  • Loading branch information
benety committed Jan 18, 2018
1 parent 25b7af8 commit 7713d55
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/mongo/db/catalog/database_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class DatabaseImpl::AddCollectionChange : public RecoveryUnit::Change {

// Ban reading from this collection on committed reads on snapshots before now.
auto replCoord = repl::ReplicationCoordinator::get(_opCtx);
auto snapshotName = replCoord->reserveSnapshotName(_opCtx);
auto snapshotName = replCoord->getMinimumVisibleSnapshot(_opCtx);
it->second->setMinimumVisibleSnapshot(snapshotName);
}

Expand Down
4 changes: 2 additions & 2 deletions src/mongo/db/catalog/index_catalog_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ void IndexCatalogImpl::IndexBuildBlock::success() {
// collection. This means that any snapshot created after this must include the full index,
// and no one can try to read this index before we set the visibility.
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
auto snapshotName = replCoord->reserveSnapshotName(opCtx);
auto snapshotName = replCoord->getMinimumVisibleSnapshot(opCtx);
entry->setMinimumVisibleSnapshot(snapshotName);

// TODO remove this once SERVER-20439 is implemented. It is a stopgap solution for
Expand Down Expand Up @@ -962,7 +962,7 @@ class IndexRemoveChange final : public RecoveryUnit::Change {
void commit() final {
// Ban reading from this collection on committed reads on snapshots before now.
auto replCoord = repl::ReplicationCoordinator::get(_opCtx);
auto snapshotName = replCoord->reserveSnapshotName(_opCtx);
auto snapshotName = replCoord->getMinimumVisibleSnapshot(_opCtx);
_collection->setMinimumVisibleSnapshot(snapshotName);

delete _entry;
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/drop_indexes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class CmdReIndex : public ErrmsgCommandDeprecated {
// tries to read in the intermediate state where all indexes are newer than the current
// snapshot so are unable to be used.
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
auto snapshotName = replCoord->reserveSnapshotName(opCtx);
auto snapshotName = replCoord->getMinimumVisibleSnapshot(opCtx);
collection->setMinimumVisibleSnapshot(snapshotName);

result.append("nIndexes", static_cast<int>(indexInfoObjs.getValue().size()));
Expand Down
3 changes: 2 additions & 1 deletion src/mongo/db/commands/snapshot_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class CmdMakeSnapshot final : public BasicCommand {

auto status = snapshotManager->prepareForCreateSnapshot(opCtx);
if (status.isOK()) {
const auto name = repl::ReplicationCoordinator::get(opCtx)->reserveSnapshotName(opCtx);
const auto name =
repl::ReplicationCoordinator::get(opCtx)->getMinimumVisibleSnapshot(opCtx);
result.append("name", static_cast<long long>(name.asULL()));
}
return CommandHelpers::appendCommandStatus(result, status);
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/repair_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Status repairDatabase(OperationContext* opCtx,
// using majority readConcern level can only use the collections after their repaired
// versions are in the committed view.
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
auto snapshotName = replCoord->reserveSnapshotName(opCtx);
auto snapshotName = replCoord->getMinimumVisibleSnapshot(opCtx);

for (auto&& collection : *db) {
collection->setMinimumVisibleSnapshot(snapshotName);
Expand Down
4 changes: 2 additions & 2 deletions src/mongo/db/repl/replication_coordinator.h
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ class ReplicationCoordinator : public SyncSourceSelector {
virtual Status updateTerm(OperationContext* opCtx, long long term) = 0;

/**
* Reserves a unique SnapshotName.
* Returns the minimum visible snapshot for this operation.
*
* This name is guaranteed to compare > all names reserved before and < all names reserved
* after.
Expand All @@ -809,7 +809,7 @@ class ReplicationCoordinator : public SyncSourceSelector {
* A null OperationContext can be used in cases where the snapshot to wait for should not be
* adjusted.
*/
virtual Timestamp reserveSnapshotName(OperationContext* opCtx) = 0;
virtual Timestamp getMinimumVisibleSnapshot(OperationContext* opCtx) = 0;

/**
* Blocks until either the current committed snapshot is at least as high as 'untilSnapshot',
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/repl/replication_coordinator_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3342,7 +3342,7 @@ EventHandle ReplicationCoordinatorImpl::_updateTerm_inlock(
return EventHandle();
}

Timestamp ReplicationCoordinatorImpl::reserveSnapshotName(OperationContext* opCtx) {
Timestamp ReplicationCoordinatorImpl::getMinimumVisibleSnapshot(OperationContext* opCtx) {
Timestamp reservedName;
if (getReplicationMode() == Mode::modeReplSet) {
invariant(opCtx->lockState()->isLocked());
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/repl/replication_coordinator_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class ReplicationCoordinatorImpl : public ReplicationCoordinator {

virtual Status updateTerm(OperationContext* opCtx, long long term) override;

virtual Timestamp reserveSnapshotName(OperationContext* opCtx) override;
virtual Timestamp getMinimumVisibleSnapshot(OperationContext* opCtx) override;

virtual OpTime getCurrentCommittedSnapshotOpTime() const override;

Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/repl/replication_coordinator_mock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ Status ReplicationCoordinatorMock::updateTerm(OperationContext* opCtx, long long
return Status::OK();
}

Timestamp ReplicationCoordinatorMock::reserveSnapshotName(OperationContext* opCtx) {
Timestamp ReplicationCoordinatorMock::getMinimumVisibleSnapshot(OperationContext* opCtx) {
return Timestamp(_snapshotNameGenerator.addAndFetch(1));
}

Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/repl/replication_coordinator_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class ReplicationCoordinatorMock : public ReplicationCoordinator {

virtual Status updateTerm(OperationContext* opCtx, long long term);

virtual Timestamp reserveSnapshotName(OperationContext* opCtx);
virtual Timestamp getMinimumVisibleSnapshot(OperationContext* opCtx) override;

virtual void dropAllSnapshots() override;

Expand Down

0 comments on commit 7713d55

Please sign in to comment.