[SERVER-74144] Fix UpdateDriver::modsAffectIndices false-negative in v6.0 Created: 17/Feb/23  Updated: 06/Jul/23  Resolved: 06/Jul/23

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

Type: Bug Priority: Major - P3
Reporter: Ivan Fefer Assignee: Ivan Fefer
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File reproduce.js    
Issue Links:
Depends
Assigned Teams:
Query Execution
Operating System: ALL
Steps To Reproduce:

reproduce.js script is attached

Sprint: QE 2023-05-15, QE 2023-05-29
Participants:
Linked BF Score: 9

 Description   

In mongod versions <= 6.0 UpdateDriver::modsAffectIndices can produce false-negative result.

It is fixed in 6.3.0-rc0 with SERVER-65364, but this change is too massive to safely backport it as is even to 6.0.

In this ticket we need to implement a custom small fix to 6.0 and try to backport it as far as possible.

How to reproduce:

  1. Create wildcard index 

    {"b.d.$**": 1} 

  1. Add document 

    {a: 1}
    

  1. Update document with 

    {$set: {"b.c": 1}}
    

  1. Call validate({full: true}) on the collection.

Validation will show that there is missing index key "b" for the updated document.

Fortunately this redundant key will never be used because the path 'b' is not covered by the wildcard path, b.d.$** and the index bounds generated for wildcard indexes will always match the path.



 Comments   
Comment by Ivan Fefer [ 06/Jul/23 ]

Closing the issue as Won't Do for the following reasons:

  • The issue is fixed in 6.3+, so this ticket is only for older versions.
  • The original fix is too big for a clean backport.
  • The issue is only a false-positive validation failure. It doesn't cause any query correctness problems.
  • The issue happens only in a very specific circumstances that are very rare in practice.
Comment by Ivan Fefer [ 20/Feb/23 ]

Idea for a small fix: update wildcard_key_generator to not generate redundant keys.

This will make false-negative into true-negative.

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