|
I have confirmed that this was fixed as a result of the work under SERVER-44487, so I am closing this as Gone Away. I checked by running the following:
MongoDB Enterprise > db.c.drop()
|
true
|
MongoDB Enterprise > db.c.insert({a: 1, b: 1, c: 1, d: 1})
|
WriteResult({ "nInserted" : 1 })
|
MongoDB Enterprise > db.c.aggregate([{$project: {d: 0}}, {$project: {e: 0}}])
|
{ "_id" : ObjectId("5dcc704907622ccc2870a8f8"), "a" : 1, "b" : 1, "c" : 1 }
|
I also added debug logging which includes the number of entries in the DocumentStorage cache whenever a new cache entry is created:
diff --git a/src/mongo/db/exec/document_value/document.cpp b/src/mongo/db/exec/document_value/document.cpp
|
index 17c18ba3c7..322168ff52 100644
|
--- a/src/mongo/db/exec/document_value/document.cpp
|
+++ b/src/mongo/db/exec/document_value/document.cpp
|
@@ -177,6 +177,10 @@ Position DocumentStorage::constructInCache(const BSONElement& elem) {
|
appendField(fieldName, ValueElement::Kind::kCached) = Value(elem);
|
_modified = savedModified;
|
|
+ std::cout << "[dstorch] constructInCache() for doc storage "
|
+ << reinterpret_cast<uintptr_t>(this) << " field: " << elem.fieldNameStringData()
|
+ << " numFields: " << _numFields << std::endl;
|
+
|
return pos;
|
}
|
Before the fix, this query resulted in 10 cache entries in a single document:
[dstorch] constructInCache() for doc storage 94492680159104 field: _id numFields: 1
|
[dstorch] constructInCache() for doc storage 94492680159104 field: a numFields: 2
|
[dstorch] constructInCache() for doc storage 94492680159104 field: b numFields: 3
|
[dstorch] constructInCache() for doc storage 94492680159104 field: c numFields: 4
|
[dstorch] constructInCache() for doc storage 94492680159104 field: d numFields: 5
|
[dstorch] constructInCache() for doc storage 94492680158848 field: _id numFields: 6
|
[dstorch] constructInCache() for doc storage 94492680158848 field: a numFields: 7
|
[dstorch] constructInCache() for doc storage 94492680158848 field: b numFields: 8
|
[dstorch] constructInCache() for doc storage 94492680158848 field: c numFields: 9
|
[dstorch] constructInCache() for doc storage 94492680158848 field: d numFields: 10
|
After the fix, we see just 5 fields:
[dstorch] constructInCache() for doc storage 139700113381760 field: _id numFields: 1
|
[dstorch] constructInCache() for doc storage 139700113381760 field: a numFields: 2
|
[dstorch] constructInCache() for doc storage 139700113381760 field: b numFields: 3
|
[dstorch] constructInCache() for doc storage 139700113381760 field: c numFields: 4
|
[dstorch] constructInCache() for doc storage 139700113381760 field: d numFields: 5
|
|