const st = new ShardingTest({
|
shards: 1,
|
});
|
const dbName = "foo";
|
const collName = "bar";
|
const ns = dbName + "." + collName;
|
assert.commandWorked(st.s.adminCommand({enableSharding: dbName}));
|
assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {skey: 1}}));
|
assert.commandWorked(st.s.getCollection(ns).insert({_id: 1, x: 1}));
|
assert.sameMembers(st.s.getCollection(ns).find({x: 1}).toArray(), [{_id: 1, x: 1}]);
|
st.stop();
|
When the following test-case is run under Bonsai, we currently incorrectly omit the document. Inserting some print statements into the code, I observed that the plan which Bonsai generates ends up invoking ShardFilterer::keyBelongsToMe with an empty BSONObj, rather than {skey: null}. Based on the API contract of keyBelongsToMe, this is undefined behavior.
This is confirmed when looking at the plan generated by the SBE stage builders:
shardFilter(s1, makeBsonObj(MakeObjSpec([\"skey\" = Arg(0)], Open), Nothing, (s2 ?: null)))
|
The plan produced by Bonsai looks like:
shardFilter(s1, makeBsonObj(MakeObjSpec([\"skey\" = Arg(0)], Open), Nothing, s3))
|
|