Azure / Azure/elastic-db-tools

ShardKey.MinDateTime.ToString() and ShardKey.MinDateTimeOffset.ToString() throw exceptions

Open
#116 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

`ShardKey.MinDateTime.ToString()` throws this exception:

```
Test Name: TestShardKeySerialization
Test FullName: Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.ShardKeyTests.TestShardKeySerialization
Test Source: d:\git\elastic-db-tools\Test\ElasticScale.ShardManagement.UnitTests\ShardKeyTests.cs : line 388
Test Outcome: Failed
Test Duration: 0:00:00.0017911

Result Message:
Test method Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.ShardKeyTests.TestShardKeySerialization threw exception:
System.ArgumentOutOfRangeException: Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
Parameter name: ticks
Result StackTrace:
at System.DateTime..ctor(Int64 ticks)
at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ShardKey.DeNormalize(ShardKeyType keyType, Byte[] value) in d:\git\elastic-db-tools\Src\ElasticScale.Client\ShardManagement\Shard\ShardKey.cs:line 1039
at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ShardKey.get_Value() in d:\git\elastic-db-tools\Src\ElasticScale.Client\ShardManagement\Shard\ShardKey.cs:line 491
at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ShardKey.ToString() in d:\git\elastic-db-tools\Src\ElasticScale.Client\ShardManagement\Shard\ShardKey.cs:line 572
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(String format, Object arg0, Object arg1)
at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.ShardKeyTests.ShardKeyAndRawValue.ToString(ShardKey shardKey) in d:\git\elastic-db-tools\Test\ElasticScale.ShardManagement.UnitTests\ShardKeyTests.cs:line 33
at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.ShardKeyTests.ShardKeyAndRawValue.ToString() in d:\git\elastic-db-tools\Test\ElasticScale.ShardManagement.UnitTests\ShardKeyTests.cs:line 28
at System.IO.TextWriter.WriteLine(Object value)
at System.IO.TextWriter.SyncTextWriter.WriteLine(Object value)
at System.Console.WriteLine(Object value)
at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.ShardKeyTests.TestShardKeySerialization() in d:\git\elastic-db-tools\Test\ElasticScale.ShardManagement.UnitTests\ShardKeyTests.cs:line 391
```

`ShardKey.MinDateTimeOffset.ToString()` throws this exception:

```
Test Name: TestShardKeySerialization
Test FullName: Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.ShardKeyTests.TestShardKeySerialization
Test Source: d:\git\elastic-db-tools\Test\ElasticScale.ShardManagement.UnitTests\ShardKeyTests.cs : line 388
Test Outcome: Failed
Test Duration: 0:00:00.0023891

Result Message:
Test method Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.ShardKeyTests.TestShardKeySerialization threw exception:
System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
Result StackTrace:
at System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count)
at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ShardKey.DenormalizeDateTimeOffset(Byte[] value) in d:\git\elastic-db-tools\Src\ElasticScale.Client\ShardManagement\Shard\ShardKey.cs:line 1290
at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ShardKey.DeNormalize(ShardKeyType keyType, Byte[] value) in d:\git\elastic-db-tools\Src\ElasticScale.Client\ShardManagement\Shard\ShardKey.cs:line 1046
at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ShardKey.get_Value() in d:\git\elastic-db-tools\Src\ElasticScale.Client\ShardManagement\Shard\ShardKey.cs:line 491
at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ShardKey.ToString() in d:\git\elastic-db-tools\Src\ElasticScale.Client\ShardManagement\Shard\ShardKey.cs:line 572
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(String format, Object arg0, Object arg1)
at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.ShardKeyTests.ShardKeyAndRawValue.ToString(ShardKey shardKey) in d:\git\elastic-db-tools\Test\ElasticScale.ShardManagement.UnitTests\ShardKeyTests.cs:line 33
at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.ShardKeyTests.ShardKeyAndRawValue.ToString() in d:\git\elastic-db-tools\Test\ElasticScale.ShardManagement.UnitTests\ShardKeyTests.cs:line 28
at System.IO.TextWriter.WriteLine(Object value)
at System.IO.TextWriter.SyncTextWriter.WriteLine(Object value)
at System.Console.WriteLine(Object value)
at Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.ShardKeyTests.TestShardKeySerialization() in d:\git\elastic-db-tools\Test\ElasticScale.ShardManagement.UnitTests\ShardKeyTests.cs:line 391
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with Src/ElasticScale.Client/ShardManagement/Shard/ShardKey.cs, especially DeNormalize, DenormalizeDateTimeOffset, and ToString, then reproduce the failure with Test/ElasticScale.ShardManagement.UnitTests/ShardKeyTests.cs and TestShardKeySerialization. Done means ShardKey.MinDateTime.ToString() and ShardKey.MinDateTimeOffset.ToString() complete without exceptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.