SERVER-127007 Add server status metric for path arrayness invalidation (#54071)
GitOrigin-RevId: 4ffd1618d653049063090c7f61bc2e9763a9ae65
This commit is contained in:
parent
ca9ea08b23
commit
005ea9599c
@ -40,6 +40,7 @@ function setupColl(name) {
|
||||
const kKilledMsg = "non-array path became multikey during yield";
|
||||
|
||||
function runPhases({runQuery, isWriteCmd}) {
|
||||
const before = db.adminCommand({serverStatus: 1}).metrics.query.pathArrayness.queriesFailedDueToInvalidation;
|
||||
const fp = configureFailPoint(db, "pathArraynessYieldInvalidation", {}, {times: 1});
|
||||
try {
|
||||
// Verify query is killed with the path-arrayness invalidation message.
|
||||
@ -55,6 +56,8 @@ function runPhases({runQuery, isWriteCmd}) {
|
||||
} finally {
|
||||
fp.off();
|
||||
}
|
||||
const after = db.adminCommand({serverStatus: 1}).metrics.query.pathArrayness.queriesFailedDueToInvalidation;
|
||||
assert.eq(after, before + 1, "expected invalidation counter to be incremented", {before, after});
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@ -71,6 +71,9 @@ function runTest({testCase, setParameters, expect}) {
|
||||
const fp = configureFailPoint(testDb, "setYieldAllLocksHang", {namespace: coll.getFullName()});
|
||||
|
||||
try {
|
||||
const before = testDb.adminCommand({serverStatus: 1}).metrics.query.pathArrayness
|
||||
.queriesFailedDueToInvalidation;
|
||||
|
||||
let awaitShell = startParallelShell(
|
||||
funWithArgs(
|
||||
function (dbName, collName, pipeline, aggOptions, expect) {
|
||||
@ -110,6 +113,14 @@ function runTest({testCase, setParameters, expect}) {
|
||||
|
||||
fp.off();
|
||||
awaitShell();
|
||||
|
||||
const after = testDb.adminCommand({serverStatus: 1}).metrics.query.pathArrayness.queriesFailedDueToInvalidation;
|
||||
const expectedDelta = expect === "killed" ? 1 : 0;
|
||||
assert.eq(after - before, expectedDelta, "expected invalidation counter change to be " + expectedDelta, {
|
||||
before,
|
||||
after,
|
||||
expect,
|
||||
});
|
||||
} finally {
|
||||
fp.off();
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@ mongo_cc_library(
|
||||
"//src/mongo:base",
|
||||
"//src/mongo/db:common",
|
||||
"//src/mongo/db/commands/server_status:server_status_core",
|
||||
"//src/mongo/db/commands/server_status:server_status_metric",
|
||||
"//src/mongo/db/pipeline:field_path",
|
||||
"//src/mongo/db/query/query_knobs:query_knob_configuration",
|
||||
"//src/mongo/db/query/query_settings",
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
|
||||
#include "mongo/db/query/compiler/metadata/path_arrayness.h"
|
||||
|
||||
#include "mongo/db/commands/server_status/server_status_metric.h"
|
||||
#include "mongo/db/namespace_string.h"
|
||||
#include "mongo/db/pipeline/expression_context.h"
|
||||
#include "mongo/logv2/log.h"
|
||||
@ -44,6 +45,9 @@ MONGO_FAIL_POINT_DEFINE(pathArraynessYieldInvalidation);
|
||||
|
||||
namespace mongo {
|
||||
|
||||
auto& pathArraynessQueriesFailedDueToInvalidation =
|
||||
*MetricBuilder<Counter64>{"query.pathArrayness.queriesFailedDueToInvalidation"};
|
||||
|
||||
const PathArrayness& PathArrayness::emptyPathArrayness() {
|
||||
static const PathArrayness kEmptyPathArrayness;
|
||||
return kEmptyPathArrayness;
|
||||
@ -220,6 +224,7 @@ boost::optional<FieldPath> PathArrayness::getFirstInvalidatedPath(
|
||||
void PathArraynessChecker::uassertIfInvalidated(const PathArrayness& current,
|
||||
const NamespaceString& ns) {
|
||||
if (auto invalidated = PathArrayness::getFirstInvalidatedPath(nonArrayPaths, current)) {
|
||||
pathArraynessQueriesFailedDueToInvalidation.increment();
|
||||
uasserted(
|
||||
ErrorCodes::QueryPlanKilled,
|
||||
str::stream() << "query plan killed :: non-array path became multikey during yield: "
|
||||
|
||||
Loading…
Reference in New Issue
Block a user