[SERVER-24883] Initial sync creates _id index even if collection does not have one Created: 01/Jul/16  Updated: 19/Dec/16  Resolved: 06/Jul/16

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 3.3.10

Type: Bug Priority: Major - P3
Reporter: Judah Schvimer Assignee: Judah Schvimer
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-24538 Make small_oplog_rs_initsync_static p... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.2
Steps To Reproduce:

var name = 'initial_sync_index_creation';
var replSet = new ReplSetTest({
    name: name,
    nodes: 1,
});
 
replSet.startSet();
replSet.initiate();
var primary = replSet.getPrimary();
 
primary.getDB('test').runCommand({create:'foo', autoIndexId:false})
primary.getDB('test').foo.insert({a:1})
assert.eq(primary.getDB('test').foo.getIndexes().length, 0);
 
// Add a secondary node but make it hang before copying databases.
var secondary = replSet.add();
secondary.setSlaveOk();
replSet.reInitiate();
replSet.awaitSecondaryNodes(200 * 1000);
 
assert.eq(primary.getDB('test').foo.getIndexes().length, 0);
assert.eq(primary.getDB('test').foo.count(), 1);
assert.eq(secondary.getDB('test').foo.count(), 1);
assert.eq(secondary.getDB('test').foo.getIndexes().length, 0);

Sprint: Repl 17 (07/15/16)
Participants:

 Description   

If you create an index with autoIdIndex: false and then initial sync a node off of that it will still create the _id index.



 Comments   
Comment by Githook User [ 06/Jul/16 ]

Author:

{u'username': u'judahschvimer', u'name': u'Judah Schvimer', u'email': u'judah@mongodb.com'}

Message: SERVER-24883 cloner should not create _id index when original collection doesn't have one
Branch: master
https://github.com/mongodb/mongo/commit/b3611e663fb40505340589fd75fa5d504829c609

Comment by Judah Schvimer [ 05/Jul/16 ]

This is actually an issue for the cloner in general and can be reproduced with copyDatabase:

var conn = MongoRunner.runMongod({});
var test = conn.getDB('test');
test.runCommand({create:'foo', autoIndexId:false});
test.foo.insert({a:1});
assert.eq(test.foo.getIndexes().length, 0);
test.copyDatabase('test', 'test2');
var test2 = conn.getDB('test2');
assert.eq(test.foo.count(), 1);
assert.eq(test.foo.getIndexes().length, 0);
assert.eq(test2.foo.count(), 1);
assert.eq(test2.foo.getIndexes().length, 0);

Comment by Andy Schwerin [ 03/Jul/16 ]

Hmmm, autoId:false with replication is prohibited, I thought. Didn't we deprecate it some time ago?

Comment by Daniel Pasette (Inactive) [ 02/Jul/16 ]

I thought that is intentional.

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