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

Collection is not replicated to the secondary if the collection is created by adding the index on _id field

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Gone away
    • 2.6.4
    • None
    • Storage
    • None
    • ALL
    • Hide
      1. Start a replica set
      2. Create _id index on a non-existing collection the primary:

        > show tables
        > db.docs.ensureIndex({_id:1})
        {
        	"createdCollectionAutomatically" : true,
        	"numIndexesBefore" : 1,
        	"note" : "index already exists",
        	"numIndexesAfter" : 1,
        	"ok" : 1
        }
        > db.getCollectionNames()
        [ "docs", "system.indexes" ]

      3. Check the secondary:

        > rs.slaveOk()
        > db.getCollectionNames()
        [ ]

      Show
      Start a replica set Create _id index on a non-existing collection the primary: > show tables > db.docs.ensureIndex({_id:1}) { "createdCollectionAutomatically" : true, "numIndexesBefore" : 1, "note" : "index already exists", "numIndexesAfter" : 1, "ok" : 1 } > db.getCollectionNames() [ "docs", "system.indexes" ] Check the secondary: > rs.slaveOk() > db.getCollectionNames() [ ]

    Description

      This issue happens on both 2.4 and 2.6.

      This behaviour may not cause issues in 2.4. However, in 2.6, looks like the implementation of convertToCapped is changed, and the missing collection could cause issues when trying to convert this collection to a capped collection on the primary.

      In 2.6.0/2.6.1, the secondaries would hit SERVER-13750 and abort.

      Since 2.6.2, the secondaries would not abort, however it would fail to apply the convertToCapped operation.

      2014-09-17T14:38:37.000+1000 [repl writer worker 1] warning: repl Failed command { convertToCapped: "docs", size: 10000.0 } on test with status NamespaceNotFound source collection test.docs does not exist during oplog application

      Then if we add a document to this collection on the primary, the write operation could be replicated to the secondaries successfully. However, the collection would be a capped collection on the primary, while the same collection on the secondaries are not capped collections:

      • Primary:

        > db.docs.stats()
        {
        	"ns" : "test.docs",
        	"count" : 1,
        	"size" : 36,
        	"avgObjSize" : 36,
        	"storageSize" : 12288,
        	"numExtents" : 1,
        	"nindexes" : 1,
        	"lastExtentSize" : 12288,
        	"paddingFactor" : 1,
        	"systemFlags" : 1,
        	"userFlags" : 0,
        	"totalIndexSize" : 8176,
        	"indexSizes" : {
        		"_id_" : 8176
        	},
        	"capped" : true,
        	"max" : NumberLong("9223372036854775807"),
        	"ok" : 1
        }

      • Secondary:

        > db.docs.stats()
        {
        	"ns" : "test.docs",
        	"count" : 1,
        	"size" : 48,
        	"avgObjSize" : 48,
        	"storageSize" : 8192,
        	"numExtents" : 1,
        	"nindexes" : 1,
        	"lastExtentSize" : 8192,
        	"paddingFactor" : 1,
        	"systemFlags" : 1,
        	"userFlags" : 1,
        	"totalIndexSize" : 8176,
        	"indexSizes" : {
        		"_id_" : 8176
        	},
        	"ok" : 1
        }

      Attachments

        Issue Links

          Activity

            People

              mathias@mongodb.com Mathias Stearn
              linda.qin@mongodb.com Linda Qin
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: