Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-15976

[Server] Document `mergeAllChunksOnShard` command

      Starting from v7.0, the mergeAllChunksOnShard command is available on routers.

      The command take care of squashing at once all "mergeable" chunks that a shard owns for a given collection.

      Definition or mergeable chunks

      Two or more contiguous non-jumbo chunks belonging to the same collection are going to be considered mergeable when they are owned by the same shard and their history can be safely purged without breaking transactions and snapshot reads.

      Technically, this means that each chunk is required to fulfill the following conditions to be mergeable:

      Jumbo chunks are not considered mergeable because they cannot participate in migrations.

      Parameters of the command

      The command is accepting the following parameters:

      • shard: the name of the shard
      • maxNumberOfChunksToMerge [optional]: the maximum number of chunks to merge (this argument can be used in case of a huge number of chunks residing on the same shard for a collection in order not to merge too many chunks in one shot).

      Example

      NB: the following example assumes that history is empty for all chunks and no chunk is flagged as jumbo, so all contiguous intervals belonging to the same shard are mergeable.

      Let's considering the following portion of chunks belonging to a collection coll with shard key x:

      Chunk ID MIN MAX SHARD
      A x: 0 x: 10 Shard0
      B x: 10 x: 20 Shard0
      C x: 20 x: 30 Shard0
      D x: 30 x: 40 Shard0
      E x: 40 x: 50 Shard1
      F x: 50 x: 60 Shard1
      G x: 60 x: 70 Shard0
      H x: 70 x: 80 Shard0
      I x: 80 x: 90 Shard1
      • Invoking coll.mergeAllChunksOnShard({shard: "Shard0"}) will result in merging the contiguous sequences of chunks A-B-C-D and G-H.
      • Invoking coll.mergeAllChunksOnShard({shard: "Shard1"}) will result in merging the contiguous sequence of chunks E-F.

      The chunks for coll after invoking the 2 above-mentioned commands will look like this:

      Chunk ID MIN MAX SHARD
      A-B-C-D x: 0 x: 40 Shard0
      E-F x: 40 x: 60 Shard1
      G-H x: 60 x: 80 Shard0
      I x: 80 x: 90 Shard1

            Assignee:
            joseph.dougherty@mongodb.com Joseph Dougherty
            Reporter:
            pierlauro.sciarelli@mongodb.com Pierlauro Sciarelli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              1 year, 4 weeks, 1 day ago