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

Creating an index on system.indexes breaks initial sync of secondary

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.4.10, 2.5.3
    • Affects Version/s: 2.4.5
    • Component/s: Replication
    • None
    • Minor Change
    • ALL

      Issue Status as of March 28, 2014

      ISSUE SUMMARY
      Indexes cannot be created on the internal system.indexes collection. Attempting to build an index on this collection responds with an error (code 13143), but still inserts a corresponding entry into the system.indexes collection. Secondary nodes that attempt to initial sync from a node with such an entry fail to create the index and abort the initial sync (after several retries).

      USER IMPACT
      This mostly affects users that create indexes dynamically on all collections and do not explicitly exclude the system.indexes collection. Furthermore, the error may not be noticed for some time, as the invalid index has no immediate effect on a replica set but only affects initial sync of a secondary.

      SOLUTION
      The fix is to explicitly check and throw an assertion if an index build on system.indexes is attempted. This assertion aborts the index build before the entry is inserted into the system.indexes collection.

      WORKAROUNDS
      Users should not build an index on the system.indexes collection. In environments with dynamic index creation, one should take precautionary steps to explicitly check and avoid building an index on system.indexes. To remove any accidentally-created index entries on system.indexes, use the following command: db.system.indexes.dropIndexes()

      AFFECTED VERSIONS
      All recent production releases up to version 2.4.9 are affected.

      PATCHES
      The fix is included in the 2.4.10 production release and the 2.5.3 development version, which will evolve into the 2.6.0 production release.

      Original Description

      It claims it isn't allowed, but it still gets inserted into system.indexes without actually creating the index.

      > use breakMyDb
      switched to db breakMyDb
      > db.system.indexes.ensureIndex({_id:1}, {unique:true})
      {
              "err" : "can't create index on system.indexes",
              "code" : 13143,
              "n" : 0,
              "connectionId" : 1,
              "ok" : 1
      }
      > db.system.indexes.find()
      { "v" : 1, "key" : { "_id" : 1 }, "ns" : "breakMyDb.system.indexes", "name" : "_id_" }
      

            Assignee:
            matt.dannenberg Matt Dannenberg
            Reporter:
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: