Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-24883

Initial sync creates _id index even if collection does not have one

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.10
    • Affects Version/s: None
    • Component/s: Replication
    • None
    • Fully Compatible
    • ALL
    • v3.2
    • Hide
      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);
      
      Show
      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);
    • Repl 17 (07/15/16)

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

            Assignee:
            judah.schvimer@mongodb.com Judah Schvimer
            Reporter:
            judah.schvimer@mongodb.com Judah Schvimer
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: