[SERVER-56140] [SBE] UniqueStage::close() should clear its _seen buffer Created: 16/Apr/21  Updated: 29/Oct/23  Resolved: 21/Apr/21

Status: Closed
Project: Core Server
Component/s: Query Execution
Affects Version/s: None
Fix Version/s: 5.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: David Storch Assignee: Mihai Andrei
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File query_fuzzer_repro.js    
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Run the attached repro script like so:

python3 buildscripts/resmoke.py run --suites=jstestfuzz --additionalFeatureFlags=featureFlagSBE query_fuzzer_repro.js

Sprint: Query Execution 2021-05-03
Participants:

 Description   

We observed this failure here. I spent some time minimizing the repro so that it runs faster but didn't look into it deeply. See attached file query_fuzzer_repro.js

The problematic find command is:

    {
        find: 'fuzzer_coll',
        filter: {'obj.obj.obj.array': {$exists: false}},
        projection: {'obj.obj.obj.num': 0},
        sort: {'obj.obj.obj.obj.obj.array': 1, _id: 1}
    },

However, the fuzzer code will augment the projection with a $meta:"sortKey" expression. As a result, the find command runs in the classic engine, but the equivalent aggregate command runs using SBE. The find/classic version returns 102 documents whereas the agg/SBE version returns just 1. The following indexes exist on the collection, which I've found is necessary for the repro:

const indexList = [
    {
        'obj.obj.obj.array': 1,
        'obj.obj.obj.obj.date': -1,
        'obj.obj.num': -1,
    },  // 15
    {
        'obj.obj.obj.array': 1,
        'obj.obj.num': -1,
    },  // 77
];

It's possible that this is related in some way to SERVER-56132, since it looks like this failure also could involve early exit during SBE multi-planning.



 Comments   
Comment by Githook User [ 21/Apr/21 ]

Author:

{'name': 'Mihai Andrei', 'email': 'mihai.andrei@10gen.com', 'username': 'mtandrei'}

Message: SERVER-56140 [SBE] UniqueStage::close() should clear its _seen buffer
Branch: master
https://github.com/mongodb/mongo/commit/895c9a4ae9f77a7de2d5537bfd111d9d15c60847

Comment by David Storch [ 20/Apr/21 ]

Nice digging on this mihai.andrei!

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