-
Type: Bug
-
Resolution: Duplicate
-
Priority: Critical - P2
-
None
-
Affects Version/s: 3.1.1
-
Component/s: Replication
-
Storage Execution
-
ALL
-
Repl 2016-11-21
If an applyOps command is run with some valid ops and some invalid ops, the valid ones can be actually applied, but then the applyOps fails and no oplog entries are generated for the writes performed as part of the valid ops.
The manifestation of the bug is a result of the change from SERVER-17634, so it only affects 3.1.1+.
Server output:
[repl writer worker 0] writer worker caught exception: :: caused by :: 26 Failed to apply insert due to missing collection: { ts: Timestamp 1438736773000|1, h: 2778434085248541821, v: 2, op: "i", ns: "test.foo", o: { _id: ObjectId('55c1618530cd6c7ac35af4b7') } } on: { ts: Timestamp 1438736773000|1, h: 2778434085248541821, v: 2, op: "i", ns: "test.foo", o: { _id: ObjectId('55c1618530cd6c7ac35af4b7') } } [repl writer worker 0] Fatal Assertion 16360 [repl writer worker 0] ***aborting after fassert() failure
Repro script:
// Start up a replica set with at least one secondary var rst = new ReplSetTest({nodes: 2}); rst.startSet(); rst.initiate(); var t = rst.getPrimary().getDB('test').foo; t.drop(); var ops = [ // The first op is valid and results in one document being written to 'test.foo' {op: 'u', ns: t.getFullName(), o2: {_id: 0}}, // The second op is invalid {op: 'f', ns: t.getFullName(), o2: {}} ]; // The command fails, but a 'test.foo' collection is created on the primary and a document is inserted into the collection. // A 'test.foo' collection is not created on the secondary because the update op is not written to the oplog. t.runCommand({applyOps: ops}); // This follow-up insert will cause an fassert on the secondary: // 'Failed to apply insert due to missing collection' t.insert({}); rst.awaitReplication(); rst.stopSet();
- duplicates
-
SERVER-28594 non-atomic applyOps should log each individual op
- Closed
- is related to
-
SERVER-23390 Missing collection during replication causes shutdown
- Closed
-
SERVER-17634 do not apply replicated insert operations on missing collections
- Closed
- related to
-
SERVER-23326 applyOps should use a single WriteUnitOfWork where possible
- Closed
-
SERVER-25994 Allow applyOps to validate authorization permissions at the operation level
- Closed