Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ClientOfficialVersion>3.51.0</ClientOfficialVersion>
<ClientPreviewVersion>3.52.0</ClientPreviewVersion>
<ClientPreviewSuffixVersion>preview.0</ClientPreviewSuffixVersion>
<DirectVersion>3.38.0</DirectVersion>
<DirectVersion>3.39.1</DirectVersion>
<FaultInjectionVersion>1.0.0</FaultInjectionVersion>
<FaultInjectionSuffixVersion>beta.0</FaultInjectionSuffixVersion>
<EncryptionOfficialVersion>2.0.5</EncryptionOfficialVersion>
Expand Down
5 changes: 5 additions & 0 deletions Microsoft.Azure.Cosmos/src/Regions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public static class Regions
/// </summary>
public const string EastUS2 = "East US 2";

/// <summary>
/// Name of the Azure East US 3 region in the Azure Cosmos DB service.
/// </summary>
public const string EastUS3 = "East US 3";

/// <summary>
/// Name of the Azure Central US region in the Azure Cosmos DB service.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace Microsoft.Azure.Cosmos.Telemetry
using System.Linq;
using System.Net;
using global::Azure.Core;
using Microsoft.Azure.Cosmos.Tracing.TraceData;
using Microsoft.Azure.Cosmos.Tracing.TraceData;
using Microsoft.Azure.Cosmos.Util;
using Microsoft.Azure.Documents;

/// <summary>
Expand Down Expand Up @@ -484,17 +485,19 @@ private static string GetRegion(ClientSideRequestStatisticsTraceDatum.StoreRespo
/// <param name="statusCode">Status code</param>
/// <param name="subStatusCode">Sub status code</param>
/// <returns>error.type dimension value</returns>
private static string GetErrorType(Exception exception, int? statusCode, int? subStatusCode)
{
if (exception == null)
{
return null;
}

HttpStatusCode? code = statusCode.HasValue ? (HttpStatusCode)statusCode.Value : null;
SubStatusCodes? subCode = subStatusCode.HasValue ? (SubStatusCodes)subStatusCode.Value : null;

return $"{exception.GetType().Name}_{code?.ToString()}_{subCode?.ToString()}";
private static string GetErrorType(Exception exception, int? statusCode, int? subStatusCode)
{
if (exception == null)
{
return null;
}

string codeString = statusCode.HasValue ? ((StatusCodes)statusCode.Value).ToString() : string.Empty;
string mappedSubStatusCode = (statusCode.HasValue && subStatusCode.HasValue)
? SubStatusMappingUtil.GetSubStatusCodeString((StatusCodes)statusCode.Value, (SubStatusCodes)subStatusCode.Value)
: string.Empty;

return $"{exception.GetType().Name}_{codeString}_{mappedSubStatusCode}";
}

private static int GetSubStatusCode(ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics tcpStats, ClientSideRequestStatisticsTraceDatum.HttpResponseStatistics? httpStats)
Expand Down
115 changes: 3 additions & 112 deletions Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceJsonWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace Microsoft.Azure.Cosmos.Tracing
using System.Net.Http;
using System.Text;
using Microsoft.Azure.Cosmos.Json;
using Microsoft.Azure.Cosmos.Tracing.TraceData;
using Microsoft.Azure.Cosmos.Tracing.TraceData;
using Microsoft.Azure.Cosmos.Util;
using Microsoft.Azure.Documents;

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

this.jsonWriter.WriteFieldName(nameof(storeResult.SubStatusCode));
this.jsonWriter.WriteStringValue(this.GetSubStatusCodeString(storeResult.StatusCode, storeResult.SubStatusCode));
this.jsonWriter.WriteStringValue(SubStatusMappingUtil.GetSubStatusCodeString(storeResult.StatusCode, storeResult.SubStatusCode));

this.jsonWriter.WriteFieldName(nameof(storeResult.LSN));
this.jsonWriter.WriteNumberValue(storeResult.LSN);
Expand Down Expand Up @@ -452,116 +453,6 @@ public void Visit(StoreResult storeResult)
this.jsonWriter.WriteObjectEnd();
}

internal string GetSubStatusCodeString(StatusCodes statusCode, SubStatusCodes subStatusCode)
{
if ((int)subStatusCode == 1002)
{
return statusCode == StatusCodes.NotFound
? "ReadSessionNotAvailable"
: SubStatusCodes.PartitionKeyRangeGone.ToString();
}

if ((int)subStatusCode == 2001)
{
return statusCode == StatusCodes.NoContent
? "MissedTargetLsn"
: SubStatusCodes.SplitIsDisabled.ToString();
}

if ((int)subStatusCode == 2002)
{
return statusCode == StatusCodes.NoContent
? "MissedTargetLsnOver100"
: SubStatusCodes.CollectionsInPartitionGotUpdated.ToString();
}

if ((int)subStatusCode == 2003)
{
return statusCode == StatusCodes.NoContent
? "MissedTargetLsnOver1000"
: SubStatusCodes.CanNotAcquirePKRangesLock.ToString();
}

if ((int)subStatusCode == 2004)
{
return statusCode == StatusCodes.NoContent
? "MissedTargetLsnOver10000"
: SubStatusCodes.ResourceNotFound.ToString();
}

if ((int)subStatusCode == 2011)
{
return statusCode == StatusCodes.NoContent
? "MissedTargetGlobalCommittedLsn"
: SubStatusCodes.StorageSplitConflictingWithNWayThroughputSplit.ToString();
}

if ((int)subStatusCode == 2012)
{
return statusCode == StatusCodes.NoContent
? "MissedTargetGlobalCommittedLsnOver100"
: SubStatusCodes.MergeIsDisabled.ToString();
}

if ((int)subStatusCode == 1004)
{
return statusCode == StatusCodes.BadRequest
? "CrossPartitionQueryNotServable"
: SubStatusCodes.ConfigurationNameNotFound.ToString();
}

if ((int)subStatusCode == 1007)
{
return statusCode == StatusCodes.Gone
? "CompletingSplit"
: SubStatusCodes.InsufficientBindablePartitions.ToString();
}

if ((int)subStatusCode == 1008)
{
return statusCode == StatusCodes.Gone
? "CompletingPartitionMigration"
: SubStatusCodes.DatabaseAccountNotFound.ToString();
}

if ((int)subStatusCode == 1005)
{
return statusCode == StatusCodes.NotFound
? "ConfigurationPropertyNotFound"
: SubStatusCodes.ProvisionLimitReached.ToString();
}

if ((int)subStatusCode == 3207)
{
return statusCode == StatusCodes.Conflict
? "ConfigurationNameAlreadyExists"
: SubStatusCodes.PrepareTimeLimitExceeded.ToString();
}

if ((int)subStatusCode == 6001)
{
return statusCode == StatusCodes.ServiceUnavailable
? "AggregatedHealthStateError"
: SubStatusCodes.PartitionMigrationWaitForFullSyncReceivedInternalServerErrorDuringCompleteMigrationFromBackend.ToString();
}

if ((int)subStatusCode == 6002)
{
return statusCode == StatusCodes.ServiceUnavailable
? "ApplicationHealthStateError"
: SubStatusCodes.PartitionMigrationWaitForFullSyncReceivedInternalServerErrorDuringAbortMigrationFromBackend.ToString();
}

if ((int)subStatusCode == 6003)
{
return statusCode == StatusCodes.ServiceUnavailable
? "HealthStateError"
: SubStatusCodes.PartitionMigrationFinalizeMigrationsDidNotCompleteInTenRetries.ToString();
}

return subStatusCode.ToString();
}

public void Visit(PartitionKeyRangeCacheTraceDatum partitionKeyRangeCacheTraceDatum)
{
this.jsonWriter.WriteObjectStart();
Expand Down
123 changes: 123 additions & 0 deletions Microsoft.Azure.Cosmos/src/Util/SubStatusMappingUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace Microsoft.Azure.Cosmos.Util
{
using Microsoft.Azure.Documents;

/// <summary>
/// Utility for correctly mapping duplicate SubStatus codes.
/// </summary>
internal class SubStatusMappingUtil
{
public static string GetSubStatusCodeString(StatusCodes statusCode, SubStatusCodes subStatusCode)
{
if ((int)subStatusCode == 1002)
{
return statusCode == StatusCodes.NotFound
? nameof(SubStatusCodes.ReadSessionNotAvailable)
: nameof(SubStatusCodes.PartitionKeyRangeGone);
}

if ((int)subStatusCode == 2001)
{
return statusCode == StatusCodes.NoContent
? nameof(SubStatusCodes.MissedTargetLsn)
: nameof(SubStatusCodes.SplitIsDisabled);
}

if ((int)subStatusCode == 2002)
{
return statusCode == StatusCodes.NoContent
? nameof(SubStatusCodes.MissedTargetLsnOver100)
: nameof(SubStatusCodes.CollectionsInPartitionGotUpdated);
}

if ((int)subStatusCode == 2003)
{
return statusCode == StatusCodes.NoContent
? nameof(SubStatusCodes.MissedTargetLsnOver1000)
: nameof(SubStatusCodes.CanNotAcquirePKRangesLock);
}

if ((int)subStatusCode == 2004)
{
return statusCode == StatusCodes.NoContent
? nameof(SubStatusCodes.MissedTargetLsnOver10000)
: nameof(SubStatusCodes.ResourceNotFound);
}

if ((int)subStatusCode == 2011)
{
return statusCode == StatusCodes.NoContent
? nameof(SubStatusCodes.MissedTargetGlobalCommittedLsn)
: nameof(SubStatusCodes.StorageSplitConflictingWithNWayThroughputSplit);
}

if ((int)subStatusCode == 2012)
{
return statusCode == StatusCodes.NoContent
? nameof(SubStatusCodes.MissedTargetGlobalCommittedLsnOver100)
: nameof(SubStatusCodes.MergeIsDisabled);
}

if ((int)subStatusCode == 1004)
{
return statusCode == StatusCodes.BadRequest
? nameof(SubStatusCodes.CrossPartitionQueryNotServable)
: nameof(SubStatusCodes.ConfigurationNameNotFound);
}

if ((int)subStatusCode == 1007)
{
return statusCode == StatusCodes.Gone
? nameof(SubStatusCodes.CompletingSplit)
: nameof(SubStatusCodes.InsufficientBindablePartitions);
}

if ((int)subStatusCode == 1008)
{
return statusCode == StatusCodes.Gone
? nameof(SubStatusCodes.CompletingPartitionMigration)
: nameof(SubStatusCodes.DatabaseAccountNotFound);
}

if ((int)subStatusCode == 1005)
{
return statusCode == StatusCodes.NotFound
? nameof(SubStatusCodes.ConfigurationPropertyNotFound)
: nameof(SubStatusCodes.ProvisionLimitReached);
}

if ((int)subStatusCode == 3207)
{
return statusCode == StatusCodes.Conflict
? nameof(SubStatusCodes.ConfigurationNameAlreadyExists)
: nameof(SubStatusCodes.PrepareTimeLimitExceeded);
}

if ((int)subStatusCode == 6001)
{
return statusCode == StatusCodes.ServiceUnavailable
? nameof(SubStatusCodes.AggregatedHealthStateError)
: nameof(SubStatusCodes.PartitionMigrationWaitForFullSyncReceivedInternalServerErrorDuringCompleteMigrationFromBackend);
}

if ((int)subStatusCode == 6002)
{
return statusCode == StatusCodes.ServiceUnavailable
? nameof(SubStatusCodes.ApplicationHealthStateError)
: nameof(SubStatusCodes.PartitionMigrationWaitForFullSyncReceivedInternalServerErrorDuringAbortMigrationFromBackend);
}

if ((int)subStatusCode == 6003)
{
return statusCode == StatusCodes.ServiceUnavailable
? nameof(SubStatusCodes.HealthStateError)
: nameof(SubStatusCodes.PartitionMigrationFinalizeMigrationsDidNotCompleteInTenRetries);
}

return subStatusCode.ToString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ FROM root]]></SqlQuery>
<SqlQuery><![CDATA[
SELECT VALUE VectorDistance(root["VectorFloatField"], [2, 3, 4], true, {"searchListSizeMultiplier": -100})
FROM root]]></SqlQuery>
<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>
<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>
</Output>
</Result>
</Results>
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<Range>[[],"Infinity")</Range>
</Range>
</QueryRanges>
<RewrittenQuery><![CDATA[SELECT DISTINCT c._rid, [{"item": c.blah}] AS orderByItems, c.blah AS payload
<RewrittenQuery><![CDATA[SELECT c._rid, [{"item": c.blah}] AS orderByItems, c.blah AS payload
FROM c
WHERE (({documentdb-formattableorderbyquery-filter}) AND IS_DEFINED(c.blah))
ORDER BY c.blah]]></RewrittenQuery>
Expand Down
Loading
Loading