summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Schultz <william.schultz@mongodb.com>2020-07-16 09:27:45 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-16 15:32:03 +0000
commitef0696ac5756af6817ea22904fad1e78f31e73fe (patch)
tree5b49c3dd167f6a43570323d2d8fa3f15153a4102
parent21b083c7352704fc8c3d8a4f33c54040259ff766 (diff)
downloadmongo-ef0696ac5756af6817ea22904fad1e78f31e73fe.tar.gz
SERVER-47845 Remove usage of ReplicationCoordinator::DataConsistency type
-rw-r--r--src/mongo/db/repl/initial_syncer.cpp5
-rw-r--r--src/mongo/db/repl/initial_syncer.h3
-rw-r--r--src/mongo/db/repl/initial_syncer_test.cpp18
-rw-r--r--src/mongo/db/repl/oplog.cpp3
-rw-r--r--src/mongo/db/repl/oplog_applier_impl.cpp30
-rw-r--r--src/mongo/db/repl/replication_coordinator.h21
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp65
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.h8
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp17
-rw-r--r--src/mongo/db/repl/replication_coordinator_mock.cpp5
-rw-r--r--src/mongo/db/repl/replication_coordinator_mock.h4
-rw-r--r--src/mongo/db/repl/replication_coordinator_noop.cpp6
-rw-r--r--src/mongo/db/repl/replication_coordinator_noop.h5
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.h6
-rw-r--r--src/mongo/db/repl/rollback_impl.cpp3
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp3
-rw-r--r--src/mongo/embedded/replication_coordinator_embedded.cpp4
-rw-r--r--src/mongo/embedded/replication_coordinator_embedded.h6
18 files changed, 74 insertions, 138 deletions
diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp
index 575bc0feacb..7e7013e4aaf 100644
--- a/src/mongo/db/repl/initial_syncer.cpp
+++ b/src/mongo/db/repl/initial_syncer.cpp
@@ -560,8 +560,7 @@ void InitialSyncer::_tearDown_inlock(OperationContext* opCtx,
_storage->setInitialDataTimestamp(opCtx->getServiceContext(), initialDataTimestamp);
auto currentLastAppliedOpTime = _opts.getMyLastOptime();
if (currentLastAppliedOpTime.isNull()) {
- _opts.setMyLastOptime(lastApplied.getValue(),
- ReplicationCoordinator::DataConsistency::Consistent);
+ _opts.setMyLastOptime(lastApplied.getValue());
} else {
invariant(currentLastAppliedOpTime == lastAppliedOpTime);
}
@@ -1568,7 +1567,7 @@ void InitialSyncer::_multiApplierCallback(const Status& multiApplierStatus,
_initialSyncState->appliedOps += numApplied;
_lastApplied = lastApplied;
const auto lastAppliedOpTime = _lastApplied.opTime;
- _opts.setMyLastOptime(_lastApplied, ReplicationCoordinator::DataConsistency::Inconsistent);
+ _opts.setMyLastOptime(_lastApplied);
// Update oplog visibility after applying a batch so that while applying transaction oplog
// entries, the TransactionHistoryIterator can get earlier oplog entries associated with the
diff --git a/src/mongo/db/repl/initial_syncer.h b/src/mongo/db/repl/initial_syncer.h
index e00fa17f032..71063112642 100644
--- a/src/mongo/db/repl/initial_syncer.h
+++ b/src/mongo/db/repl/initial_syncer.h
@@ -81,8 +81,7 @@ struct InitialSyncerOptions {
using GetMyLastOptimeFn = std::function<OpTime()>;
/** Function to update optime of last operation applied on this node */
- using SetMyLastOptimeFn = std::function<void(
- const OpTimeAndWallTime&, ReplicationCoordinator::DataConsistency consistency)>;
+ using SetMyLastOptimeFn = std::function<void(const OpTimeAndWallTime&)>;
/** Function to reset all optimes on this node (e.g. applied & durable). */
using ResetOptimesFn = std::function<void()>;
diff --git a/src/mongo/db/repl/initial_syncer_test.cpp b/src/mongo/db/repl/initial_syncer_test.cpp
index b4ddd113e96..cfc1bff821b 100644
--- a/src/mongo/db/repl/initial_syncer_test.cpp
+++ b/src/mongo/db/repl/initial_syncer_test.cpp
@@ -140,8 +140,7 @@ public:
* clear/reset state
*/
void reset() {
- _setMyLastOptime = [this](const OpTimeAndWallTime& opTimeAndWallTime,
- ReplicationCoordinator::DataConsistency consistency) {
+ _setMyLastOptime = [this](const OpTimeAndWallTime& opTimeAndWallTime) {
_myLastOpTime = opTimeAndWallTime.opTime;
_myLastWallTime = opTimeAndWallTime.wallTime;
};
@@ -382,9 +381,8 @@ protected:
InitialSyncerOptions options;
options.initialSyncRetryWait = Milliseconds(1);
options.getMyLastOptime = [this]() { return _myLastOpTime; };
- options.setMyLastOptime = [this](const OpTimeAndWallTime& opTimeAndWallTime,
- ReplicationCoordinator::DataConsistency consistency) {
- _setMyLastOptime(opTimeAndWallTime, consistency);
+ options.setMyLastOptime = [this](const OpTimeAndWallTime& opTimeAndWallTime) {
+ _setMyLastOptime(opTimeAndWallTime);
};
options.resetOptimes = [this]() { _myLastOpTime = OpTime(); };
options.syncSourceSelector = this;
@@ -695,8 +693,7 @@ void InitialSyncerTest::processSuccessfulFCVFetcherResponse(std::vector<BSONObj>
TEST_F(InitialSyncerTest, InvalidConstruction) {
InitialSyncerOptions options;
options.getMyLastOptime = []() { return OpTime(); };
- options.setMyLastOptime = [](const OpTimeAndWallTime&,
- ReplicationCoordinator::DataConsistency consistency) {};
+ options.setMyLastOptime = [](const OpTimeAndWallTime&) {};
options.resetOptimes = []() {};
options.syncSourceSelector = this;
auto callback = [](const StatusWith<OpTimeAndWallTime>&) {};
@@ -931,11 +928,10 @@ TEST_F(InitialSyncerTest, InitialSyncerResetsOptimesOnNewAttempt) {
_syncSourceSelector->setChooseNewSyncSourceResult_forTest(HostAndPort());
- // Set the last optime to an arbitrary nonzero value. The value of the 'consistency' argument
- // doesn't matter. Also set last wall time to an arbitrary non-minimum value.
+ // Set the last optime to an arbitrary nonzero value. Also set last wall time to an arbitrary
+ // non-minimum value.
auto origOptime = OpTime(Timestamp(1000, 1), 1);
- _setMyLastOptime({origOptime, Date_t::max()},
- ReplicationCoordinator::DataConsistency::Inconsistent);
+ _setMyLastOptime({origOptime, Date_t::max()});
// Start initial sync.
const std::uint32_t initialSyncMaxAttempts = 1U;
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index f534ad78877..0b25875c71c 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -252,8 +252,7 @@ void _logOpsInner(OperationContext* opCtx,
}
// Optimes on the primary should always represent consistent database states.
- replCoord->setMyLastAppliedOpTimeAndWallTimeForward(
- {finalOpTime, wallTime}, ReplicationCoordinator::DataConsistency::Consistent);
+ replCoord->setMyLastAppliedOpTimeAndWallTimeForward({finalOpTime, wallTime});
// We set the last op on the client to 'finalOpTime', because that contains the
// timestamp of the operation that the client actually performed.
diff --git a/src/mongo/db/repl/oplog_applier_impl.cpp b/src/mongo/db/repl/oplog_applier_impl.cpp
index d0c2aa9cf56..bde193887be 100644
--- a/src/mongo/db/repl/oplog_applier_impl.cpp
+++ b/src/mongo/db/repl/oplog_applier_impl.cpp
@@ -303,17 +303,15 @@ public:
ApplyBatchFinalizer(ReplicationCoordinator* replCoord) : _replCoord(replCoord) {}
virtual ~ApplyBatchFinalizer(){};
- virtual void record(const OpTimeAndWallTime& newOpTimeAndWallTime,
- ReplicationCoordinator::DataConsistency consistency) {
- _recordApplied(newOpTimeAndWallTime, consistency);
+ virtual void record(const OpTimeAndWallTime& newOpTimeAndWallTime) {
+ _recordApplied(newOpTimeAndWallTime);
};
protected:
- void _recordApplied(const OpTimeAndWallTime& newOpTimeAndWallTime,
- ReplicationCoordinator::DataConsistency consistency) {
+ void _recordApplied(const OpTimeAndWallTime& newOpTimeAndWallTime) {
// We have to use setMyLastAppliedOpTimeAndWallTimeForward since this thread races with
// ReplicationExternalStateImpl::onTransitionToPrimary.
- _replCoord->setMyLastAppliedOpTimeAndWallTimeForward(newOpTimeAndWallTime, consistency);
+ _replCoord->setMyLastAppliedOpTimeAndWallTimeForward(newOpTimeAndWallTime);
}
void _recordDurable(const OpTimeAndWallTime& newOpTimeAndWallTime) {
@@ -334,8 +332,7 @@ public:
_waiterThread{&ApplyBatchFinalizerForJournal::_run, this} {};
~ApplyBatchFinalizerForJournal();
- void record(const OpTimeAndWallTime& newOpTimeAndWallTime,
- ReplicationCoordinator::DataConsistency consistency) override;
+ void record(const OpTimeAndWallTime& newOpTimeAndWallTime) override;
private:
/**
@@ -366,9 +363,8 @@ ApplyBatchFinalizerForJournal::~ApplyBatchFinalizerForJournal() {
_waiterThread.join();
}
-void ApplyBatchFinalizerForJournal::record(const OpTimeAndWallTime& newOpTimeAndWallTime,
- ReplicationCoordinator::DataConsistency consistency) {
- _recordApplied(newOpTimeAndWallTime, consistency);
+void ApplyBatchFinalizerForJournal::record(const OpTimeAndWallTime& newOpTimeAndWallTime) {
+ _recordApplied(newOpTimeAndWallTime);
stdx::unique_lock<Latch> lock(_mutex);
_latestOpTimeAndWallTime = newOpTimeAndWallTime;
@@ -531,16 +527,8 @@ void OplogApplierImpl::_run(OplogBuffer* oplogBuffer) {
_storageInterface->oplogDiskLocRegister(
&opCtx, lastOpTimeInBatch.getTimestamp(), orderedCommit);
- // 4. Finalize this batch. We are at a consistent optime if our current optime is >= the
- // current 'minValid' optime. Note that recording the lastOpTime in the finalizer includes
- // advancing the global timestamp to at least its timestamp.
- const auto minValid = _consistencyMarkers->getMinValid(&opCtx);
- auto consistency = (lastOpTimeInBatch >= minValid)
- ? ReplicationCoordinator::DataConsistency::Consistent
- : ReplicationCoordinator::DataConsistency::Inconsistent;
-
- // The finalizer advances the global timestamp to lastOpTimeInBatch.
- finalizer->record({lastOpTimeInBatch, lastWallTimeInBatch}, consistency);
+ // 4. Finalize this batch. The finalizer advances the global timestamp to lastOpTimeInBatch.
+ finalizer->record({lastOpTimeInBatch, lastWallTimeInBatch});
}
}
diff --git a/src/mongo/db/repl/replication_coordinator.h b/src/mongo/db/repl/replication_coordinator.h
index f997fb16771..e7281778a7f 100644
--- a/src/mongo/db/repl/replication_coordinator.h
+++ b/src/mongo/db/repl/replication_coordinator.h
@@ -364,20 +364,9 @@ public:
virtual void setMyLastDurableOpTimeAndWallTime(const OpTimeAndWallTime& opTimeAndWallTime) = 0;
/**
- * This type is used to represent the "consistency" of a current database state. In
- * replication, there may be times when our database data is not represented by a single optime,
- * because we have fetched remote data from different points in time. For example, when we are
- * in RECOVERING following a refetch based rollback. We never allow external clients to read
- * from the database if it is not consistent.
- */
- enum class DataConsistency { Consistent, Inconsistent };
-
- /**
* Updates our internal tracking of the last OpTime applied to this node, but only
* if the supplied optime is later than the current last OpTime known to the replication
- * coordinator. The 'consistency' argument must tell whether or not the optime argument
- * represents a consistent database state. Also updates the wall clock time corresponding to
- * that operation.
+ * coordinator.
*
* This function is used by logOp() on a primary, since the ops in the oplog do not
* necessarily commit in sequential order. It is also used when we finish oplog batch
@@ -385,7 +374,7 @@ public:
* applied optime from more than one thread.
*/
virtual void setMyLastAppliedOpTimeAndWallTimeForward(
- const OpTimeAndWallTime& opTimeAndWallTime, DataConsistency consistency) = 0;
+ const OpTimeAndWallTime& opTimeAndWallTime) = 0;
/**
* Updates our internal tracking of the last OpTime durable to this node, but only
@@ -789,11 +778,9 @@ public:
/**
* Loads the optime from the last op in the oplog into the coordinator's lastAppliedOpTime and
- * lastDurableOpTime values. The 'consistency' argument must tell whether or not the optime of
- * the op in the oplog represents a consistent database state.
+ * lastDurableOpTime values.
*/
- virtual void resetLastOpTimesFromOplog(OperationContext* opCtx,
- DataConsistency consistency) = 0;
+ virtual void resetLastOpTimesFromOplog(OperationContext* opCtx) = 0;
/**
* Returns the OpTime of the latest replica set-committed op known to this server.
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 20480170b71..d44e28f117a 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -269,10 +269,9 @@ InitialSyncerOptions createInitialSyncerOptions(
InitialSyncerOptions options;
options.getMyLastOptime = [replCoord]() { return replCoord->getMyLastAppliedOpTime(); };
options.setMyLastOptime = [replCoord,
- externalState](const OpTimeAndWallTime& opTimeAndWallTime,
- ReplicationCoordinator::DataConsistency consistency) {
+ externalState](const OpTimeAndWallTime& opTimeAndWallTime) {
// Note that setting the last applied opTime forward also advances the global timestamp.
- replCoord->setMyLastAppliedOpTimeAndWallTimeForward(opTimeAndWallTime, consistency);
+ replCoord->setMyLastAppliedOpTimeAndWallTimeForward(opTimeAndWallTime);
// The oplog application phase of initial sync starts timestamping writes, causing
// WiredTiger to pin this data in memory. Advancing the oldest timestamp in step with the
// last applied optime here will permit WiredTiger to evict this data as it sees fit.
@@ -649,7 +648,6 @@ void ReplicationCoordinatorImpl::_finishLoadLocalConfig(
}
auto opCtx = cc().makeOperationContext();
- auto consistency = DataConsistency::Inconsistent;
if (!lastOpTime.isNull()) {
// If we have an oplog, it is still possible that our data is not in a consistent state. For
@@ -657,8 +655,6 @@ void ReplicationCoordinatorImpl::_finishLoadLocalConfig(
// To detect this, we see if our last optime is >= the 'minValid' optime, which
// should be persistent across node crashes.
OpTime minValid = _replicationProcess->getConsistencyMarkers()->getMinValid(opCtx.get());
- consistency =
- (lastOpTime >= minValid) ? DataConsistency::Consistent : DataConsistency::Inconsistent;
// It is not safe to take stable checkpoints until we reach minValid, so we set our
// initialDataTimestamp to prevent this. It is expected that this is only necessary when
@@ -686,8 +682,7 @@ void ReplicationCoordinatorImpl::_finishLoadLocalConfig(
// Set our last applied and durable optimes to the top of the oplog, if we have one.
if (!lastOpTime.isNull()) {
bool isRollbackAllowed = false;
- _setMyLastAppliedOpTimeAndWallTime(
- lock, lastOpTimeAndWallTime, isRollbackAllowed, consistency);
+ _setMyLastAppliedOpTimeAndWallTime(lock, lastOpTimeAndWallTime, isRollbackAllowed);
_setMyLastDurableOpTimeAndWallTime(lock, lastOpTimeAndWallTime, isRollbackAllowed);
_reportUpstream_inlock(std::move(lock)); // unlocks _mutex.
} else {
@@ -786,8 +781,7 @@ void ReplicationCoordinatorImpl::_startDataReplication(OperationContext* opCtx,
}
const auto lastApplied = opTimeStatus.getValue();
- _setMyLastAppliedOpTimeAndWallTime(
- lock, lastApplied, false, DataConsistency::Consistent);
+ _setMyLastAppliedOpTimeAndWallTime(lock, lastApplied, false);
}
// Clear maint. mode.
@@ -1281,7 +1275,7 @@ void ReplicationCoordinatorImpl::setMyHeartbeatMessage(const std::string& msg) {
}
void ReplicationCoordinatorImpl::setMyLastAppliedOpTimeAndWallTimeForward(
- const OpTimeAndWallTime& opTimeAndWallTime, DataConsistency consistency) {
+ const OpTimeAndWallTime& opTimeAndWallTime) {
// Update the global timestamp before setting the last applied opTime forward so the last
// applied optime is never greater than the latest cluster time in the logical clock.
const auto opTime = opTimeAndWallTime.opTime;
@@ -1290,7 +1284,7 @@ void ReplicationCoordinatorImpl::setMyLastAppliedOpTimeAndWallTimeForward(
stdx::unique_lock<Latch> lock(_mutex);
auto myLastAppliedOpTime = _getMyLastAppliedOpTime_inlock();
if (opTime > myLastAppliedOpTime) {
- _setMyLastAppliedOpTimeAndWallTime(lock, opTimeAndWallTime, false, consistency);
+ _setMyLastAppliedOpTimeAndWallTime(lock, opTimeAndWallTime, false);
_reportUpstream_inlock(std::move(lock));
} else {
if (opTime != myLastAppliedOpTime) {
@@ -1302,8 +1296,7 @@ void ReplicationCoordinatorImpl::setMyLastAppliedOpTimeAndWallTimeForward(
opTime.getTimestamp() < myLastAppliedOpTime.getTimestamp());
}
- if (consistency == DataConsistency::Consistent &&
- _readWriteAbility->canAcceptNonLocalWrites(lock) && _rsConfig.getWriteMajority() == 1) {
+ if (_readWriteAbility->canAcceptNonLocalWrites(lock) && _rsConfig.getWriteMajority() == 1) {
// Single vote primaries may have a lagged stable timestamp due to paring back the
// stable timestamp to the all committed timestamp.
_setStableTimestampForStorage(lock);
@@ -1334,7 +1327,7 @@ void ReplicationCoordinatorImpl::setMyLastAppliedOpTimeAndWallTime(
stdx::unique_lock<Latch> lock(_mutex);
// The optime passed to this function is required to represent a consistent database state.
- _setMyLastAppliedOpTimeAndWallTime(lock, opTimeAndWallTime, false, DataConsistency::Consistent);
+ _setMyLastAppliedOpTimeAndWallTime(lock, opTimeAndWallTime, false);
_reportUpstream_inlock(std::move(lock));
}
@@ -1355,8 +1348,7 @@ void ReplicationCoordinatorImpl::_resetMyLastOpTimes(WithLock lk) {
LOGV2_DEBUG(21332, 1, "Resetting durable/applied optimes");
// Reset to uninitialized OpTime
bool isRollbackAllowed = true;
- _setMyLastAppliedOpTimeAndWallTime(
- lk, OpTimeAndWallTime(), isRollbackAllowed, DataConsistency::Inconsistent);
+ _setMyLastAppliedOpTimeAndWallTime(lk, OpTimeAndWallTime(), isRollbackAllowed);
_setMyLastDurableOpTimeAndWallTime(lk, OpTimeAndWallTime(), isRollbackAllowed);
}
@@ -1377,10 +1369,7 @@ void ReplicationCoordinatorImpl::_reportUpstream_inlock(stdx::unique_lock<Latch>
}
void ReplicationCoordinatorImpl::_setMyLastAppliedOpTimeAndWallTime(
- WithLock lk,
- const OpTimeAndWallTime& opTimeAndWallTime,
- bool isRollbackAllowed,
- DataConsistency consistency) {
+ WithLock lk, const OpTimeAndWallTime& opTimeAndWallTime, bool isRollbackAllowed) {
const auto opTime = opTimeAndWallTime.opTime;
// The last applied opTime should never advance beyond the global timestamp (i.e. the latest
@@ -1419,22 +1408,16 @@ void ReplicationCoordinatorImpl::_setMyLastAppliedOpTimeAndWallTime(
return;
}
- // Add the new applied optime to the list of stable optime candidates and then set the last
- // stable optime. Stable optimes are used to determine the last optime that it is safe to revert
- // the database to, in the event of a rollback via the 'recover to timestamp' method. If we are
- // setting our applied optime to a value that doesn't represent a consistent database state, we
- // should not add it to the set of stable optime candidates. For example, if we are in
- // RECOVERING after a rollback using the 'rollbackViaRefetch' algorithm, we will be inconsistent
- // until we reach the 'minValid' optime.
- if (consistency == DataConsistency::Consistent) {
- invariant(opTime.getTimestamp().getInc() > 0,
- str::stream() << "Impossible optime received: " << opTime.toString());
- // If we are lagged behind the commit optime, set a new stable timestamp here. When majority
- // read concern is disabled, the stable timestamp is set to lastApplied.
- if (opTime <= _topCoord->getLastCommittedOpTime() ||
- !serverGlobalParams.enableMajorityReadConcern) {
- _setStableTimestampForStorage(lk);
- }
+ // Advance the stable timestamp if necessary. Stable timestamps are used to determine the latest
+ // timestamp that it is safe to revert the database to, in the event of a rollback via the
+ // 'recover to timestamp' method.
+ invariant(opTime.getTimestamp().getInc() > 0,
+ str::stream() << "Impossible optime received: " << opTime.toString());
+ // If we are lagged behind the commit optime, set a new stable timestamp here. When majority
+ // read concern is disabled, the stable timestamp is set to lastApplied.
+ if (opTime <= _topCoord->getLastCommittedOpTime() ||
+ !serverGlobalParams.enableMajorityReadConcern) {
+ _setStableTimestampForStorage(lk);
}
}
@@ -4775,8 +4758,7 @@ void ReplicationCoordinatorImpl::blacklistSyncSource(const HostAndPort& host, Da
});
}
-void ReplicationCoordinatorImpl::resetLastOpTimesFromOplog(OperationContext* opCtx,
- DataConsistency consistency) {
+void ReplicationCoordinatorImpl::resetLastOpTimesFromOplog(OperationContext* opCtx) {
auto lastOpTimeAndWallTimeStatus = _externalState->loadLastOpTimeAndWallTime(opCtx);
OpTimeAndWallTime lastOpTimeAndWallTime = {OpTime(), Date_t()};
if (!lastOpTimeAndWallTimeStatus.getStatus().isOK()) {
@@ -4797,7 +4779,7 @@ void ReplicationCoordinatorImpl::resetLastOpTimesFromOplog(OperationContext* opC
stdx::unique_lock<Latch> lock(_mutex);
bool isRollbackAllowed = true;
- _setMyLastAppliedOpTimeAndWallTime(lock, lastOpTimeAndWallTime, isRollbackAllowed, consistency);
+ _setMyLastAppliedOpTimeAndWallTime(lock, lastOpTimeAndWallTime, isRollbackAllowed);
_setMyLastDurableOpTimeAndWallTime(lock, lastOpTimeAndWallTime, isRollbackAllowed);
_reportUpstream_inlock(std::move(lock));
}
@@ -5067,8 +5049,7 @@ void ReplicationCoordinatorImpl::_advanceCommitPoint(
if (_getMemberState_inlock().arbiter()) {
// Arbiters do not store replicated data, so we consider their data trivially
// consistent.
- _setMyLastAppliedOpTimeAndWallTime(
- lk, committedOpTimeAndWallTime, false, DataConsistency::Consistent);
+ _setMyLastAppliedOpTimeAndWallTime(lk, committedOpTimeAndWallTime, false);
}
_setStableTimestampForStorage(lk);
diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h
index 1a7d685c4a8..25cf94768bc 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.h
+++ b/src/mongo/db/repl/replication_coordinator_impl.h
@@ -174,7 +174,7 @@ public:
virtual void setMyLastDurableOpTimeAndWallTime(const OpTimeAndWallTime& opTimeAndWallTime);
virtual void setMyLastAppliedOpTimeAndWallTimeForward(
- const OpTimeAndWallTime& opTimeAndWallTime, DataConsistency consistency);
+ const OpTimeAndWallTime& opTimeAndWallTime);
virtual void setMyLastDurableOpTimeAndWallTimeForward(
const OpTimeAndWallTime& opTimeAndWallTime);
@@ -281,8 +281,7 @@ public:
virtual void blacklistSyncSource(const HostAndPort& host, Date_t until) override;
- virtual void resetLastOpTimesFromOplog(OperationContext* opCtx,
- DataConsistency consistency) override;
+ virtual void resetLastOpTimesFromOplog(OperationContext* opCtx) override;
virtual ChangeSyncSourceAction shouldChangeSyncSource(const HostAndPort& currentSource,
const rpc::ReplSetMetadata& replMetadata,
@@ -1014,8 +1013,7 @@ private:
*/
void _setMyLastAppliedOpTimeAndWallTime(WithLock lk,
const OpTimeAndWallTime& opTime,
- bool isRollbackAllowed,
- DataConsistency consistency);
+ bool isRollbackAllowed);
void _setMyLastDurableOpTimeAndWallTime(WithLock lk,
const OpTimeAndWallTime& opTimeAndWallTime,
bool isRollbackAllowed);
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index c98bc0e070c..701134928fb 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -6858,12 +6858,11 @@ TEST_F(ReplCoordTest,
OpTime time2(Timestamp(100, 2), term);
OpTime time3(Timestamp(100, 3), term);
- auto consistency = ReplicationCoordinator::DataConsistency::Consistent;
replCoordSetMyLastAppliedOpTime(time1, Date_t() + Seconds(100));
ASSERT_EQUALS(time1, getReplCoord()->getMyLastAppliedOpTime());
- replCoordSetMyLastAppliedOpTimeForward(time3, consistency, Date_t() + Seconds(100));
+ replCoordSetMyLastAppliedOpTimeForward(time3, Date_t() + Seconds(100));
ASSERT_EQUALS(time3, getReplCoord()->getMyLastAppliedOpTime());
- replCoordSetMyLastAppliedOpTimeForward(time2, consistency, Date_t() + Seconds(100));
+ replCoordSetMyLastAppliedOpTimeForward(time2, Date_t() + Seconds(100));
replCoordSetMyLastDurableOpTimeForward(time2, Date_t() + Seconds(100));
ASSERT_EQUALS(time3, getReplCoord()->getMyLastAppliedOpTime());
}
@@ -6883,12 +6882,11 @@ DEATH_TEST_F(ReplCoordTest,
OpTime time1(Timestamp(100, 1), 1);
OpTime time2(Timestamp(99, 1), 2);
- auto consistency = ReplicationCoordinator::DataConsistency::Consistent;
replCoordSetMyLastAppliedOpTime(time1, Date_t() + Seconds(100));
ASSERT_EQUALS(time1, getReplCoord()->getMyLastAppliedOpTime());
// Since in pv1, oplog entries are ordered by non-decreasing
// term and strictly increasing timestamp, it leads to invariant failure.
- replCoordSetMyLastAppliedOpTimeForward(time2, consistency, Date_t() + Seconds(100));
+ replCoordSetMyLastAppliedOpTimeForward(time2, Date_t() + Seconds(100));
}
DEATH_TEST_F(ReplCoordTest,
@@ -6906,12 +6904,11 @@ DEATH_TEST_F(ReplCoordTest,
OpTime time1(Timestamp(100, 1), 1);
OpTime time2(Timestamp(100, 1), 2);
- auto consistency = ReplicationCoordinator::DataConsistency::Consistent;
replCoordSetMyLastAppliedOpTime(time1, Date_t() + Seconds(100));
ASSERT_EQUALS(time1, getReplCoord()->getMyLastAppliedOpTime());
// Since in pv1, oplog entries are ordered by non-decreasing
// term and strictly increasing timestamp, it leads to invariant failure.
- replCoordSetMyLastAppliedOpTimeForward(time2, consistency, Date_t() + Seconds(100));
+ replCoordSetMyLastAppliedOpTimeForward(time2, Date_t() + Seconds(100));
}
DEATH_TEST_F(ReplCoordTest,
@@ -6929,12 +6926,11 @@ DEATH_TEST_F(ReplCoordTest,
OpTime time1(Timestamp(100, 1), 1);
OpTime time2(Timestamp(100, 2), 0);
- auto consistency = ReplicationCoordinator::DataConsistency::Consistent;
replCoordSetMyLastAppliedOpTime(time1, Date_t() + Seconds(100));
ASSERT_EQUALS(time1, getReplCoord()->getMyLastAppliedOpTime());
// Since in pv1, oplog entries are ordered by non-decreasing
// term and strictly increasing timestamp, it leads to invariant failure.
- replCoordSetMyLastAppliedOpTimeForward(time2, consistency, Date_t() + Seconds(100));
+ replCoordSetMyLastAppliedOpTimeForward(time2, Date_t() + Seconds(100));
}
DEATH_TEST_F(ReplCoordTest,
@@ -6952,12 +6948,11 @@ DEATH_TEST_F(ReplCoordTest,
OpTime time1(Timestamp(100, 1), 1);
OpTime time2(Timestamp(100, 1), 0);
- auto consistency = ReplicationCoordinator::DataConsistency::Consistent;
replCoordSetMyLastAppliedOpTime(time1, Date_t() + Seconds(100));
ASSERT_EQUALS(time1, getReplCoord()->getMyLastAppliedOpTime());
// Since in pv1, oplog entries are ordered by non-decreasing
// term and strictly increasing timestamp, it leads to invariant failure.
- replCoordSetMyLastAppliedOpTimeForward(time2, consistency, Date_t() + Seconds(100));
+ replCoordSetMyLastAppliedOpTimeForward(time2, Date_t() + Seconds(100));
}
TEST_F(ReplCoordTest, OnlyForwardSyncProgressForOtherNodesWhenTheNodesAreBelievedToBeUp) {
diff --git a/src/mongo/db/repl/replication_coordinator_mock.cpp b/src/mongo/db/repl/replication_coordinator_mock.cpp
index be452167de0..e6082fc887f 100644
--- a/src/mongo/db/repl/replication_coordinator_mock.cpp
+++ b/src/mongo/db/repl/replication_coordinator_mock.cpp
@@ -247,7 +247,7 @@ void ReplicationCoordinatorMock::setMyLastDurableOpTimeAndWallTime(
}
void ReplicationCoordinatorMock::setMyLastAppliedOpTimeAndWallTimeForward(
- const OpTimeAndWallTime& opTimeAndWallTime, DataConsistency consistency) {
+ const OpTimeAndWallTime& opTimeAndWallTime) {
stdx::lock_guard<Mutex> lk(_mutex);
if (opTimeAndWallTime.opTime > _myLastAppliedOpTime) {
@@ -489,8 +489,7 @@ HostAndPort ReplicationCoordinatorMock::chooseNewSyncSource(const OpTime& lastOp
void ReplicationCoordinatorMock::blacklistSyncSource(const HostAndPort& host, Date_t until) {}
-void ReplicationCoordinatorMock::resetLastOpTimesFromOplog(OperationContext* opCtx,
- DataConsistency consistency) {
+void ReplicationCoordinatorMock::resetLastOpTimesFromOplog(OperationContext* opCtx) {
stdx::lock_guard<Mutex> lk(_mutex);
_resetLastOpTimesCalled = true;
diff --git a/src/mongo/db/repl/replication_coordinator_mock.h b/src/mongo/db/repl/replication_coordinator_mock.h
index ebd848e62d8..5ee450adb01 100644
--- a/src/mongo/db/repl/replication_coordinator_mock.h
+++ b/src/mongo/db/repl/replication_coordinator_mock.h
@@ -140,7 +140,7 @@ public:
virtual void setMyLastDurableOpTimeAndWallTime(const OpTimeAndWallTime& opTimeAndWallTime);
virtual void setMyLastAppliedOpTimeAndWallTimeForward(
- const OpTimeAndWallTime& opTimeAndWallTime, DataConsistency consistency);
+ const OpTimeAndWallTime& opTimeAndWallTime);
virtual void setMyLastDurableOpTimeAndWallTimeForward(
const OpTimeAndWallTime& opTimeAndWallTime);
@@ -245,7 +245,7 @@ public:
virtual void blacklistSyncSource(const HostAndPort& host, Date_t until);
- virtual void resetLastOpTimesFromOplog(OperationContext* opCtx, DataConsistency consistency);
+ virtual void resetLastOpTimesFromOplog(OperationContext* opCtx);
bool lastOpTimesWereReset() const;
diff --git a/src/mongo/db/repl/replication_coordinator_noop.cpp b/src/mongo/db/repl/replication_coordinator_noop.cpp
index 5d703311b4a..6e34f3c0d9d 100644
--- a/src/mongo/db/repl/replication_coordinator_noop.cpp
+++ b/src/mongo/db/repl/replication_coordinator_noop.cpp
@@ -206,8 +206,8 @@ void ReplicationCoordinatorNoOp::setMyHeartbeatMessage(const std::string&) {
MONGO_UNREACHABLE;
}
-void ReplicationCoordinatorNoOp::setMyLastAppliedOpTimeAndWallTimeForward(const OpTimeAndWallTime&,
- DataConsistency) {
+void ReplicationCoordinatorNoOp::setMyLastAppliedOpTimeAndWallTimeForward(
+ const OpTimeAndWallTime&) {
MONGO_UNREACHABLE;
}
@@ -393,7 +393,7 @@ void ReplicationCoordinatorNoOp::blacklistSyncSource(const HostAndPort&, Date_t)
MONGO_UNREACHABLE;
}
-void ReplicationCoordinatorNoOp::resetLastOpTimesFromOplog(OperationContext*, DataConsistency) {
+void ReplicationCoordinatorNoOp::resetLastOpTimesFromOplog(OperationContext*) {
MONGO_UNREACHABLE;
}
diff --git a/src/mongo/db/repl/replication_coordinator_noop.h b/src/mongo/db/repl/replication_coordinator_noop.h
index fb3a5ec64d2..5090132dd7f 100644
--- a/src/mongo/db/repl/replication_coordinator_noop.h
+++ b/src/mongo/db/repl/replication_coordinator_noop.h
@@ -122,8 +122,7 @@ public:
void setMyLastAppliedOpTimeAndWallTime(const OpTimeAndWallTime& opTimeAndWallTime) final;
void setMyLastDurableOpTimeAndWallTime(const OpTimeAndWallTime& opTimeAndWallTime) final;
- void setMyLastAppliedOpTimeAndWallTimeForward(const OpTimeAndWallTime& opTimeAndWallTime,
- DataConsistency consistency) final;
+ void setMyLastAppliedOpTimeAndWallTimeForward(const OpTimeAndWallTime& opTimeAndWallTime) final;
void setMyLastDurableOpTimeAndWallTimeForward(const OpTimeAndWallTime& opTimeAndWallTime) final;
void resetMyLastOpTimes() final;
@@ -212,7 +211,7 @@ public:
void blacklistSyncSource(const HostAndPort&, Date_t) final;
- void resetLastOpTimesFromOplog(OperationContext*, DataConsistency) final;
+ void resetLastOpTimesFromOplog(OperationContext*) final;
ChangeSyncSourceAction shouldChangeSyncSource(const HostAndPort&,
const rpc::ReplSetMetadata&,
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.h b/src/mongo/db/repl/replication_coordinator_test_fixture.h
index a29fecdaf70..1498d409e8a 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.h
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.h
@@ -126,13 +126,11 @@ protected:
getReplCoord()->setMyLastAppliedOpTimeAndWallTime({opTime, wallTime});
}
- void replCoordSetMyLastAppliedOpTimeForward(const OpTime& opTime,
- ReplicationCoordinator::DataConsistency consistency,
- Date_t wallTime = Date_t()) {
+ void replCoordSetMyLastAppliedOpTimeForward(const OpTime& opTime, Date_t wallTime = Date_t()) {
if (wallTime == Date_t()) {
wallTime = Date_t() + Seconds(opTime.getSecs());
}
- getReplCoord()->setMyLastAppliedOpTimeAndWallTimeForward({opTime, wallTime}, consistency);
+ getReplCoord()->setMyLastAppliedOpTimeAndWallTimeForward({opTime, wallTime});
}
void replCoordSetMyLastDurableOpTime(const OpTime& opTime, Date_t wallTime = Date_t()) {
diff --git a/src/mongo/db/repl/rollback_impl.cpp b/src/mongo/db/repl/rollback_impl.cpp
index 83ab9d39004..753802916cc 100644
--- a/src/mongo/db/repl/rollback_impl.cpp
+++ b/src/mongo/db/repl/rollback_impl.cpp
@@ -245,8 +245,7 @@ Status RollbackImpl::runRollback(OperationContext* opCtx) {
// At this point, the last applied and durable optimes on this node still point to ops on
// the divergent branch of history. We therefore update the last optimes to the top of the
// oplog, which should now be at the common point.
- _replicationCoordinator->resetLastOpTimesFromOplog(
- opCtx, ReplicationCoordinator::DataConsistency::Consistent);
+ _replicationCoordinator->resetLastOpTimesFromOplog(opCtx);
status = _triggerOpObserver(opCtx);
if (!status.isOK()) {
return status;
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index 5aa58b0ee96..12b86993a2a 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -2014,8 +2014,7 @@ void rollback_internal::syncFixUp(OperationContext* opCtx,
// have rolled back to an optime that fell in the middle of an oplog application batch. We make
// the database consistent again after rollback by applying ops forward until we reach
// 'minValid'.
- replCoord->resetLastOpTimesFromOplog(opCtx,
- ReplicationCoordinator::DataConsistency::Inconsistent);
+ replCoord->resetLastOpTimesFromOplog(opCtx);
}
Status syncRollback(OperationContext* opCtx,
diff --git a/src/mongo/embedded/replication_coordinator_embedded.cpp b/src/mongo/embedded/replication_coordinator_embedded.cpp
index fd12817508c..303d5bcd301 100644
--- a/src/mongo/embedded/replication_coordinator_embedded.cpp
+++ b/src/mongo/embedded/replication_coordinator_embedded.cpp
@@ -214,7 +214,7 @@ void ReplicationCoordinatorEmbedded::setMyHeartbeatMessage(const std::string&) {
}
void ReplicationCoordinatorEmbedded::setMyLastAppliedOpTimeAndWallTimeForward(
- const OpTimeAndWallTime&, DataConsistency) {
+ const OpTimeAndWallTime&) {
UASSERT_NOT_IMPLEMENTED;
}
@@ -418,7 +418,7 @@ void ReplicationCoordinatorEmbedded::blacklistSyncSource(const HostAndPort&, Dat
UASSERT_NOT_IMPLEMENTED;
}
-void ReplicationCoordinatorEmbedded::resetLastOpTimesFromOplog(OperationContext*, DataConsistency) {
+void ReplicationCoordinatorEmbedded::resetLastOpTimesFromOplog(OperationContext*) {
UASSERT_NOT_IMPLEMENTED;
}
diff --git a/src/mongo/embedded/replication_coordinator_embedded.h b/src/mongo/embedded/replication_coordinator_embedded.h
index e7a2de3b9a8..6e6923d52f4 100644
--- a/src/mongo/embedded/replication_coordinator_embedded.h
+++ b/src/mongo/embedded/replication_coordinator_embedded.h
@@ -127,8 +127,8 @@ public:
const repl::OpTimeAndWallTime& opTimeAndWallTime) override;
void setMyLastDurableOpTimeAndWallTime(
const repl::OpTimeAndWallTime& opTimeAndWallTime) override;
- void setMyLastAppliedOpTimeAndWallTimeForward(const repl::OpTimeAndWallTime& opTimeAndWallTime,
- DataConsistency consistency) override;
+ void setMyLastAppliedOpTimeAndWallTimeForward(
+ const repl::OpTimeAndWallTime& opTimeAndWallTime) override;
void setMyLastDurableOpTimeAndWallTimeForward(
const repl::OpTimeAndWallTime& opTimeAndWallTime) override;
@@ -218,7 +218,7 @@ public:
void blacklistSyncSource(const HostAndPort&, Date_t) override;
- void resetLastOpTimesFromOplog(OperationContext*, DataConsistency) override;
+ void resetLastOpTimesFromOplog(OperationContext*) override;
repl::ChangeSyncSourceAction shouldChangeSyncSource(const HostAndPort&,
const rpc::ReplSetMetadata&,