Azure / Azure/elastic-db-tools

DetectMappingDifferences - The length of raw value specified for the shard key does not match the expected length

Open
#204 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
147
Forks
108
PR merge metrics
No merged PRs in 30d

Description

We have a shard map using long (Int64) as the shard key and in the event of a failover we do a DetachShard and AttachShard operation which works fine but then when we call RecoveryManager.DetectMappingDifferences it fails with the following exception:

System.ArgumentOutOfRangeException: 'The length of raw value specified for the shard key (4 bytes) does not match the expected length (8 bytes) for the ShardKeyType (Int64) specified.
Parameter name: rawValue
Actual value was System.Byte[].'

This is actually failing when iterating through lsmMappings.StoreMappings and the attempted creation of the ShardKey. The call to ShardKey.FromRawValue is failing because the lsmMapping.MinValue is being populated with a byte array of length 4 instead of 8.

I'm not sure what to do here as we have no control over the population of lsmMappings and its not coming back populated with the correct type of array.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at RecoveryManager.DetectMappingDifferences and trace its iteration over lsmMappings.StoreMappings. Inspect how lsmMapping.MinValue reaches ShardKey.FromRawValue after DetachShard and AttachShard with an Int64 shard key, then reproduce the reported exception. Done means DetectMappingDifferences handles the resulting mappings without the raw-value length error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.