-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Summary
jstest matrix + parser-invariant spec for SERVER-124369: replacement-style update documents containing a $diff field are misparsed as delta updates during oplog application. Same class of bug recurs on schema additions of reserved field names.
Files
- jstests/replsets/oplog_update_reserved_field_names.js (154 lines) — 2-node replset; for each token in {$diff, $set, $unset, $v, $rename, $inc} inserts a seed doc, issues replaceOne() with the token as a top-level field carrying a syntactically-valid modifier value, then asserts three things: (1) primary preserves the field literally, (2) the recorded oplog entry has op:"u" with o matching the replacement byte-for-byte and lacks $v: 2, (3) secondary converges via docEq. Plus nested-token and all-tokens-combined cases.
- src/mongo/db/repl/UPDATE_FIELD_NAME_PARSER_INVARIANT.md (~513 words) — states the invariant (discriminate by $v value, never by reserved-name presence on the replacement branch), explains why (legal user data, recurrence on schema additions), pins the parser site as internal_apply_oplog_update_stage.cpp:64 → write_ops::UpdateModification::parseFromOplogEntry, with a secondary site in oplog.cpp, and proposes a C++ regression test next to parseFromOplogEntry paired with the jstest.
Verify
- node --input-type=module --check on the jstest: clean.
Cross-reference
v2 delta shape {$v: 2, diff: {...}} confirmed by jstests/replsets/oplog_format.js (line 46+); the invariant aligns with the established format.