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

mergeChunk command fails if there isn't an index that exactly matches the shard key

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.4
    • Component/s: Sharding
    • None
    • ALL
    • Hide

      The steps to reproduce this error are:

      1. Ensure the index {a: 1, b:1}

        on some collection

      2. Shard it on {a:1}
      3. Execute sh.splitAt a few times to force some empty chunks
      4. Try to merge any two contiguous chunks. The error will occur.
      5. If the index {a:1}

        is ensured, the mergeChunk functions correctly.

      I've attached an script that reproduces these steps and forces this error to occur. To execute it:

      1. Create a sharded environment using mtools (mlaunch init --sharded 1 --single --port 60000)
      2. Execute it with mongo localhost:60000 force-empty-chunks-merge-error.js
      Show
      The steps to reproduce this error are: Ensure the index {a: 1, b:1} on some collection Shard it on {a:1} Execute sh.splitAt a few times to force some empty chunks Try to merge any two contiguous chunks. The error will occur. If the index {a:1} is ensured, the mergeChunk functions correctly. I've attached an script that reproduces these steps and forces this error to occur. To execute it: Create a sharded environment using mtools (mlaunch init --sharded 1 --single --port 60000) Execute it with mongo localhost:60000 force-empty-chunks-merge-error.js

      The mergeChunk command fails if the sharded collection does not have an index that exactly matches the shard key, but has one or more indexes that have the shard key as its prefix.

      The error message is something like this:

      {
      	"ok" : 0,
      	"errmsg" : "could not merge chunks, could not count docs in database.collection :: caused by :: 13106 nextSafe(): { $err: \"Unable to execute query: error processing query: ns=database.collection limit=1 skip=0\nTree: $and\nSort: {}\nProj: {}\n planner returned error: unable to fin...\", code: 17007 }"
      }
      

      Apparently, the query planner is unable to find a relevant index in this situation.

            Assignee:
            randolph@mongodb.com Randolph Tan
            Reporter:
            danielgalinkin@gmail.com Daniel Galinkin
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: