|
In addition to the manifestation of this problem originally described by arun.banala@mongodb.com in the ticket description, I've crafted another scenario where tombstones left behind inside arrays affect the correctness of downstream operations in the query execution plan:
(function() {
|
"use strict";
|
|
const coll = db.tombstone_repro;
|
coll.drop();
|
|
assert.commandWorked(coll.insert({a: 1, b: [{x: 1, y: 1}, 1], c: [{x: 1}]}));
|
|
const pipeline[{$group: {_id: "$a", b: {$first: "$b"}, c: {$first: "$c"}}},
|
{$project: {"b.x": 1, "c.x": 1}},
|
{$addFields: {comparison: {$eq: ["$b", "$c"]}}}];
|
printjson(coll.aggregate(pipeline).toArray());
|
}());
|
This script produces the following output:
[
|
{
|
"_id" : 1,
|
"b" : [
|
{
|
"x" : 1
|
}
|
],
|
"c" : [
|
{
|
"x" : 1
|
}
|
],
|
"comparison" : false
|
}
|
]
|
The fact that the comparison field is false seems wrong to me, since "b" and "c" are equal apart from tombstones. The concept of tombstones should be entirely internal to the implementation of the engine, but instead it has real consequences for the behavior of the query that are observable by the end user.
This ticket seems very similar to SERVER-70860, which was recently filed by ivan.fefer@mongodb.com. Ivan and Arun, do you think that SERVER-70860 should be closed as a duplicate of this ticket?
|