[SERVER-42864] change index build initial write timestamp logic Created: 16/Aug/19  Updated: 29/Oct/23  Resolved: 20/Aug/19

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: 4.2.1, 4.3.1

Type: Task Priority: Major - P3
Reporter: Eric Milkie Assignee: Eric Milkie
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
is related to SERVER-42843 shutting down a node while in PRIMARY... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.2
Sprint: Execution Team 2019-08-26
Participants:
Linked BF Score: 69

 Description   

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.



 Comments   
Comment by Githook User [ 12/Sep/19 ]

Author:

{'username': 'milkie', 'email': 'milkie@10gen.com', 'name': 'Eric Milkie'}

Message: SERVER-42864 change index build initial write timestamp logic

(cherry picked from commit 99593e1255dde3320ac330599311e3481a1ac0e0)
Branch: v4.2
https://github.com/mongodb/mongo/commit/08e81689618d7bf906377913e4f2958ce216e275

Comment by Githook User [ 20/Aug/19 ]

Author:

{'name': 'Eric Milkie', 'email': 'milkie@10gen.com', 'username': 'milkie'}

Message: SERVER-42864 change index build initial write timestamp logic
Branch: master
https://github.com/mongodb/mongo/commit/99593e1255dde3320ac330599311e3481a1ac0e0

Generated at Thu Feb 08 05:01:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.