diff options
author | Benety Goh <benety@mongodb.com> | 2014-03-18 11:12:09 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2014-03-18 13:42:17 -0400 |
commit | 975cff4802c9042a736c142233b38312c2cd3a81 (patch) | |
tree | f82bf0882f6e2d264c83f52df565088f040d24bb | |
parent | 0de6511419aee109f2fb997e14b596f6295c90a8 (diff) | |
download | mongo-975cff4802c9042a736c142233b38312c2cd3a81.tar.gz |
SERVER-13241 system profile will hold plan summary if execution stats object is too large
-rw-r--r-- | jstests/core/profile4.js | 14 | ||||
-rw-r--r-- | jstests/profile4.js | 14 | ||||
-rw-r--r-- | src/mongo/db/curop.h | 3 | ||||
-rw-r--r-- | src/mongo/db/query/new_find.cpp | 8 |
4 files changed, 38 insertions, 1 deletions
diff --git a/jstests/core/profile4.js b/jstests/core/profile4.js index 63940ed1530..bfd78aee5d4 100644 --- a/jstests/core/profile4.js +++ b/jstests/core/profile4.js @@ -102,6 +102,20 @@ try { assert.eq( "FETCH", o.execStats.type, tojson( o.execStats ) ); assert.eq( "IXSCAN", o.execStats.children[0].type, tojson( o.execStats ) ); + // For queries with a lot of stats data, the execution stats in the profile + // is replaced by the plan summary. + var orClauses = 32; + var bigOrQuery = { $or: [] }; + for ( var i = 0; i < orClauses; ++i ) { + var indexSpec = {}; + indexSpec[ "a" + i ] = 1; + t.ensureIndex( indexSpec ); + bigOrQuery[ "$or" ].push( indexSpec ); + } + t.find( bigOrQuery ).itcount(); + o = lastOp(); + assert.neq( undefined, o.execStats.summary, tojson( o.execStats ) ); + db.setProfilingLevel(0); db.system.profile.drop(); } diff --git a/jstests/profile4.js b/jstests/profile4.js index 83bc0a27c7e..25d71acba6e 100644 --- a/jstests/profile4.js +++ b/jstests/profile4.js @@ -96,6 +96,20 @@ try { assert.eq( "FETCH", o.execStats.type, tojson( o.execStats ) ); assert.eq( "IXSCAN", o.execStats.children[0].type, tojson( o.execStats ) ); + // For queries with a lot of stats data, the execution stats in the profile + // is replaced by the plan summary. + var orClauses = 32; + var bigOrQuery = { $or: [] }; + for ( var i = 0; i < orClauses; ++i ) { + var indexSpec = {}; + indexSpec[ "a" + i ] = 1; + t.ensureIndex( indexSpec ); + bigOrQuery[ "$or" ].push( indexSpec ); + } + t.find( bigOrQuery ).itcount(); + o = lastOp(); + assert.neq( undefined, o.execStats.summary, tojson( o.execStats ) ); + db.setProfilingLevel(0); db.system.profile.drop(); } diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index 1226d0f3ed1..7562f47a01d 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -84,6 +84,7 @@ namespace mongo { int size() const { return *_size; } bool have() const { return size() > 0; } + bool tooBig() const { return size() == TOO_BIG_SENTINEL; } BSONObj get() const { scoped_spinlock lk(_lock); @@ -176,7 +177,7 @@ namespace mongo { // New Query Framework debugging/profiling info // TODO: should this really be an opaque BSONObj? Not sure. - CachedBSONObj<2048> execStats; + CachedBSONObj<4096> execStats; // error handling ExceptionInfo exceptionInfo; diff --git a/src/mongo/db/query/new_find.cpp b/src/mongo/db/query/new_find.cpp index eb89a1137f8..6c309be0aaa 100644 --- a/src/mongo/db/query/new_find.cpp +++ b/src/mongo/db/query/new_find.cpp @@ -769,6 +769,14 @@ namespace mongo { // execStats is a CachedBSONObj because it lives in the race-prone // curop. curop.debug().execStats.set(explain->stats); + + // Replace exec stats with plan summary if stats cannot fit into CachedBSONObj. + if (curop.debug().execStats.tooBig() && !curop.debug().planSummary.empty()) { + BSONObjBuilder bob; + bob.append("summary", curop.debug().planSummary.toString()); + curop.debug().execStats.set(bob.done()); + } + } } |