|
The code currently does this to timestamp the initial catalog write for index builds:
if (opCtx->recoveryUnit()->getCommitTimestamp().isNull() &&
|
replCoord->canAcceptWritesForDatabase(opCtx, "admin")) {
|
// Only primaries must timestamp this write. Secondaries run this from within a
|
// `TimestampBlock`. Primaries performing an index build via `applyOps` may have a
|
// wrapping commit timestamp that will be used instead.
|
opCtx->getServiceContext()->getOpObserver()->onOpMessage(
|
opCtx,
|
BSON("msg" << std::string(str::stream() << "Creating indexes. Coll: " << ns)));
|
}
|
Instead of canAcceptWritesForDatabase(), which incorrectly captures times when a primary is attempting to step down but hasn't yet, we can check for the node state to be STARTUP2; this bit of logic is attempting to differentiate between normal index builds that must be timestamped and index builds that are part of initial sync and must not be timestamped.
|