[SERVER-57014] Sharded find command fails with "undefined slot accessor" when SBE is on Created: 17/May/21  Updated: 29/Oct/23  Resolved: 19/May/21

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

Type: Bug Priority: Major - P3
Reporter: David Storch Assignee: Nikita Lapkov (Inactive)
Resolution: Fixed Votes: 0
Labels: post-rc0, sbe-post-rc0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0
Sprint: Query Execution 2021-05-31
Participants:
Linked BF Score: 47

 Description   

The query_fuzzer_sharded picked up on this. I haven't figured out exactly what the problem is yet, but here is a simple repro:

(function() {
"use strict";
 
const st = new ShardingTest({shards: 1});
const db = st.s.getDB("test");
 
const shardKey = {
    num: 1,
    "obj.str": "hashed"
};
 
assert.commandWorked(db.createCollection("c"));
const coll = db.c;
assert.commandWorked(coll.createIndex(shardKey));
 
assert.commandWorked(db.adminCommand({enableSharding: "test"}));
assert.commandWorked(db.adminCommand({
    shardCollection: coll.getFullName(),
    key: shardKey,
}));
 
assert.eq([], coll.find({num: {$in: [/myRegex/, 1]}}).sort({"obj.obj.obj": 1}).toArray());
 
st.stop();
}());

Note that although this is an "undefined slot accessor" error which can happen in the query fuzzer, it looks like a separate issue from SERVER-56506.

One thing I noticed is that this does not repro unless the $in match expression has a regular expression as one of its arguments. Perhaps some special code in the SBE stage builders for $in with a regex plays badly with how we construct the plan for shard filtering? Just guessing based on the nature of the repro.



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

Author:

{'name': 'Nikita Lapkov', 'email': 'nikita.lapkov@mongodb.com', 'username': 'laplab'}

Message: SERVER-57014 Include all index keys in relevant slots for index filter

(cherry picked from commit 39c04abc9ec9da43130f64f2158b9b6293bf1d80)
Branch: v5.0
https://github.com/mongodb/mongo/commit/8173602a6b932b2fe0981182a7f84ff1ecaa91f4

Comment by Githook User [ 19/May/21 ]

Author:

{'name': 'Nikita Lapkov', 'email': 'nikita.lapkov@mongodb.com', 'username': 'laplab'}

Message: SERVER-57014 Include all index keys in relevant slots for index filter
Branch: master
https://github.com/mongodb/mongo/commit/39c04abc9ec9da43130f64f2158b9b6293bf1d80

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