[SERVER-13976] Cloner needs to detect failure to create collection Created: 16/May/14  Updated: 11/Jul/16  Resolved: 19/May/14

Status: Closed
Project: Core Server
Component/s: Replication, Storage
Affects Version/s: 2.6.1, 2.7.0
Fix Version/s: 2.6.2, 2.7.1

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

Issue Links:
Depends
Duplicate
is duplicated by SERVER-13927 Copydb breaks on (some) capped collec... Closed
Related
related to SERVER-13968 Report invalid collection options in ... Closed
Operating System: ALL
Backport Completed:
Participants:

 Description   
Issue Status as of May 30, 2014

ISSUE SUMMARY
When a collection contains invalid options, cloning it will result in a collection created with default options. As a result, collections with invalid options created by an initial sync or using the copyDatabase command may lose some of their properties like their allocation strategy, or become non-capped collections.

USER IMPACT
Different members on a replica set might become out of sync when capped collections become non-capped during initial sync. In this scenario, or when the original storage strategy for a cloned collection is modified, storage utilization may be adversely affected. Only collections created with invalid options are affected by this issue.

WORKAROUNDS
N/A

AFFECTED VERSIONS
MongoDB production releases 2.6.0 and 2.6.1 are affected by this issue.

FIX VERSION
The fix is included in the 2.6.2 production release.

RESOLUTION DETAILS
Collections with invalid options are no longer cloned.

Original description

Cloner::go() proceeds with a collection copy even if the call to userCreateNS() fails, in which case the collection is created with default options (by the insert of the first document). As a result, collections created by an initial sync or the copydb command can lose their cappedness or allocation strategy.

Reproduce by creating a collection with invalid options in 2.4.10:

> db.version()
2.4.10
> db.runCommand({create: "foo", capped: true, size: 1024*1024, max: "foobar"})
{ "ok" : 1 }
> db.foo.insert({})
Cannot use commands write mode, degrading to compatibility mode
WriteResult({ "nInserted" : 1 })

And then upgrading to 2.6.1 and attempting to use copydb:

> db.version()
2.6.1
> db.copyDatabase("test","test2")
{ "ok" : 1 }
> db.system.namespaces.find()
{ "name" : "test.system.indexes" }
{ "name" : "test.foo.$_id_" }
{ "name" : "test.foo", "options" : { "create" : "foo", "capped" : true, "size" : 1048576, "max" : "foobar" } }
> db.foo.stats().capped
true
> db.getSiblingDB("test2").system.namespaces.find()
{ "name" : "test2.foo" } // INCORRECT: "foo" is no longer capped
{ "name" : "test2.system.indexes" }
{ "name" : "test2.foo.$_id_" }
> db.getSiblingDB("test2").foo.stats().capped
>



 Comments   
Comment by Githook User [ 24/May/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-13976 Cloner::go() fail fast if any collection has bad options

(cherry picked from commit 7fced83ca52d18991b2729e2e518248b9e7c7887)
Branch: v2.6
https://github.com/mongodb/mongo/commit/57bd9bd1d6f4903d78be8a8d106a2fae2a628be7

Comment by Githook User [ 24/May/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-13976 Cloner::go() should check return value of userCreateNS

(cherry picked from commit f89e280ef9946edf1904ffb91751461554be78b9)

Conflicts:
src/mongo/db/cloner.cpp
Branch: v2.6
https://github.com/mongodb/mongo/commit/c86d218c92820da50d97849af2c057498d6c7283

Comment by Ramon Fernandez Marina [ 20/May/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-13976 Cloner::go() should check return value of userCreateNS

Branch: master
https://github.com/mongodb/mongo/commit/f89e280ef9946edf1904ffb91751461554be78b9

Comment by Ramon Fernandez Marina [ 20/May/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-13976 Cloner::go() fail fast if any collection has bad options

Branch: master
https://github.com/mongodb/mongo/commit/7fced83ca52d18991b2729e2e518248b9e7c7887

Generated at Thu Feb 08 03:33:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.