Search code examples
mongodbsharding

Using mongo updateZoneKeyRange to reduce a zone range


I'm trying to update an existing zone's range named hot from

{ "id" : 1507520572 }, { "id" : { "$maxKey" : 1 }

using

sh.updateZoneKeyRange('db.collection', { id: 1507520572 }, { id: 9999999999 }, 'hot'),

but I'm getting the error

Zone range: { id: 1507520572.0 } -->> { id: 9999999999.0 } on hot is overlapping with existing: { id: 1507520572 } -->> { id: MaxKey } on hot.

My plan is to then create a new zone from 9999999999 to MaxKey. How can I achieve this?


Solution

  • I had to remove the previous range first with

    db.runCommand({ updateZoneKeyRange: 'db.collection', min: {id: 1507520572}, max: {id: MaxKey}, zone: null }),

    then it let me create the new ranges.