Skip to content

Commit dc36ab5

Browse files
kundadebdattaadityasaaavasthy
authored
Direct Package Upgrade: Fixes Cosmos.Direct Package to 3.39.1 (#5241)
# Pull Request Template ## Description This PR also bumps up the `Microsoft.Azure.Cosmos.Direct` version from `3.38.0` to `3.39.1`. The new direct release contains the below changes: - Session Consistency: Adds SessionTokenMismatchRetryPolicy optimization through customer supplied region switch hints. - Rntbd Health Check Improvements Part 3: Enables Aggressive Timeout Detection By Default. - Introduce East US 3 in the SDK. - Adding a utility to map substatus codes string values to the statuscode. This is being done to avoid substatus mismatch issue which happens in case of duplicate substatus values as ToString() tends to pick up the first value from the list. This change is needed in 3.39.1 version as the order of statusCode changed in the root file. <img width="497" alt="image" src="https://github.com/user-attachments/assets/a2f6e022-6a78-4c85-b5ec-d331c34296ef" /> ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) ## Closing issues To automatically close an issue: closes #IssueNumber --------- Co-authored-by: REDMOND\adityasa <[email protected]> Co-authored-by: Arooshi Avasthy (from Dev Box) <[email protected]>
1 parent cfabd2a commit dc36ab5

File tree

12 files changed

+176
-154
lines changed

12 files changed

+176
-154
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ClientOfficialVersion>3.51.0</ClientOfficialVersion>
44
<ClientPreviewVersion>3.52.0</ClientPreviewVersion>
55
<ClientPreviewSuffixVersion>preview.0</ClientPreviewSuffixVersion>
6-
<DirectVersion>3.38.0</DirectVersion>
6+
<DirectVersion>3.39.1</DirectVersion>
77
<FaultInjectionVersion>1.0.0</FaultInjectionVersion>
88
<FaultInjectionSuffixVersion>beta.0</FaultInjectionSuffixVersion>
99
<EncryptionOfficialVersion>2.0.5</EncryptionOfficialVersion>

Microsoft.Azure.Cosmos/src/Regions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public static class Regions
3535
/// </summary>
3636
public const string EastUS2 = "East US 2";
3737

38+
/// <summary>
39+
/// Name of the Azure East US 3 region in the Azure Cosmos DB service.
40+
/// </summary>
41+
public const string EastUS3 = "East US 3";
42+
3843
/// <summary>
3944
/// Name of the Azure Central US region in the Azure Cosmos DB service.
4045
/// </summary>

Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryAttributeKeys.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ namespace Microsoft.Azure.Cosmos.Telemetry
99
using System.Linq;
1010
using System.Net;
1111
using global::Azure.Core;
12-
using Microsoft.Azure.Cosmos.Tracing.TraceData;
12+
using Microsoft.Azure.Cosmos.Tracing.TraceData;
13+
using Microsoft.Azure.Cosmos.Util;
1314
using Microsoft.Azure.Documents;
1415

1516
/// <summary>
@@ -484,17 +485,19 @@ private static string GetRegion(ClientSideRequestStatisticsTraceDatum.StoreRespo
484485
/// <param name="statusCode">Status code</param>
485486
/// <param name="subStatusCode">Sub status code</param>
486487
/// <returns>error.type dimension value</returns>
487-
private static string GetErrorType(Exception exception, int? statusCode, int? subStatusCode)
488-
{
489-
if (exception == null)
490-
{
491-
return null;
492-
}
493-
494-
HttpStatusCode? code = statusCode.HasValue ? (HttpStatusCode)statusCode.Value : null;
495-
SubStatusCodes? subCode = subStatusCode.HasValue ? (SubStatusCodes)subStatusCode.Value : null;
496-
497-
return $"{exception.GetType().Name}_{code?.ToString()}_{subCode?.ToString()}";
488+
private static string GetErrorType(Exception exception, int? statusCode, int? subStatusCode)
489+
{
490+
if (exception == null)
491+
{
492+
return null;
493+
}
494+
495+
string codeString = statusCode.HasValue ? ((StatusCodes)statusCode.Value).ToString() : string.Empty;
496+
string mappedSubStatusCode = (statusCode.HasValue && subStatusCode.HasValue)
497+
? SubStatusMappingUtil.GetSubStatusCodeString((StatusCodes)statusCode.Value, (SubStatusCodes)subStatusCode.Value)
498+
: string.Empty;
499+
500+
return $"{exception.GetType().Name}_{codeString}_{mappedSubStatusCode}";
498501
}
499502

500503
private static int GetSubStatusCode(ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics tcpStats, ClientSideRequestStatisticsTraceDatum.HttpResponseStatistics? httpStats)

Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceJsonWriter.cs

Lines changed: 3 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ namespace Microsoft.Azure.Cosmos.Tracing
1111
using System.Net.Http;
1212
using System.Text;
1313
using Microsoft.Azure.Cosmos.Json;
14-
using Microsoft.Azure.Cosmos.Tracing.TraceData;
14+
using Microsoft.Azure.Cosmos.Tracing.TraceData;
15+
using Microsoft.Azure.Cosmos.Util;
1516
using Microsoft.Azure.Documents;
1617

1718
internal static partial class TraceWriter
@@ -394,7 +395,7 @@ public void Visit(StoreResult storeResult)
394395
this.jsonWriter.WriteStringValue(storeResult.StatusCode.ToString());
395396

396397
this.jsonWriter.WriteFieldName(nameof(storeResult.SubStatusCode));
397-
this.jsonWriter.WriteStringValue(this.GetSubStatusCodeString(storeResult.StatusCode, storeResult.SubStatusCode));
398+
this.jsonWriter.WriteStringValue(SubStatusMappingUtil.GetSubStatusCodeString(storeResult.StatusCode, storeResult.SubStatusCode));
398399

399400
this.jsonWriter.WriteFieldName(nameof(storeResult.LSN));
400401
this.jsonWriter.WriteNumberValue(storeResult.LSN);
@@ -452,116 +453,6 @@ public void Visit(StoreResult storeResult)
452453
this.jsonWriter.WriteObjectEnd();
453454
}
454455

455-
internal string GetSubStatusCodeString(StatusCodes statusCode, SubStatusCodes subStatusCode)
456-
{
457-
if ((int)subStatusCode == 1002)
458-
{
459-
return statusCode == StatusCodes.NotFound
460-
? "ReadSessionNotAvailable"
461-
: SubStatusCodes.PartitionKeyRangeGone.ToString();
462-
}
463-
464-
if ((int)subStatusCode == 2001)
465-
{
466-
return statusCode == StatusCodes.NoContent
467-
? "MissedTargetLsn"
468-
: SubStatusCodes.SplitIsDisabled.ToString();
469-
}
470-
471-
if ((int)subStatusCode == 2002)
472-
{
473-
return statusCode == StatusCodes.NoContent
474-
? "MissedTargetLsnOver100"
475-
: SubStatusCodes.CollectionsInPartitionGotUpdated.ToString();
476-
}
477-
478-
if ((int)subStatusCode == 2003)
479-
{
480-
return statusCode == StatusCodes.NoContent
481-
? "MissedTargetLsnOver1000"
482-
: SubStatusCodes.CanNotAcquirePKRangesLock.ToString();
483-
}
484-
485-
if ((int)subStatusCode == 2004)
486-
{
487-
return statusCode == StatusCodes.NoContent
488-
? "MissedTargetLsnOver10000"
489-
: SubStatusCodes.ResourceNotFound.ToString();
490-
}
491-
492-
if ((int)subStatusCode == 2011)
493-
{
494-
return statusCode == StatusCodes.NoContent
495-
? "MissedTargetGlobalCommittedLsn"
496-
: SubStatusCodes.StorageSplitConflictingWithNWayThroughputSplit.ToString();
497-
}
498-
499-
if ((int)subStatusCode == 2012)
500-
{
501-
return statusCode == StatusCodes.NoContent
502-
? "MissedTargetGlobalCommittedLsnOver100"
503-
: SubStatusCodes.MergeIsDisabled.ToString();
504-
}
505-
506-
if ((int)subStatusCode == 1004)
507-
{
508-
return statusCode == StatusCodes.BadRequest
509-
? "CrossPartitionQueryNotServable"
510-
: SubStatusCodes.ConfigurationNameNotFound.ToString();
511-
}
512-
513-
if ((int)subStatusCode == 1007)
514-
{
515-
return statusCode == StatusCodes.Gone
516-
? "CompletingSplit"
517-
: SubStatusCodes.InsufficientBindablePartitions.ToString();
518-
}
519-
520-
if ((int)subStatusCode == 1008)
521-
{
522-
return statusCode == StatusCodes.Gone
523-
? "CompletingPartitionMigration"
524-
: SubStatusCodes.DatabaseAccountNotFound.ToString();
525-
}
526-
527-
if ((int)subStatusCode == 1005)
528-
{
529-
return statusCode == StatusCodes.NotFound
530-
? "ConfigurationPropertyNotFound"
531-
: SubStatusCodes.ProvisionLimitReached.ToString();
532-
}
533-
534-
if ((int)subStatusCode == 3207)
535-
{
536-
return statusCode == StatusCodes.Conflict
537-
? "ConfigurationNameAlreadyExists"
538-
: SubStatusCodes.PrepareTimeLimitExceeded.ToString();
539-
}
540-
541-
if ((int)subStatusCode == 6001)
542-
{
543-
return statusCode == StatusCodes.ServiceUnavailable
544-
? "AggregatedHealthStateError"
545-
: SubStatusCodes.PartitionMigrationWaitForFullSyncReceivedInternalServerErrorDuringCompleteMigrationFromBackend.ToString();
546-
}
547-
548-
if ((int)subStatusCode == 6002)
549-
{
550-
return statusCode == StatusCodes.ServiceUnavailable
551-
? "ApplicationHealthStateError"
552-
: SubStatusCodes.PartitionMigrationWaitForFullSyncReceivedInternalServerErrorDuringAbortMigrationFromBackend.ToString();
553-
}
554-
555-
if ((int)subStatusCode == 6003)
556-
{
557-
return statusCode == StatusCodes.ServiceUnavailable
558-
? "HealthStateError"
559-
: SubStatusCodes.PartitionMigrationFinalizeMigrationsDidNotCompleteInTenRetries.ToString();
560-
}
561-
562-
return subStatusCode.ToString();
563-
}
564-
565456
public void Visit(PartitionKeyRangeCacheTraceDatum partitionKeyRangeCacheTraceDatum)
566457
{
567458
this.jsonWriter.WriteObjectStart();
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
//------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
//------------------------------------------------------------
4+
namespace Microsoft.Azure.Cosmos.Util
5+
{
6+
using Microsoft.Azure.Documents;
7+
8+
/// <summary>
9+
/// Utility for correctly mapping duplicate SubStatus codes.
10+
/// </summary>
11+
internal class SubStatusMappingUtil
12+
{
13+
public static string GetSubStatusCodeString(StatusCodes statusCode, SubStatusCodes subStatusCode)
14+
{
15+
if ((int)subStatusCode == 1002)
16+
{
17+
return statusCode == StatusCodes.NotFound
18+
? nameof(SubStatusCodes.ReadSessionNotAvailable)
19+
: nameof(SubStatusCodes.PartitionKeyRangeGone);
20+
}
21+
22+
if ((int)subStatusCode == 2001)
23+
{
24+
return statusCode == StatusCodes.NoContent
25+
? nameof(SubStatusCodes.MissedTargetLsn)
26+
: nameof(SubStatusCodes.SplitIsDisabled);
27+
}
28+
29+
if ((int)subStatusCode == 2002)
30+
{
31+
return statusCode == StatusCodes.NoContent
32+
? nameof(SubStatusCodes.MissedTargetLsnOver100)
33+
: nameof(SubStatusCodes.CollectionsInPartitionGotUpdated);
34+
}
35+
36+
if ((int)subStatusCode == 2003)
37+
{
38+
return statusCode == StatusCodes.NoContent
39+
? nameof(SubStatusCodes.MissedTargetLsnOver1000)
40+
: nameof(SubStatusCodes.CanNotAcquirePKRangesLock);
41+
}
42+
43+
if ((int)subStatusCode == 2004)
44+
{
45+
return statusCode == StatusCodes.NoContent
46+
? nameof(SubStatusCodes.MissedTargetLsnOver10000)
47+
: nameof(SubStatusCodes.ResourceNotFound);
48+
}
49+
50+
if ((int)subStatusCode == 2011)
51+
{
52+
return statusCode == StatusCodes.NoContent
53+
? nameof(SubStatusCodes.MissedTargetGlobalCommittedLsn)
54+
: nameof(SubStatusCodes.StorageSplitConflictingWithNWayThroughputSplit);
55+
}
56+
57+
if ((int)subStatusCode == 2012)
58+
{
59+
return statusCode == StatusCodes.NoContent
60+
? nameof(SubStatusCodes.MissedTargetGlobalCommittedLsnOver100)
61+
: nameof(SubStatusCodes.MergeIsDisabled);
62+
}
63+
64+
if ((int)subStatusCode == 1004)
65+
{
66+
return statusCode == StatusCodes.BadRequest
67+
? nameof(SubStatusCodes.CrossPartitionQueryNotServable)
68+
: nameof(SubStatusCodes.ConfigurationNameNotFound);
69+
}
70+
71+
if ((int)subStatusCode == 1007)
72+
{
73+
return statusCode == StatusCodes.Gone
74+
? nameof(SubStatusCodes.CompletingSplit)
75+
: nameof(SubStatusCodes.InsufficientBindablePartitions);
76+
}
77+
78+
if ((int)subStatusCode == 1008)
79+
{
80+
return statusCode == StatusCodes.Gone
81+
? nameof(SubStatusCodes.CompletingPartitionMigration)
82+
: nameof(SubStatusCodes.DatabaseAccountNotFound);
83+
}
84+
85+
if ((int)subStatusCode == 1005)
86+
{
87+
return statusCode == StatusCodes.NotFound
88+
? nameof(SubStatusCodes.ConfigurationPropertyNotFound)
89+
: nameof(SubStatusCodes.ProvisionLimitReached);
90+
}
91+
92+
if ((int)subStatusCode == 3207)
93+
{
94+
return statusCode == StatusCodes.Conflict
95+
? nameof(SubStatusCodes.ConfigurationNameAlreadyExists)
96+
: nameof(SubStatusCodes.PrepareTimeLimitExceeded);
97+
}
98+
99+
if ((int)subStatusCode == 6001)
100+
{
101+
return statusCode == StatusCodes.ServiceUnavailable
102+
? nameof(SubStatusCodes.AggregatedHealthStateError)
103+
: nameof(SubStatusCodes.PartitionMigrationWaitForFullSyncReceivedInternalServerErrorDuringCompleteMigrationFromBackend);
104+
}
105+
106+
if ((int)subStatusCode == 6002)
107+
{
108+
return statusCode == StatusCodes.ServiceUnavailable
109+
? nameof(SubStatusCodes.ApplicationHealthStateError)
110+
: nameof(SubStatusCodes.PartitionMigrationWaitForFullSyncReceivedInternalServerErrorDuringAbortMigrationFromBackend);
111+
}
112+
113+
if ((int)subStatusCode == 6003)
114+
{
115+
return statusCode == StatusCodes.ServiceUnavailable
116+
? nameof(SubStatusCodes.HealthStateError)
117+
: nameof(SubStatusCodes.PartitionMigrationFinalizeMigrationsDidNotCompleteInTenRetries);
118+
}
119+
120+
return subStatusCode.ToString();
121+
}
122+
}
123+
}

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/LinqTranslationBaselineTests.TestVectorDistanceFunction.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ FROM root]]></SqlQuery>
599599
<SqlQuery><![CDATA[
600600
SELECT VALUE VectorDistance(root["VectorFloatField"], [2, 3, 4], true, {"searchListSizeMultiplier": -100})
601601
FROM root]]></SqlQuery>
602-
<ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":71,"end":105},"code":"SC2213","message":"The SearchListSizeMultiplier value -100 specified in the VectorDistance function is outside the supported range. The value must be between 1 and 100."}]},0x800A0B00]]></ErrorMessage>
602+
<ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":71,"end":105},"code":"SC2213","message":"The 'searchListSizeMultiplier' value -100 specified in the VectorDistance function is outside the supported range. The value must be between 1 and 100."}]},0x800A0B00]]></ErrorMessage>
603603
</Output>
604604
</Result>
605605
</Results>

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/QueryPlanBaselineTests.Distinct.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
<Range>[[],"Infinity")</Range>
126126
</Range>
127127
</QueryRanges>
128-
<RewrittenQuery><![CDATA[SELECT DISTINCT c._rid, [{"item": c.blah}] AS orderByItems, c.blah AS payload
128+
<RewrittenQuery><![CDATA[SELECT c._rid, [{"item": c.blah}] AS orderByItems, c.blah AS payload
129129
FROM c
130130
WHERE (({documentdb-formattableorderbyquery-filter}) AND IS_DEFINED(c.blah))
131131
ORDER BY c.blah]]></RewrittenQuery>

0 commit comments

Comments
 (0)