Skip to content

Commit ab69838

Browse files
authored
Merge branch 'master' into users/akotalwar/TurnOnODEByDefault
2 parents cc1db80 + 17bbdab commit ab69838

53 files changed

Lines changed: 5362 additions & 374 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
3-
<ClientOfficialVersion>3.37.0</ClientOfficialVersion>
4-
<ClientPreviewVersion>3.37.0</ClientPreviewVersion>
3+
<ClientOfficialVersion>3.37.1</ClientOfficialVersion>
4+
<ClientPreviewVersion>3.37.1</ClientPreviewVersion>
55
<ClientPreviewSuffixVersion>preview</ClientPreviewSuffixVersion>
66
<DirectVersion>3.31.5</DirectVersion>
77
<EncryptionOfficialVersion>2.0.4</EncryptionOfficialVersion>

Microsoft.Azure.Cosmos/contracts/API_3.37.1-preview.txt

Lines changed: 1611 additions & 0 deletions
Large diffs are not rendered by default.

Microsoft.Azure.Cosmos/contracts/API_3.37.1.txt

Lines changed: 1552 additions & 0 deletions
Large diffs are not rendered by default.

Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/PartitionControllerCore.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ public override async Task AddOrUpdateLeaseAsync(DocumentServiceLease lease)
8989
throw;
9090
}
9191

92-
PartitionSupervisor supervisor = this.partitionSupervisorFactory.Create(lease);
93-
this.ProcessPartitionAsync(supervisor, lease).LogException();
92+
this.ProcessPartitionAsync(lease).LogException();
9493
}
9594

9695
public override async Task ShutdownAsync()
@@ -146,8 +145,10 @@ private async Task RemoveLeaseAsync(DocumentServiceLease lease, bool wasAcquired
146145
}
147146
}
148147

149-
private async Task ProcessPartitionAsync(PartitionSupervisor partitionSupervisor, DocumentServiceLease lease)
148+
private async Task ProcessPartitionAsync(DocumentServiceLease lease)
150149
{
150+
using PartitionSupervisor partitionSupervisor = this.partitionSupervisorFactory.Create(lease);
151+
151152
try
152153
{
153154
await partitionSupervisor.RunAsync(this.shutdownCts.Token).ConfigureAwait(false);

Microsoft.Azure.Cosmos/src/ClientRetryPolicy.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@ public async Task<ShouldRetryResult> ShouldRetryAsync(
9898
}
9999
}
100100

101+
// Any metadata request will throw a cosmos exception from CosmosHttpClientCore if
102+
// it receives a 503 service unavailable from gateway. This check is to add retry
103+
// mechanism for the metadata requests in such cases.
104+
if (exception is CosmosException cosmosException)
105+
{
106+
ShouldRetryResult shouldRetryResult = await this.ShouldRetryInternalAsync(
107+
cosmosException.StatusCode,
108+
cosmosException.Headers.SubStatusCode);
109+
if (shouldRetryResult != null)
110+
{
111+
return shouldRetryResult;
112+
}
113+
}
114+
101115
return await this.throttlingRetry.ShouldRetryAsync(exception, cancellationToken);
102116
}
103117

Microsoft.Azure.Cosmos/src/DocumentClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ private async Task OpenPrivateAsync(CancellationToken cancellationToken)
662662
tokenProvider: this,
663663
retryPolicy: this.retryPolicy,
664664
telemetryToServiceHelper: this.telemetryToServiceHelper);
665-
this.partitionKeyRangeCache = new PartitionKeyRangeCache(this, this.GatewayStoreModel, this.collectionCache);
665+
this.partitionKeyRangeCache = new PartitionKeyRangeCache(this, this.GatewayStoreModel, this.collectionCache, this.GlobalEndpointManager);
666666

667667
DefaultTrace.TraceWarning("{0} occurred while OpenAsync. Exception Message: {1}", ex.ToString(), ex.Message);
668668
}
@@ -1033,7 +1033,7 @@ private async Task<bool> GetInitializationTaskAsync(IStoreClientFactory storeCli
10331033
tokenProvider: this,
10341034
retryPolicy: this.retryPolicy,
10351035
telemetryToServiceHelper: this.telemetryToServiceHelper);
1036-
this.partitionKeyRangeCache = new PartitionKeyRangeCache(this, this.GatewayStoreModel, this.collectionCache);
1036+
this.partitionKeyRangeCache = new PartitionKeyRangeCache(this, this.GatewayStoreModel, this.collectionCache, this.GlobalEndpointManager);
10371037
this.ResetSessionTokenRetryPolicy = new ResetSessionTokenRetryPolicyFactory(this.sessionContainer, this.collectionCache, this.retryPolicy);
10381038

10391039
gatewayStoreModel.SetCaches(this.partitionKeyRangeCache, this.collectionCache);

Microsoft.Azure.Cosmos/src/HttpClient/HttpTimeoutPolicy.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ public static HttpTimeoutPolicy GetTimeoutPolicy(
2929
return HttpTimeoutPolicyControlPlaneRetriableHotPath.InstanceShouldThrow503OnTimeout;
3030
}
3131

32-
//Partition Key Requests
33-
if (documentServiceRequest.ResourceType == ResourceType.PartitionKeyRange)
32+
//Get Partition Key Range Requests
33+
if (documentServiceRequest.ResourceType == ResourceType.PartitionKeyRange
34+
&& documentServiceRequest.OperationType == OperationType.ReadFeed)
35+
{
36+
return HttpTimeoutPolicyControlPlaneRetriableHotPath.InstanceShouldThrow503OnTimeout;
37+
}
38+
39+
//Get Addresses Requests
40+
if (documentServiceRequest.ResourceType == ResourceType.Address)
3441
{
3542
return HttpTimeoutPolicyControlPlaneRetriableHotPath.Instance;
3643
}
@@ -44,7 +51,7 @@ public static HttpTimeoutPolicy GetTimeoutPolicy(
4451
//Meta Data Read
4552
if (HttpTimeoutPolicy.IsMetaData(documentServiceRequest) && documentServiceRequest.IsReadOnlyRequest)
4653
{
47-
return HttpTimeoutPolicyDefault.InstanceShouldThrow503OnTimeout;
54+
return HttpTimeoutPolicyControlPlaneRetriableHotPath.InstanceShouldThrow503OnTimeout;
4855
}
4956

5057
//Default behavior

Microsoft.Azure.Cosmos/src/Linq/CosmosLinqQuery.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace Microsoft.Azure.Cosmos.Linq
1212
using System.Threading;
1313
using System.Threading.Tasks;
1414
using Microsoft.Azure.Cosmos.Diagnostics;
15-
using Microsoft.Azure.Cosmos.Query;
1615
using Microsoft.Azure.Cosmos.Query.Core;
16+
using Microsoft.Azure.Cosmos.Serializer;
1717
using Microsoft.Azure.Cosmos.Tracing;
1818
using Newtonsoft.Json;
1919

@@ -32,7 +32,7 @@ internal sealed class CosmosLinqQuery<T> : IDocumentQuery<T>, IOrderedQueryable<
3232
private readonly QueryRequestOptions cosmosQueryRequestOptions;
3333
private readonly bool allowSynchronousQueryExecution = false;
3434
private readonly string continuationToken;
35-
private readonly CosmosLinqSerializerOptions linqSerializationOptions;
35+
private readonly CosmosLinqSerializerOptionsInternal linqSerializationOptions;
3636

3737
public CosmosLinqQuery(
3838
ContainerInternal container,
@@ -42,7 +42,7 @@ public CosmosLinqQuery(
4242
QueryRequestOptions cosmosQueryRequestOptions,
4343
Expression expression,
4444
bool allowSynchronousQueryExecution,
45-
CosmosLinqSerializerOptions linqSerializationOptions = null)
45+
CosmosLinqSerializerOptionsInternal linqSerializationOptions = null)
4646
{
4747
this.container = container ?? throw new ArgumentNullException(nameof(container));
4848
this.responseFactory = responseFactory ?? throw new ArgumentNullException(nameof(responseFactory));
@@ -72,7 +72,7 @@ public CosmosLinqQuery(
7272
string continuationToken,
7373
QueryRequestOptions cosmosQueryRequestOptions,
7474
bool allowSynchronousQueryExecution,
75-
CosmosLinqSerializerOptions linqSerializerOptions = null)
75+
CosmosLinqSerializerOptionsInternal linqSerializerOptions = null)
7676
: this(
7777
container,
7878
responseFactory,

Microsoft.Azure.Cosmos/src/Linq/CosmosLinqQueryProvider.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Microsoft.Azure.Cosmos.Linq
66
{
77
using System;
8-
using System.Collections.Generic;
98
using System.Linq;
109
using System.Linq.Expressions;
1110
using System.Threading;
@@ -24,7 +23,7 @@ internal sealed class CosmosLinqQueryProvider : IQueryProvider
2423
private readonly bool allowSynchronousQueryExecution;
2524
private readonly Action<IQueryable> onExecuteScalarQueryCallback;
2625
private readonly string continuationToken;
27-
private readonly CosmosLinqSerializerOptions linqSerializerOptions;
26+
private readonly CosmosLinqSerializerOptionsInternal linqSerializerOptions;
2827

2928
public CosmosLinqQueryProvider(
3029
ContainerInternal container,
@@ -34,7 +33,7 @@ public CosmosLinqQueryProvider(
3433
QueryRequestOptions cosmosQueryRequestOptions,
3534
bool allowSynchronousQueryExecution,
3635
Action<IQueryable> onExecuteScalarQueryCallback = null,
37-
CosmosLinqSerializerOptions linqSerializerOptions = null)
36+
CosmosLinqSerializerOptionsInternal linqSerializerOptions = null)
3837
{
3938
this.container = container;
4039
this.responseFactory = responseFactory;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
//------------------------------------------------------------
4+
namespace Microsoft.Azure.Cosmos.Linq
5+
{
6+
using System;
7+
using System.Globalization;
8+
using System.IO;
9+
using System.Linq.Expressions;
10+
using System.Reflection;
11+
12+
internal class CustomCosmosLinqSerializer : ICosmosLinqSerializerInternal
13+
{
14+
private readonly CosmosLinqSerializer CustomCosmosSerializer;
15+
16+
public CustomCosmosLinqSerializer(CosmosLinqSerializer customCosmosLinqSerializer)
17+
{
18+
this.CustomCosmosSerializer = customCosmosLinqSerializer;
19+
}
20+
21+
public bool RequiresCustomSerialization(MemberExpression memberExpression, Type memberType)
22+
{
23+
return true;
24+
}
25+
26+
public string Serialize(object value, MemberExpression memberExpression, Type memberType)
27+
{
28+
return this.SerializeWithCustomSerializer(value);
29+
}
30+
31+
public string SerializeScalarExpression(ConstantExpression inputExpression)
32+
{
33+
return this.SerializeWithCustomSerializer(inputExpression.Value);
34+
}
35+
36+
public string SerializeMemberName(MemberInfo memberInfo)
37+
{
38+
return this.CustomCosmosSerializer.SerializeMemberName(memberInfo);
39+
}
40+
41+
private string SerializeWithCustomSerializer(object value)
42+
{
43+
StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);
44+
45+
using (Stream stream = this.CustomCosmosSerializer.ToStream(value))
46+
{
47+
using (StreamReader streamReader = new StreamReader(stream))
48+
{
49+
string propertyValue = streamReader.ReadToEnd();
50+
writer.Write(propertyValue);
51+
return writer.ToString();
52+
}
53+
}
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)