[SERVER-69264] Fail time-series index builds due to mixed schema only at commit time Created: 31/Aug/22  Updated: 29/Oct/23  Resolved: 05/Oct/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.2.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Louis Williams Assignee: Gregory Noma
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
is caused by SERVER-60577 Add logic to check time-series bucket... Closed
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2022-10-03, Execution Team 2022-10-17
Participants:

 Description   

We return an error on the primary if we detect mixed schema data in a document. See code.

The issue with this check is that we cannot guarantee that a node will ever be primary when scanning any problematic documents. Consider the following scenario:

  • Node 1 is primary, Node 2 is secondary
  • Node 1 replicates a startIndexBuild oplog entry, and both Node 1 and 2 start a collection scan
  • Node 2 scans a mixed-schema document, but does not report an error because it is secondary
  • A leadership change happens and Node 2 becomes primary, Node 1 becomes secondary
  • Now Node 1 scans a mixed-schema document

In this scenario, neither node reported an error about a mixed-schema document because neither node was primary when this document was scanned.

We have to follow the same approach we do with all constraint violations, which is record them on all nodes and have the committing primary confirm whether these violations still exist, and handle them at commit time.

This can cause CannotCreateIndex to escape from the index build which is not allowed.



 Comments   
Comment by Githook User [ 05/Oct/22 ]

Author:

{'name': 'Gregory Noma', 'email': 'gregory.noma@gmail.com', 'username': 'gregorynoma'}

Message: SERVER-69264 Fail time-series index builds due to mixed schema only at commit time
Branch: master
https://github.com/mongodb/mongo/commit/006fee088ba3235e427dbdeeeba74e0964e63aa1

Comment by Gregory Noma [ 04/Oct/22 ]

This isn't actually a bug due to this check at commit time. I've updated the ticket accordingly.

Comment by Louis Williams [ 31/Aug/22 ]

I noticed this bug because I saw the addition of CannotCreateIndex to this assertion. We shouldn't be adding any error codes to that list, because in almost all cases, this indicates a potential bug like the one I described.

Generated at Thu Feb 08 06:13:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.