|
When a command fails by propagating a Status return value, the mongod service entry point calls incrementCommandsFailed():
https://github.com/mongodb/mongo/blob/da5520555faef9a2ba9b6c9ec80539ae95ad88a5/src/mongo/db/service_entry_point_mongod.cpp#L720-L722
No analogous call exists in the service entry point's DBException handler. You can observe this by comparing a failed aggregate command, which fails by throwing, to a failed find command, which fails by Status:
// Expects to be run against a freshly-started mongod.
|
db.c.drop();
|
assert.writeOK(db.c.insert({}));
|
|
// This succeeds, since failed find commands are counted correctly.
|
db.c.find().hint({bad: 1});
|
assert.eq(1, db.serverStatus().metrics.commands.find.failed);
|
|
// This fails: failed aggregate commands are not counted correctly.
|
db.c.aggregate([{$project: {a: {$div: ["$a", 0]}}}]);
|
assert.eq(1, db.serverStatus().metrics.commands.aggregate.failed);
|
|