azureazure-sql-databaseazure-elastic-scale

Adding new shard - Azure Elastics Scale


I was facing trouble creating a new shard for our system. I have an already sharded database, with two shards.

0-280000
280000-inf

I am using the this application provided by Microsoft.

Using the above app I select add shard and when I try to add a new shard and input 400000 as the new high key, performs the operations and at the very end when it tries to add range mapping, I am getting the following error.

ERROR

{"Mapping referencing shard '[DataSource=xxxxxxxxxxxxxx Database=xxxxxx]' in the shard map 'UserID' cannot be added because the Range it covers is already mapped by another mapping. Error occurred while executing stored procedure '__ShardManagement.spBulkOperationShardMappingsGlobalBegin' for operation 'AddRangeMapping'. This can occur if another concurrent user has already added a mapping covering the given Range."}

Any help in this regard will be highly appreciated.


Solution

  • If your second shard is actually 280000-inf, with inf meaning infinity then the error you are receiving is correct. The second shard already contains mappings for 400000. Instead of adding a shard, you need to split the second shard. Check out the split-merge tool instead.