-
Type:
Engineering Test
-
Resolution: Fixed
-
Priority:
Major - P3
-
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
- Build a unique index on a collection that contains at least one true duplicate so the recordDuplicateKey
callback is invoked - Drive the build through the load phase up to (and including) _indexes[i].bulk->commit.
- Immediately before the call that will trigger duplicate recording, arm the engine-agnostic write-conflict failpoint
- After commit returns, assert all three:
- The build commit succeeded (the retry did its job).
- Exactly one WCE fired
- 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.
- blocks
-
SERVER-118769 Add jstests with write conflicts to primary-driven index build suites
-
- Closed
-
- is depended on by
-
SERVER-126385 Make unit tests that exercise _writeStateToContainer write conflict retry
-
- Closed
-
- is related to
-
SERVER-126326 Add PDIB test suites that artificially inject write conflicts
-
- Closed
-
-
SERVER-126328 Have a storage engine-agnostic way to turn on write conflict fail points in unit tests
-
- Closed
-