diff options
Diffstat (limited to 'jstests/noPassthrough/truncate_large_profiler_entry.js')
-rw-r--r-- | jstests/noPassthrough/truncate_large_profiler_entry.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/jstests/noPassthrough/truncate_large_profiler_entry.js b/jstests/noPassthrough/truncate_large_profiler_entry.js new file mode 100644 index 00000000000..1cf05c27d45 --- /dev/null +++ b/jstests/noPassthrough/truncate_large_profiler_entry.js @@ -0,0 +1,36 @@ +/** + * Test which verifies that large profiler entries generated for SBE plans do not exceed the max + * BSON depth. Instead, they get truncated right below the max depth. + */ +(function() { +"use strict"; + +const conn = + MongoRunner.runMongod({setParameter: "internalQueryEnableSlotBasedExecutionEngine=true"}); +assert.neq(null, conn, "mongod was unable to startup"); +const db = conn.getDB("test"); +const collName = jsTestName(); +const coll = db[collName]; +coll.drop(); + +// Insert some documents so our query will perform some work. +assert.commandWorked(coll.insert([{a: 1}, {a: 2}])); +const longField = 'a.'.repeat(99) + 'a'; +const projectionSpec = { + [longField]: 1 +}; + +// Setup the profiler to only pick up the query below. +assert.commandWorked(db.setProfilingLevel(2, {slowms: 0, sampleRate: 1}, { + filter: {'op': 'query', 'command.projection': projectionSpec} +})); + +// Verify that our query was picked up by the profiler. +coll.find({}, projectionSpec).toArray(); +const profilerEntry = db.system.profile.find().toArray(); +assert.eq(1, profilerEntry.length, profilerEntry); + +// Collection validation should detect no issues. +assert.commandWorked(db.system.profile.validate({full: true})); +MongoRunner.stopMongod(conn); +}()); |