Skip to content

Commit 9327fa5

Browse files
Merge branch 'master' into users/Meghana-Palaparthi/DTS_openspec
2 parents 1da7b52 + 71d317f commit 9327fa5

47 files changed

Lines changed: 1377 additions & 225 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.

CODEOWNERS

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
# the repo. Unless a later match takes precedence,
66
# @global-owner1 and @global-owner2 will be requested for
77
# review when someone opens a pull request.
8-
* @kirankumarkolli @FabianMeiswinkel @sboshra @Pilchie
9-
Microsoft.Azure.Cosmos/src/Json @adityasa @neildsh @kirankumarkolli @sboshra
10-
Microsoft.Azure.Cosmos/src/Query @adityasa @neildsh @kirankumarkolli @sboshra
11-
Microsoft.Azure.Cosmos/src/CosmosElements @adityasa @neildsh @kirankumarkolli @sboshra
12-
Microsoft.Azure.Cosmos/src/SqlObjects @leminh98 @adityasa @kirankumarkolli @sboshra
13-
Microsoft.Azure.Cosmos/src/Linq @khdang @adityasa @sboshra @kirankumarkolli
14-
Microsoft.Azure.Cosmos/src/Spatial @neildsh @adityasa @sboshra @kirankumarkolli
15-
Microsoft.Azure.Cosmos/tests @khdang @sboshra @adityasa @neildsh @kirankumarkolli @FabianMeiswinkel @kirillg
16-
Microsoft.Azure.Cosmos.Samples @khdang @sboshra @adityasa @neildsh @kirankumarkolli @FabianMeiswinkel @kirillg
8+
* @kirankumarkolli @FabianMeiswinkel @sboshra @Pilchie @kushagraThapar
9+
Microsoft.Azure.Cosmos/src/Json @adityasa @neildsh @kirankumarkolli @sboshra @kushagraThapar
10+
Microsoft.Azure.Cosmos/src/Query @adityasa @neildsh @kirankumarkolli @sboshra @kushagraThapar
11+
Microsoft.Azure.Cosmos/src/CosmosElements @adityasa @neildsh @kirankumarkolli @sboshra @kushagraThapar
12+
Microsoft.Azure.Cosmos/src/SqlObjects @leminh98 @adityasa @kirankumarkolli @sboshra @kushagraThapar
13+
Microsoft.Azure.Cosmos/src/Linq @khdang @adityasa @sboshra @kirankumarkolli @kushagraThapar
14+
Microsoft.Azure.Cosmos/src/Spatial @neildsh @adityasa @sboshra @kirankumarkolli @kushagraThapar
15+
Microsoft.Azure.Cosmos/tests @khdang @sboshra @adityasa @neildsh @kirankumarkolli @FabianMeiswinkel @kirillg @kushagraThapar
16+
Microsoft.Azure.Cosmos.Samples @khdang @sboshra @adityasa @neildsh @kirankumarkolli @FabianMeiswinkel @kirillg @kushagraThapar
1717

1818
# Order is important; the last matching pattern takes the most precedence
19-
Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts @kirillg @kirankumarkolli @FabianMeiswinkel
20-
Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Contracts @kirillg @kirankumarkolli @FabianMeiswinkel
19+
Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts @kirillg @kirankumarkolli @FabianMeiswinkel @kushagraThapar
20+
Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Contracts @kirillg @kirankumarkolli @FabianMeiswinkel @kushagraThapar
2121
Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json @Azure/azure-cosmosdb-lt
2222
Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json @Azure/azure-cosmosdb-lt
2323
Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKTelemetryAPI.json @Azure/azure-cosmosdb-lt

Directory.Build.props

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

Microsoft.Azure.Cosmos.Samples/Usage/HttpClientFactory/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@ private static void ShareHttpHandlers(
193193
{
194194
PooledConnectionLifetime = TimeSpan.FromMinutes(10), // Customize this value based on desired DNS refresh timer
195195
MaxConnectionsPerServer = 20, // Customize the maximum number of allowed connections
196-
EnableMultipleHttp2Connections = true // Recommended for thin client (HTTP/2) mode to open additional connections when stream limits are reached
196+
EnableMultipleHttp2Connections = true, // Recommended for thin client (HTTP/2) mode to open additional connections when stream limits are reached
197+
KeepAlivePingDelay = TimeSpan.FromSeconds(1), // Send HTTP/2 PING after 1s of inactivity to detect broken connections
198+
KeepAlivePingTimeout = TimeSpan.FromSeconds(2), // Mark connection dead if no PONG within 2s
199+
KeepAlivePingPolicy = HttpKeepAlivePingPolicy.Always
197200
};
198201

199202
CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()

Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/LeaseManagement/DocumentServiceLeaseManagerCosmos.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ internal sealed class DocumentServiceLeaseManagerCosmos : DocumentServiceLeaseMa
3131
private readonly AsyncLazy<TryCatch<string>> lazyContainerRid;
3232
private PartitionKeyRangeCache partitionKeyRangeCache;
3333

34+
internal static bool IsChangeFeedLeaseIdAsPartitionKeyEnabled = ConfigurationManager.IsChangeFeedLeaseIdAsPartitionKeyEnabled();
35+
3436
public DocumentServiceLeaseManagerCosmos(
3537
ContainerInternal monitoredContainer,
3638
ContainerInternal leaseContainer,
@@ -128,7 +130,9 @@ public override Task<DocumentServiceLease> CreateLeaseIfNotExistAsync(
128130
Mode = this.GetChangeFeedMode()
129131
};
130132

131-
this.requestOptionsFactory.AddPartitionKeyIfNeeded((string pk) => documentServiceLease.LeasePartitionKey = pk, Guid.NewGuid().ToString());
133+
this.requestOptionsFactory.AddPartitionKeyIfNeeded(
134+
(string pk) => documentServiceLease.LeasePartitionKey = pk,
135+
DocumentServiceLeaseManagerCosmos.GetLeasePartitionKeyValue(documentServiceLease.LeaseId));
132136

133137
return this.TryCreateDocumentServiceLeaseAsync(documentServiceLease);
134138
}
@@ -153,11 +157,20 @@ public override Task<DocumentServiceLease> CreateLeaseIfNotExistAsync(
153157
Mode = this.GetChangeFeedMode()
154158
};
155159

156-
this.requestOptionsFactory.AddPartitionKeyIfNeeded((string pk) => documentServiceLease.LeasePartitionKey = pk, Guid.NewGuid().ToString());
160+
this.requestOptionsFactory.AddPartitionKeyIfNeeded(
161+
(string pk) => documentServiceLease.LeasePartitionKey = pk,
162+
DocumentServiceLeaseManagerCosmos.GetLeasePartitionKeyValue(documentServiceLease.LeaseId));
157163

158164
return this.TryCreateDocumentServiceLeaseAsync(documentServiceLease);
159165
}
160166

167+
private static string GetLeasePartitionKeyValue(string leaseId)
168+
{
169+
return DocumentServiceLeaseManagerCosmos.IsChangeFeedLeaseIdAsPartitionKeyEnabled
170+
? leaseId
171+
: Guid.NewGuid().ToString();
172+
}
173+
161174
private string GetChangeFeedMode()
162175
{
163176
return this.options.Mode == ChangeFeedMode.AllVersionsAndDeletes

Microsoft.Azure.Cosmos/src/CosmosClientOptions.cs

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,19 @@ public string ApplicationName
244244
/// </summary>
245245
/// <remarks>
246246
/// This setting is only applicable in Gateway mode.
247-
/// The SDK sets EnableMultipleHttp2Connections = true on the underlying SocketsHttpHandler,
248-
/// allowing additional HTTP/2 TCP connections to be opened when the maximum concurrent streams
249-
/// limit on an existing connection is reached. This property controls the upper bound on the
250-
/// total number of connections per server endpoint.
251-
/// When using a custom <see cref="HttpClientFactory"/>, set EnableMultipleHttp2Connections
247+
/// The SDK sets the following on the underlying SocketsHttpHandler:
248+
/// <list type="bullet">
249+
/// <item><description>EnableMultipleHttp2Connections = true — allows additional HTTP/2 TCP connections
250+
/// to be opened when the maximum concurrent streams limit on an existing connection is reached.</description></item>
251+
/// <item><description>KeepAlivePingDelay = 1 second — sends HTTP/2 PING frames after 1 second
252+
/// of inactivity to detect broken connections in the pool.</description></item>
253+
/// <item><description>KeepAlivePingTimeout = 2 seconds — marks a connection as dead if no PONG
254+
/// response is received within 2 seconds.</description></item>
255+
/// <item><description>KeepAlivePingPolicy = Always — sends pings even for idle connections, which
256+
/// is critical for detecting broken connections that remain in the pool.</description></item>
257+
/// </list>
258+
/// This property controls the upper bound on the total number of connections per server endpoint.
259+
/// When using a custom <see cref="HttpClientFactory"/>, configure these properties
252260
/// directly on your SocketsHttpHandler for equivalent behavior.
253261
/// </remarks>
254262
/// <example>
@@ -268,7 +276,10 @@ public string ApplicationName
268276
/// SocketsHttpHandler handler = new SocketsHttpHandler
269277
/// {
270278
/// MaxConnectionsPerServer = 100,
271-
/// EnableMultipleHttp2Connections = true
279+
/// EnableMultipleHttp2Connections = true,
280+
/// KeepAlivePingDelay = TimeSpan.FromSeconds(1),
281+
/// KeepAlivePingTimeout = TimeSpan.FromSeconds(2),
282+
/// KeepAlivePingPolicy = HttpKeepAlivePingPolicy.Always
272283
/// };
273284
/// CosmosClientOptions options = new CosmosClientOptions()
274285
/// {
@@ -306,6 +317,24 @@ public int GatewayModeMaxConnectionLimit
306317
/// <seealso cref="CosmosClientBuilder.WithRequestTimeout(TimeSpan)"/>
307318
public TimeSpan RequestTimeout { get; set; }
308319

320+
/// <summary>
321+
/// Gets or sets the request timeout for inference service operations (e.g., semantic reranking).
322+
/// The number specifies the time to wait for a response from the inference service before the request is cancelled.
323+
/// This is a single-attempt timeout with no retries.
324+
/// </summary>
325+
/// <value>Default value is 5 seconds.</value>
326+
/// <remarks>
327+
/// This timeout is specific to inference service operations and is separate from the standard <see cref="RequestTimeout"/>.
328+
/// If the request does not complete within the specified duration, a <see cref="CosmosException"/> with status 408 (Request Timeout) is thrown.
329+
/// No retries are attempted on timeout.
330+
/// </remarks>
331+
#if PREVIEW
332+
public
333+
#else
334+
internal
335+
#endif
336+
TimeSpan InferenceRequestTimeout { get; set; } = InferenceService.DefaultInferenceRequestTimeout;
337+
309338
/// <summary>
310339
/// The SDK does a background refresh based on the time interval set to refresh the token credentials.
311340
/// This avoids latency issues because the old token is used until the new token is retrieved.
@@ -474,6 +503,7 @@ public ConnectionMode ConnectionMode
474503
/// ]]>
475504
/// </code>
476505
/// </example>
506+
[JsonConverter(typeof(ClientOptionJsonConverter))]
477507
public System.Text.Json.JsonSerializerOptions UseSystemTextJsonSerializerWithOptions
478508
{
479509
get => this.stjSerializerOptions;
@@ -1372,14 +1402,19 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
13721402
return;
13731403
}
13741404

1375-
CosmosJsonSerializerWrapper cosmosJsonSerializerWrapper = value as CosmosJsonSerializerWrapper;
1376-
if (value is CosmosJsonSerializerWrapper)
1405+
if (value is System.Text.Json.JsonSerializerOptions)
1406+
{
1407+
writer.WriteValue(value.GetType().ToString());
1408+
return;
1409+
}
1410+
1411+
if (value is CosmosJsonSerializerWrapper cosmosJsonSerializerWrapper)
13771412
{
13781413
writer.WriteValue(cosmosJsonSerializerWrapper.InternalJsonSerializer.GetType().ToString());
1414+
return;
13791415
}
13801416

1381-
CosmosSerializer cosmosSerializer = value as CosmosSerializer;
1382-
if (cosmosSerializer is CosmosSerializer)
1417+
if (value is CosmosSerializer cosmosSerializer)
13831418
{
13841419
writer.WriteValue(cosmosSerializer.GetType().ToString());
13851420
}

Microsoft.Azure.Cosmos/src/DistributedTransaction/DistributedTransactionOperation.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ------------------------------------------------------------
1+
// ------------------------------------------------------------
22
// Copyright (c) Microsoft Corporation. All rights reserved.
33
// ------------------------------------------------------------
44

@@ -78,19 +78,6 @@ internal virtual async Task MaterializeResourceAsync(CosmosSerializerCore serial
7878

7979
internal class DistributedTransactionOperation<T> : DistributedTransactionOperation
8080
{
81-
public DistributedTransactionOperation(
82-
Documents.OperationType operationType,
83-
int operationIndex,
84-
string database,
85-
string container,
86-
PartitionKey partitionKey,
87-
T resource,
88-
DistributedTransactionRequestOptions requestOptions = null)
89-
: base(operationType, operationIndex, database, container, partitionKey, id: null, requestOptions)
90-
{
91-
this.Resource = resource;
92-
}
93-
9481
public DistributedTransactionOperation(
9582
Documents.OperationType operationType,
9683
int operationIndex,

Microsoft.Azure.Cosmos/src/DistributedTransaction/DistributedTransactionSerializer.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace Microsoft.Azure.Cosmos
66
{
77
using System;
88
using System.Collections.Generic;
9+
using System.Diagnostics;
910
using System.IO;
1011
using System.Text.Json;
1112
using Microsoft.Azure.Documents;
@@ -62,6 +63,9 @@ private static void WriteOperation(Utf8JsonWriter jsonWriter, DistributedTransac
6263
// collectionName
6364
jsonWriter.WriteString("collectionName", operation.Container);
6465

66+
// id
67+
jsonWriter.WriteString("id", operation.Id);
68+
6569
// collectionResourceId
6670
if (operation.CollectionResourceId != null)
6771
{
@@ -74,12 +78,6 @@ private static void WriteOperation(Utf8JsonWriter jsonWriter, DistributedTransac
7478
jsonWriter.WriteString("databaseResourceId", operation.DatabaseResourceId);
7579
}
7680

77-
// id
78-
if (operation.Id != null)
79-
{
80-
jsonWriter.WriteString("id", operation.Id);
81-
}
82-
8381
// partitionKey
8482
if (operation.PartitionKeyJson != null)
8583
{

Microsoft.Azure.Cosmos/src/DistributedTransaction/DistributedWriteTransaction.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ abstract class DistributedWriteTransaction : DistributedTransaction
2424
/// <param name="database">The name of the database containing the container.</param>
2525
/// <param name="collection">The name of the container where the item will be created.</param>
2626
/// <param name="partitionKey">The partition key for the item.</param>
27+
/// <param name="id">The unique identifier of the item to create.</param>
2728
/// <param name="resource">The resource to create.</param>
2829
/// <param name="requestOptions">Options for the create operation.</param>
2930
/// <returns>The current <see cref="DistributedWriteTransaction"/> instance for method chaining.</returns>
3031
public abstract DistributedWriteTransaction CreateItem<T>(
3132
string database,
3233
string collection,
3334
PartitionKey partitionKey,
35+
string id,
3436
T resource,
3537
DistributedTransactionRequestOptions requestOptions = null);
3638

@@ -40,13 +42,15 @@ public abstract DistributedWriteTransaction CreateItem<T>(
4042
/// <param name="database">The name of the database containing the container.</param>
4143
/// <param name="collection">The name of the container where the item will be created.</param>
4244
/// <param name="partitionKey">The partition key for the item.</param>
45+
/// <param name="id">The unique identifier of the item to create.</param>
4346
/// <param name="streamPayload">A <see cref="Stream"/> containing the JSON serialization of the item.</param>
4447
/// <param name="requestOptions">Options for the create operation.</param>
4548
/// <returns>The current <see cref="DistributedWriteTransaction"/> instance for method chaining.</returns>
4649
public abstract DistributedWriteTransaction CreateItemStream(
4750
string database,
4851
string collection,
4952
PartitionKey partitionKey,
53+
string id,
5054
Stream streamPayload,
5155
DistributedTransactionRequestOptions requestOptions = null);
5256

@@ -147,13 +151,15 @@ public abstract DistributedWriteTransaction PatchItemStream(
147151
/// <param name="database">The name of the database containing the container.</param>
148152
/// <param name="collection">The name of the container where the item will be upserted.</param>
149153
/// <param name="partitionKey">The partition key for the item.</param>
154+
/// <param name="id">The unique identifier of the item to upsert.</param>
150155
/// <param name="resource">The resource to upsert.</param>
151156
/// <param name="requestOptions">Options for the upsert operation.</param>
152157
/// <returns>The current <see cref="DistributedWriteTransaction"/> instance for method chaining.</returns>
153158
public abstract DistributedWriteTransaction UpsertItem<T>(
154159
string database,
155160
string collection,
156161
PartitionKey partitionKey,
162+
string id,
157163
T resource,
158164
DistributedTransactionRequestOptions requestOptions = null);
159165

@@ -164,13 +170,15 @@ public abstract DistributedWriteTransaction UpsertItem<T>(
164170
/// <param name="database">The name of the database containing the container.</param>
165171
/// <param name="collection">The name of the container where the item will be upserted.</param>
166172
/// <param name="partitionKey">The partition key for the item.</param>
173+
/// <param name="id">The unique identifier of the item to upsert.</param>
167174
/// <param name="streamPayload">A <see cref="Stream"/> containing the JSON serialization of the item.</param>
168175
/// <param name="requestOptions">Options for the upsert operation.</param>
169176
/// <returns>The current <see cref="DistributedWriteTransaction"/> instance for method chaining.</returns>
170177
public abstract DistributedWriteTransaction UpsertItemStream(
171178
string database,
172179
string collection,
173180
PartitionKey partitionKey,
181+
string id,
174182
Stream streamPayload,
175183
DistributedTransactionRequestOptions requestOptions = null);
176184
}

0 commit comments

Comments
 (0)