-
Type:
Task
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Query Execution
-
None
-
Query Integration
-
Fully Compatible
-
QI 2025-02-17
-
0
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
- What this PR does
Makes the delete-metric assertions in `jstests/noPassthrough/query/queryStats/query_stats_delete_cmd_metrics.js` robust to spurious `WriteConflictException`s on debug builds.
- Adds `retryDeleteMetricTestOnWriteConflict(ctxFn, testFn, maxAttempts = 5)` to `jstests/libs/query/query_stats_write_cmd_utils.js`. It resets the collection and query stats store, runs the caller's exact-metric assertion, and retries (up to `maxAttempts`) until an execution passes; if all attempts fail it rethrows the last error.
- Wraps the five replica-set delete-metric cases (`single`, `_id`, `multi`, `no matches`, `partial success`) in that helper.
The `docsExamined` expectations stay exact, and the sharded path is untouched.
-
- Motivation
The test asserts `docsExamined` exactly. On debug builds a spurious `WriteConflictException` re-runs the delete's COLLSCAN, nondeterministically inflating `docsExamined` above its true value (e.g. an expected sum of 8 was recorded as 11), causing a rare one-off failure.
Per-op accounting was ruled out: the operation's `writeConflicts` counter does not track these command-level retries (observed 3 conflicts producing 14 extra examinations, and a run with 16 examined but 0 recorded conflicts), so the count cannot be corrected arithmetically. Retrying until a clean execution keeps the assertions exact — a genuine regression produces the wrong value on every attempt and still fails once retries are exhausted.
-
- Reviewer reading guide
- Start with `jstests/libs/query/query_stats_write_cmd_utils.js` for the new `retryDeleteMetricTestOnWriteConflict` helper.
- Then `jstests/noPassthrough/query/queryStats/query_stats_delete_cmd_metrics.js` — the five replica-set `it()` bodies now call the helper; the metric expectations are unchanged.
-
- Caveats
- Only the replica-set delete cases are wrapped; the sharded suite uses a different fixture and its own `docsExamined` tolerance and is left as-is.
- The title is prefixed `SERVER-XXX` because no ticket exists yet — a bot will file one and replace it.
- related to
-
SERVER-121266 Query stats double-counts execCount for retried retryable writes
-
- Open
-
-
SERVER-132226 Protect query_stats_delete_cmd_metrics.js against spurious write failures in sharded cases
-
- Closed
-