[SERVER-48593] createIndexForApplyOps() should always relax index build constraints Created: 04/Jun/20  Updated: 29/Oct/23  Resolved: 15/Mar/21

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Improvement Priority: Minor - P4
Reporter: Benety Goh Assignee: Bynn Lee
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
Related
related to SERVER-47182 Single-phase index builds should run ... Closed
is related to SERVER-55421 Relax index constraints when recoverT... Closed
is related to SERVER-21700 Do not relax constraints during stead... Closed
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2021-03-08, Execution Team 2021-03-22
Participants:
Linked BF Score: 135

 Description   

This function is used to apply createIndexes oplog entries. After SERVER-47182 and SERVER-41554, this function should not be used outside oplog application. We should be able to always set the index build constraints to kRelax instead of querying the ReplicationCoordinator with the collection namespace.



 Comments   
Comment by Githook User [ 15/Mar/21 ]

Author:

{'name': 'Bynn Lee', 'email': 'bynn.lee@mongodb.com', 'username': 'bynn'}

Message: SERVER-48593 createIndexForApplyOps() should always relax index build constraints
Branch: master
https://github.com/mongodb/mongo/commit/66c8aa36e0574c82c4cdf771fc124939d0d23a5e

Comment by Bynn Lee [ 03/Mar/21 ]

Off of commit 868785d084ea685f7d0a269d2a87e8a7df338e5d

patch with invariant

Fails db_repl_test

the invariant is hit from applyOplogEntryOrGroupedInsertsCommon in OplogApplierUtils

 "Invariant failure","attr":{"expr":"ReplicationCoordinator::get(opCtx)->shouldRelaxIndexConstraints(opCtx, indexNss)","msg":"Unexpected result from shouldRelaxIndexConstraints - ns: test.foo; uuid: 4331f5c5-59a0-440f-a645-a1acec79ff02; original index spec: { v: 2, key:{ loc: \"2dsphere\" }, name: \"loc_index\", 2dsphereIndexVersion: 3 }","file":"src/mongo/db/repl/oplog.cpp","line":225}"

invariance fails when shouldRelaxIndexConstraints is false.
shouldRelaxIndexConstraints is true if shouldRecoverFromOplogAsStandalone but !canAcceptWritesFor if otherwise

patch without invariant
fails IdempotencyTest::IndexWithDifferentOptions (oplog_applier_impl_test.cpp) as referenced in previous comment

Fails this assertion

 ASSERT_EQ(status.code(), ErrorCodes::IndexOptionsConflict);

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