Skip to content

Commit a16c8ed

Browse files
authored
Merge branch 'main' into wangbill/largepayloadv2
2 parents a5b5bd1 + 06de0be commit a16c8ed

File tree

11 files changed

+750
-30
lines changed

11 files changed

+750
-30
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
2-
2+
## v1.15.0
3+
- Abandon workitem if processing workitem failed by @YunchuWang in ([#467](https://github.com/microsoft/durabletask-dotnet/pull/467))
4+
- Extended Sessions for Isolated (Orchestrations) by @sophiatev in ([#449](https://github.com/microsoft/durabletask-dotnet/pull/449))
5+
36
## v1.14.0
47
- Add RestartAsync API Support at DurableTaskClient ([#456](https://github.com/microsoft/durabletask-dotnet/pull/456))
58

@@ -292,3 +295,4 @@ Microsoft.DurableTask.Generators
292295
## v0.4.1-beta
293296

294297
Initial public release
298+

Directory.Packages.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
<!-- Microsoft.Extensions.* Packages -->
1111
<ItemGroup>
12+
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="6.0.3" />
1213
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
1314
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="6.0.2" />
1415
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
@@ -29,7 +30,7 @@
2930

3031
<!-- DurableTask Packages -->
3132
<ItemGroup>
32-
<PackageVersion Include="Microsoft.Azure.DurableTask.Core" Version="3.3.0" />
33+
<PackageVersion Include="Microsoft.Azure.DurableTask.Core" Version="3.4.0" />
3334
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.2.2" />
3435
</ItemGroup>
3536

eng/targets/Release.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</PropertyGroup>
1818

1919
<PropertyGroup>
20-
<VersionPrefix>1.14.0</VersionPrefix>
20+
<VersionPrefix>1.15.0</VersionPrefix>
2121
<VersionSuffix></VersionSuffix>
2222
</PropertyGroup>
2323

src/Grpc/orchestrator_service.proto

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ message OrchestratorResponse {
342342
// The number of work item events that were processed by the orchestrator.
343343
// This field is optional. If not set, the service should assume that the orchestrator processed all events.
344344
google.protobuf.Int32Value numEventsProcessed = 5;
345-
346345
OrchestrationTraceContext orchestrationTraceContext = 6;
346+
347+
// Whether or not a history is required to complete the original OrchestratorRequest and none was provided.
348+
bool requiresHistory = 7;
347349
}
348350

349351
message CreateInstanceRequest {
@@ -678,6 +680,18 @@ message AbandonEntityTaskResponse {
678680
// Empty.
679681
}
680682

683+
message SkipGracefulOrchestrationTerminationsRequest {
684+
// A maximum of 500 instance IDs can be provided in this list.
685+
repeated string instanceIds = 1;
686+
google.protobuf.StringValue reason = 2;
687+
}
688+
689+
message SkipGracefulOrchestrationTerminationsResponse {
690+
// Those instances which could not be terminated because they had locked entities at the time of this termination call,
691+
// are already in a terminal state (completed, failed, terminated, etc.), are not orchestrations, or do not exist (i.e. have been purged)
692+
repeated string unterminatedInstanceIds = 1;
693+
}
694+
681695
service TaskHubSidecarService {
682696
// Sends a hello request to the sidecar service.
683697
rpc Hello(google.protobuf.Empty) returns (google.protobuf.Empty);
@@ -751,6 +765,10 @@ service TaskHubSidecarService {
751765

752766
// Abandon an entity work item
753767
rpc AbandonTaskEntityWorkItem(AbandonEntityTaskRequest) returns (AbandonEntityTaskResponse);
768+
769+
// "Skip" graceful termination of orchestrations by immediately changing their status in storage to "terminated".
770+
// Note that a maximum of 500 orchestrations can be terminated at a time using this method.
771+
rpc SkipGracefulOrchestrationTerminations(SkipGracefulOrchestrationTerminationsRequest) returns (SkipGracefulOrchestrationTerminationsResponse);
754772
}
755773

756774
message GetWorkItemsRequest {

src/Grpc/versions.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# The following files were downloaded from branch main at 2025-09-10 22:50:45 UTC
2-
https://raw.githubusercontent.com/microsoft/durabletask-protobuf/985035a0890575ae18be0eb2a3ac93c10824498a/protos/orchestrator_service.proto
1+
# The following files were downloaded from branch main at 2025-09-17 01:45:58 UTC
2+
https://raw.githubusercontent.com/microsoft/durabletask-protobuf/f5745e0d83f608d77871c1894d9260ceaae08967/protos/orchestrator_service.proto

src/Shared/Grpc/ProtoUtils.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,19 @@ internal static Timestamp ToTimestamp(this DateTime dateTime)
279279
/// </param>
280280
/// <param name="entityConversionState">The entity conversion state, or null if no conversion is required.</param>
281281
/// <param name="orchestrationActivity">The <see cref="Activity" /> that represents orchestration execution.</param>
282+
/// <param name="requiresHistory">Whether or not a history is required to complete the orchestration request and none was provided.</param>
282283
/// <returns>The orchestrator response.</returns>
283284
/// <exception cref="NotSupportedException">When an orchestrator action is unknown.</exception>
284285
internal static P.OrchestratorResponse ConstructOrchestratorResponse(
285286
string instanceId,
286287
string executionId,
287288
string? customStatus,
288-
IEnumerable<OrchestratorAction> actions,
289+
IEnumerable<OrchestratorAction>? actions,
289290
string completionToken,
290291
EntityConversionState? entityConversionState,
291-
Activity? orchestrationActivity)
292+
Activity? orchestrationActivity,
293+
bool requiresHistory = false)
292294
{
293-
Check.NotNull(actions);
294295
var response = new P.OrchestratorResponse
295296
{
296297
InstanceId = instanceId,
@@ -302,8 +303,16 @@ internal static P.OrchestratorResponse ConstructOrchestratorResponse(
302303
SpanID = orchestrationActivity?.SpanId.ToString(),
303304
SpanStartTime = orchestrationActivity?.StartTimeUtc.ToTimestamp(),
304305
},
306+
RequiresHistory = requiresHistory,
305307
};
306308

309+
// If a history is required and the orchestration request was not completed, then there is no list of actions.
310+
if (requiresHistory)
311+
{
312+
return response;
313+
}
314+
315+
Check.NotNull(actions);
307316
foreach (OrchestratorAction action in actions)
308317
{
309318
var protoAction = new P.OrchestratorAction { Id = action.Id };
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using DurableTask.Core;
5+
6+
namespace Microsoft.DurableTask.Worker;
7+
8+
/// <summary>
9+
/// Represents the state of an extended session for an orchestration.
10+
/// </summary>
11+
public class ExtendedSessionState
12+
{
13+
/// <summary>
14+
/// Initializes a new instance of the <see cref="ExtendedSessionState"/> class.
15+
/// </summary>
16+
/// <param name="state">The orchestration's runtime state.</param>
17+
/// <param name="taskOrchestration">The TaskOrchestration implementation of the orchestration.</param>
18+
/// <param name="orchestrationExecutor">The TaskOrchestrationExecutor for the orchestration.</param>
19+
public ExtendedSessionState(OrchestrationRuntimeState state, TaskOrchestration taskOrchestration, TaskOrchestrationExecutor orchestrationExecutor)
20+
{
21+
this.RuntimeState = state;
22+
this.TaskOrchestration = taskOrchestration;
23+
this.OrchestrationExecutor = orchestrationExecutor;
24+
}
25+
26+
/// <summary>
27+
/// Gets or sets the saved runtime state of the orchestration.
28+
/// </summary>
29+
public OrchestrationRuntimeState RuntimeState { get; set; }
30+
31+
/// <summary>
32+
/// Gets or sets the saved TaskOrchestration implementation of the orchestration.
33+
/// </summary>
34+
public TaskOrchestration TaskOrchestration { get; set; }
35+
36+
/// <summary>
37+
/// Gets or sets the saved TaskOrchestrationExecutor.
38+
/// </summary>
39+
public TaskOrchestrationExecutor OrchestrationExecutor { get; set; }
40+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using Microsoft.Extensions.Caching.Memory;
5+
6+
namespace Microsoft.DurableTask.Worker;
7+
8+
/// <summary>
9+
/// A cache for extended sessions that wraps a <see cref="MemoryCache"/> instance.
10+
/// Responsible for holding <see cref="ExtendedSessionState"/> for orchestrations that are running within extended sessions.
11+
/// </summary>
12+
public class ExtendedSessionsCache : IDisposable
13+
{
14+
MemoryCache? extendedSessions;
15+
16+
/// <summary>
17+
/// Gets a value indicating whether returns whether or not the cache has been initialized.
18+
/// </summary>
19+
/// <returns>True if the cache has been initialized, false otherwise.</returns>
20+
public bool IsInitialized => this.extendedSessions is not null;
21+
22+
/// <summary>
23+
/// Dispose the cache and release all resources.
24+
/// </summary>
25+
public void Dispose()
26+
{
27+
this.extendedSessions?.Dispose();
28+
GC.SuppressFinalize(this);
29+
}
30+
31+
/// <summary>
32+
/// Gets the cache for extended sessions if it has already been initialized, or otherwise initializes it with the given expiration scan frequency.
33+
/// </summary>
34+
/// <param name="expirationScanFrequencyInSeconds">
35+
/// The expiration scan frequency of the cache, in seconds.
36+
/// This specifies how often the cache checks for stale items, and evicts them.
37+
/// </param>
38+
/// <returns>The IMemoryCache that holds the cached <see cref="ExtendedSessionState"/>.</returns>
39+
public MemoryCache GetOrInitializeCache(double expirationScanFrequencyInSeconds)
40+
{
41+
this.extendedSessions ??= new MemoryCache(new MemoryCacheOptions
42+
{
43+
ExpirationScanFrequency = TimeSpan.FromSeconds(expirationScanFrequencyInSeconds / 5),
44+
});
45+
46+
return this.extendedSessions;
47+
}
48+
}

src/Worker/Core/Worker.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The worker is responsible for processing durable task work items.</PackageDescri
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
1213
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
1314
<PackageReference Include="Microsoft.Extensions.Options" />
1415
<PackageReference Include="System.Text.Json" />

0 commit comments

Comments
 (0)