From 2e2a9cdadeddece3236b2cece4c6b1854a5b8696 Mon Sep 17 00:00:00 2001 From: Asket Agarwal Date: Tue, 1 Feb 2022 03:53:11 +0530 Subject: [PATCH] Bumping Direct version to 3.24.1 (#3008) - Sub status: Adds SDK generated substatus codes for 503's - Diagnostics: Captures diagnostics for Splits and RequestTimeoutExcpetion - Performance: Reduces the size of the Rntbd buffer - Diagnostics: Adds ServiceEndpoint and Connection Stats to the diagnostics - Availability: Direct mode removes blocking call on broken connection exception - Availability: Fixes the SDK to ensure it does not retry on replica that previously failed with 410, 408 and >= 500 status codes - Session: Fixes scoped session tokens on partition splits and multiple write endpoints enabled. - DefaultTraceListener: Removes DefaultTraceListener by default unless there is a debugger attached to it. - Diagnostics: Resetting thread starvation status once it is detected. - Hierarchical Partitioning: Provides an EPK range for partial partition key specification. - Session: Fixes gateway session scope during merges --- Directory.Build.props | 2 +- Microsoft.Azure.Cosmos/src/Regions.cs | 5 +++ .../SummaryDiagnosticsTests.cs | 2 +- .../TransportWrapperTests.cs | 2 +- .../TraceWriterBaselineTests.TraceData.xml | 34 +++++++++++++++++-- .../CancellationTokenTests.cs | 2 +- .../Contracts/DotNetSDKAPI.json | 5 +++ .../CosmosExceptionTests.cs | 3 +- .../MockSetupsHelper.cs | 2 +- .../Tracing/TraceWriterBaselineTests.cs | 13 +++++++ 10 files changed, 62 insertions(+), 8 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index b55507fef1..0ecd110d5b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,7 +4,7 @@ 3.23.0 3.23.0 preview - 3.24.0 + 3.24.1 1.0.0-previewV19 1.0.0-preview02 1.1.0-preview3 diff --git a/Microsoft.Azure.Cosmos/src/Regions.cs b/Microsoft.Azure.Cosmos/src/Regions.cs index a5a1a57261..92ee6486d9 100644 --- a/Microsoft.Azure.Cosmos/src/Regions.cs +++ b/Microsoft.Azure.Cosmos/src/Regions.cs @@ -329,5 +329,10 @@ public static class Regions /// Name of the Azure Sweden South region in the Azure Cosmos DB service. /// public const string SwedenSouth = "Sweden South"; + + /// + /// Name of the Azure Qatar Central region in the Azure Cosmos DB service. + /// + public const string QatarCentral = "Qatar Central"; } } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SummaryDiagnosticsTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SummaryDiagnosticsTests.cs index 62c087049d..86b4b67512 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SummaryDiagnosticsTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/SummaryDiagnosticsTests.cs @@ -119,7 +119,7 @@ public async Task DirectPointOperationsWithTransportErrors() ITrace trace = ((CosmosTraceDiagnostics)response.Diagnostics).Value; SummaryDiagnostics summaryDiagnostics = new SummaryDiagnostics(trace); Assert.AreEqual(summaryDiagnostics.DirectRequestsSummary.Value.Keys.Count, 2); - Assert.AreEqual(summaryDiagnostics.DirectRequestsSummary.Value[(410, 0)], 3); + Assert.AreEqual(summaryDiagnostics.DirectRequestsSummary.Value[(410, (int)SubStatusCodes.TransportGenerated410)], 3); Assert.AreEqual(summaryDiagnostics.DirectRequestsSummary.Value[(201, 0)], 1); } } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/TransportWrapperTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/TransportWrapperTests.cs index 51e2c48329..34af05be6a 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/TransportWrapperTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/TransportWrapperTests.cs @@ -97,7 +97,7 @@ private void ValidateTransportException(ResponseMessage responseMessage) Assert.AreEqual(HttpStatusCode.ServiceUnavailable, responseMessage.StatusCode); string message = responseMessage.ErrorMessage; Assert.AreEqual(message, responseMessage.CosmosException.Message); - Assert.IsTrue(message.Contains("ServiceUnavailable (503); Substatus: 0; ActivityId:")); + Assert.IsTrue(message.Contains($"ServiceUnavailable (503); Substatus: {(int)SubStatusCodes.TransportGenerated503}; ActivityId:")); Assert.IsTrue(message.Contains("Reason: (Message: Channel is closed"), "Should contain exception message"); string diagnostics = responseMessage.Diagnostics.ToString(); Assert.IsNotNull(diagnostics); diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/TraceWriterBaselineTests.TraceData.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/TraceWriterBaselineTests.TraceData.xml index 7baf2fb5b1..416cb83d2a 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/TraceWriterBaselineTests.TraceData.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/TraceWriterBaselineTests.TraceData.xml @@ -389,7 +389,22 @@ "startTimeUtc": "2021-12-31T23:59:59.06Z", "durationInMs": 0 } - ] + ], + "serviceEndpointStats": { + "inflightRequests": 2, + "openConnections": 1 + }, + "connectionStats": { + "waitforConnectionInit": "True", + "callsPendingReceive": 1, + "lastSendAttempt": "2021-12-31T23:59:59.059Z", + "lastSend": "2021-12-31T23:59:59.059Z", + "lastReceive": "2021-12-31T23:59:59.059Z" + }, + "requestSizeInBytes": 2, + "requestBodySizeInBytes": 1, + "responseMetadataSizeInBytes": 1, + "responseBodySizeInBytes": 1 }, "TransportException": null } @@ -582,7 +597,22 @@ "startTimeUtc": "2021-12-31T23:59:59.06Z", "durationInMs": 0 } - ] + ], + "serviceEndpointStats": { + "inflightRequests": 2, + "openConnections": 1 + }, + "connectionStats": { + "waitforConnectionInit": "True", + "callsPendingReceive": 1, + "lastSendAttempt": "2021-12-31T23:59:59.059Z", + "lastSend": "2021-12-31T23:59:59.059Z", + "lastReceive": "2021-12-31T23:59:59.059Z" + }, + "requestSizeInBytes": 2, + "requestBodySizeInBytes": 1, + "responseMetadataSizeInBytes": 1, + "responseBodySizeInBytes": 1 }, "TransportException": null } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CancellationTokenTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CancellationTokenTests.cs index c0c05feda9..02c9bdd1ff 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CancellationTokenTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CancellationTokenTests.cs @@ -160,7 +160,7 @@ StoreResponse sendDirectFunc(Uri uri, ResourceOperation resourceOperation, Docum Assert.Fail("There should only be 1 TCP request that triggers an address resolution."); } - throw new GoneException(new TransportException(TransportErrorCode.ConnectFailed, null, Guid.NewGuid(), new Uri("http://one.com"), "description", true, true)); + throw new GoneException(new TransportException(TransportErrorCode.ConnectFailed, null, Guid.NewGuid(), new Uri("http://one.com"), "description", true, true), SubStatusCodes.Unknown); } using CosmosClient client = MockCosmosUtil.CreateMockCosmosClient(); diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json index 58f01e59d4..fdd6f2e9b4 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json @@ -5832,6 +5832,11 @@ "Attributes": [], "MethodInfo": "System.String NorwayWest;IsInitOnly:False;IsStatic:True;" }, + "System.String QatarCentral": { + "Type": "Field", + "Attributes": [], + "MethodInfo": "System.String QatarCentral;IsInitOnly:False;IsStatic:True;" + }, "System.String SouthAfricaNorth": { "Type": "Field", "Attributes": [], diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosExceptionTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosExceptionTests.cs index 9594766f3b..592dfb1962 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosExceptionTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosExceptionTests.cs @@ -297,7 +297,8 @@ public void VerifyTransportExceptionToResponseMessage() { throw new ServiceUnavailableException( message: errorMessage, - innerException: transportException); + innerException: transportException, + SubStatusCodes.Unknown); } catch (DocumentClientException exception) { diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/PartitionKeyRangeFailoverTests/MockSetupsHelper.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/PartitionKeyRangeFailoverTests/MockSetupsHelper.cs index 57ef31767a..b2f831e348 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/PartitionKeyRangeFailoverTests/MockSetupsHelper.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/PartitionKeyRangeFailoverTests/MockSetupsHelper.cs @@ -254,7 +254,7 @@ internal static void SetupServiceUnavailableException( TransportAddressUri physicalUri) { mockTransportClient.Setup(x => x.InvokeResourceOperationAsync(physicalUri, It.IsAny())) - .Returns(() => throw new ServiceUnavailableException($"Mock write forbidden exception on URI:{physicalUri}", physicalUri.Uri)); + .Returns(() => throw new ServiceUnavailableException($"Mock write forbidden exception on URI:{physicalUri}", SubStatusCodes.Unknown, physicalUri.Uri)); } internal static void SetupRequestTimeoutException( diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceWriterBaselineTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceWriterBaselineTests.cs index 6f47b40176..174dcf7992 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceWriterBaselineTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceWriterBaselineTests.cs @@ -754,6 +754,19 @@ internal static TransportRequestStats CreateTransportRequestStats() field = transportRequestStats.GetType().GetField("requestCompletedTime", BindingFlags.NonPublic | BindingFlags.Instance); field.SetValue(transportRequestStats, TimeSpan.FromMilliseconds(1)); + + transportRequestStats.RequestSizeInBytes = 2; + transportRequestStats.RequestBodySizeInBytes = 1; + transportRequestStats.ResponseBodySizeInBytes = 1; + transportRequestStats.ResponseMetadataSizeInBytes = 1; + + transportRequestStats.NumberOfInflightRequestsToEndpoint = 2; + transportRequestStats.NumberOfOpenConnectionsToEndpoint = 1; + transportRequestStats.NumberOfInflightRequestsInConnection = 1; + transportRequestStats.RequestWaitingForConnectionInitialization = true; + transportRequestStats.ConnectionLastSendTime = defaultDateTime; + transportRequestStats.ConnectionLastSendAttemptTime = defaultDateTime; + transportRequestStats.ConnectionLastReceiveTime = defaultDateTime; return transportRequestStats; }