[SERVER-26887] Idempotency of createCollection with options Created: 02/Nov/16  Updated: 25/Jan/17  Resolved: 11/Nov/16

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: 3.4.0-rc2
Fix Version/s: 3.4.0-rc4

Type: Bug Priority: Major - P3
Reporter: Siyuan Zhou Assignee: Siyuan Zhou
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
is depended on by SERVER-25332 Initial sync bootstrap needs to handl... Closed
Related
related to SERVER-23849 Add collection default collation to t... Closed
related to SERVER-26514 Create command should take idIndex op... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.2
Sprint: Repl 2016-11-21
Participants:

 Description   

In oplog application, we ignore the NamespaceExists error returned by createCollection if the collection with the same name but different options already exists.

Most options of createCollection don't affect the semantic of operations on secondaries, like the following (capped collection related are omitted here):
1. usePowerOf2Sizes
2. noPadding
3. storageEngine
4. validation related
5. indexOptionDefaults

However, in 3.4, we added two options that affect the behavior of operations on secondaries.
1. collation in SERVER-23849
2. idIndex in SERVER-26514

collation option
The first one can cause the reapplication of insert lead to different data than the first application because a case-insensitive _id index is created later.

createCollection with no collation
insert { _id: "foo" }
insert { _id: "FOO", x: 1 }
update { _id: "foo" }, { $set: { x: 2 } }
dropCollection
createCollection with case-insensitive _id index

Reapplication of the previous sequence of operations will overwrite the document { id: "foo" }.

In the other case, if the _id index changes from case-insensitive to case-sensitive, an expected document will be considered missing. However, the missing or duplicated document in this inconsistent period is fine because the collection must be dropped later.

idIndex option
The second option about idIndex is to set the correct featureCompatibilityVersion. The insertion of decimal will return an error.

createCollection with v: 2, meaning featureCompatibilityVersion: 3.4
insert decimal
dropCollection
createCollection with v:1, meaning featureCompatibilityVersion: 3.2

The reapplication of these sequence will crash the server because of inserting decimal into 3.2 index.

viewOn and pipeline
If the expected collection doesn't exist because we're in an inconsistent state, the application will fail.

The collection life cycle project will fix all these issues. Another solution is to drop the existing collection if createCollection sees an existing one with the same name.



 Comments   
Comment by Githook User [ 11/Nov/16 ]

Author:

{u'username': u'visualzhou', u'name': u'Siyuan Zhou', u'email': u'siyuan.zhou@mongodb.com'}

Message: SERVER-26887 Idempotency of createCollection with options
Branch: master
https://github.com/mongodb/mongo/commit/3592a98bd198bd7f5a657e7bf5b9c34451c3de6b

Generated at Thu Feb 08 04:13:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.