Test recordDuplicateKey writeConflictRetry in primary-driven index builds

XMLWordPrintableJSON

    • Type: Engineering Test
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Storage Execution
    • Fully Compatible
    • Storage Execution 2026-04-27, Storage Execution 2026-05-11, Storage Execution 2026-05-25, Storage Execution 2026-06-08
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Add a deterministic unit test that exercises the writeConflictRetry block at src/mongo/db/index_builds/multi_index_block.cpp:1240, which wraps IndexBuildInterceptor::recordDuplicateKey during the bulk-load commit of a unique index

      1. Build a unique index on a collection that contains at least one true duplicate so the recordDuplicateKey
          callback is invoked
      2. Drive the build through the load phase up to (and including) _indexes[i].bulk->commit.
      3. Immediately before the call that will trigger duplicate recording, arm the engine-agnostic write-conflict failpoint 
      1. After commit returns, assert all three:
        1. The build commit succeeded (the retry did its job).
        2. Exactly one WCE fired
        3. The duplicate key was recorded exactly once in the duplicate-key tracking store the interceptor owns. (Count records directly in the underlying ident; do not just check "the read returned something" – a buggy retry  could insert the duplicate twice and a weak read assertion would pass)

        Suggested test name: DuplicateKeyRecordingSurvivesWriteConflict.

        src/mongo/db/index_builds/multi_index_block_test.cpp.

        If exercising the duplicate path from MultiIndexBlockTest proves hard (e.g. the test fixture can't easily
        run a unique build with intentional dupes through insertAllDocumentsInCollection), route through
        IndexBuildsManagerTest (see src/mongo/db/index_builds/index_builds_manager_test.cpp) –

      Constraints

        * Use the engine-agnostic helper enableStorageEngineWriteConflictForWrites introduced by SERVER-126328, not the WT-specific WTWriteConflictException failpoint by name.
        * FailPoint::Mode::nTimes only – no Mode::random. Per the SPM-4469 strategic split, percentage-based
        WCE injection is jstest-level (SERVER-126326) only.
        * Test-only PR – do not modify production code.
        * Depends on SERVER-126385 landing first (it brings in enableStorageEngineWriteConflictForWrites +
        CatalogTestFixture plumbing).

      Acceptance

      • New DuplicateKeyRecordingSurvivesWriteConflict test passes.
      • All existing tests in +multi_index_block_test (or +index_builds_manager_test if routed there) pass.
        WCE-fired-exactly-once assertion present.
      • Exactly-one-duplicate-record-persisted assertion present (record-count check against the duplicate-key ident,  not just a read).
        No production code changed.
      • No Mode::random, no jstest changes.

            Assignee:
            Stephanie Eristoff
            Reporter:
            Jess Balint
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: