-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
(copied to CRM)
-
None
-
None
-
None
-
None
-
None
-
None
-
None
PlanExecutor is a key interface used to execute all CRUD statements (except for insert). It's used for find and aggregate commands, for findAndModify commands, and for every update/delete statement in an update, delete, or bulkWrite operation.
For a very long time, the server has logged a warning to the diagnostic logs whenever a PlanExecutor fails. This goes back at least to SERVER-41996 in version 4.3, a change that unified various code paths for read commands to log a warning when the PlanExecutor indicated a failure. At the time, this was probably just fine – read commands are less likely to fail at high rates, and there may be some utility to seeing the error information in the logs.
The PlanExecutor interface later evolved to error by throwing DBException (SERVER-43821). SERVER-92126 then consolidated the code paths used by the various write statements so that they used the PlanExecutor interface in the same way. These code changes retained the logging of warnings. We are now in a state in which any error produced from a PlanExecutor from any non-insert read or write operation will result in a logged warning at the default log verbosity settings. Moreover, there is not trivial way to suppress these warnings.
Sometimes these warnings could be useful, if the error is unusual or unexpected. There have even been recent suggestions to expand the logging: see SERVER-116094. However, there are many common errors which are not evidence of an operational issue or are expected due to the design of the application. One example is WriteConflictException, for which we made a specialized fix in SERVER-74551. Other examples are DuplicateKey (an issue that was previously observed but not fixed in SERVER-80317) and WouldChangeOwningShard (SERVER-98032). These common errors spamming the logs as warnings is a bad customer experience when nothing in the system is actually amiss.
The DuplicateKey case is particularly common, and it got worse in 9.0.x versions. In 8.0.x, we happened to log DuplicateKey warnings from the findAndModify and bulkWrite commands, but not the update command. In 9.0.x as a consequence of an unrelated refactor, we log DuplicateKey warnings for the update command in the same way as the other write statements.
This ticket proposes fixing this class of log spamminess issues for all CRUD statement types once and for all. There are a few approaches we could take:
- Simply change the warnings to log at debug level 1. Users who wish to see this information can increase the log level for the WRITE or QUERY log components to 1. The downside is that real deployments rarely run at elevated log levels for long. However, the recent in-progress work to include error code information in $queryStats could be useful for diagnostics in the cases where these log messages were previously found useful (cc erin.liang@mongodb.com). A future implementation of SERVER-65093 would also help (e.g. if we start seeing a spike of a specific error code during an incident).
- Introduce a more fine-grained switch which controls this logging, but is off by default. It could be a setParameter or even a PQS setting.
- A narrow fix which suppresses these log messages for DuplicateKey in particular. My worry is that a new error case like this will crop up and we will end up playing whack-a-mole.
- Try to categorize errors into two categories: "expected, shouldn't be logged" and "unexpected, should be logged". This also seems somewhat fragile.
- is related to
-
SERVER-74551 WriteConflictException unnecessarily logged as warning during findAndModify after upgrade to mongo 5.0
-
- Closed
-
-
SERVER-80317 DuplicateKey error message is logged from findAndModify after 5.0 upgrade
-
- Closed
-
-
SERVER-65093 Count operation failures in serverStatus broken down by error code
-
- Open
-
-
SERVER-116094 Include originating command to "Plan executor error" log in case of writes.
-
- Backlog
-
-
SERVER-41996 Improve PlanExecutor error logging
-
- Closed
-
-
SERVER-43821 Fail in query execution by throwing rather than the FAILURE state code
-
- Closed
-
-
SERVER-92126 Consolidate functions used for iterating PlanExecutor in bulkWrite update statements and update command
-
- Closed
-
-
SERVER-98032 Suppress WouldChangeOwningShard warnings by default
-
- Closed
-