3

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.

Joseph Idziorek
  • 4,853
  • 6
  • 23
  • 37
imrn
  • 297
  • 2
  • 12

1 Answers1

5

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.

MikeWo
  • 10,887
  • 1
  • 38
  • 44
  • Removed my previous comment. Yes, that was the problem you mentioned. I updated the Max value in __shardmanagement.ShardMappingsGlobal and __shardmanagement.ShardMappingsLocal. Then I tried to run the app and it completed all the steps successfully. – imrn Oct 16 '15 at 15:18
  • 1
    The Split-Merge tool is the correct approach if you already have data in the the shard in that range which needs to be moved - the primary purpose of the Split-Merge tool is to move data. If no data needs to be moved then you can just use the `RangeShardMap.SplitMapping` method to split the mapping https://msdn.microsoft.com/en-us/library/azure/dn823939.aspx – Jared Moore Oct 17 '15 at 18:35