[SERVER-15282] Collection is not replicated to the secondary if the collection is created by adding the index on _id field Created: 17/Sep/14  Updated: 22/May/15  Resolved: 22/May/15

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: 2.6.4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Linda Qin Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-13750 ConvertToCapped on empty collection a... Closed
Operating System: ALL
Steps To Reproduce:
  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()
    [ ]

Participants:

 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
    }



 Comments   
Comment by Geert Bosch [ 22/May/15 ]

This got fixed as result of other 3.0 work.

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