Skip to content
Open
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
41 changes: 41 additions & 0 deletions src/Abstractions/Entities/EntityLockAcquisitionFailedException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.DurableTask.Entities;

/// <summary>
/// Exception that gets thrown when an entity operation fails with an unhandled exception.
/// </summary>
/// <remarks>
/// Detailed information associated with a particular operation failure, including exception details, can be found in the
/// <see cref="FailureDetails"/> property.
/// </remarks>
Comment on lines +6 to +12
public sealed class EntityLockAcquisitionFailedException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="EntityLockAcquisitionFailedException"/> class.
/// </summary>
/// <param name="entityIds">The entity IDs being locked.</param>
/// <param name="failureDetails">The failure details.</param>
public EntityLockAcquisitionFailedException(IEnumerable<EntityInstanceId> entityIds, TaskFailureDetails failureDetails)
: base(GetExceptionMessage(entityIds, failureDetails))
{
this.EntityIds = entityIds;
this.FailureDetails = failureDetails;
}

/// <summary>
/// Gets the IDs of the entities for which the lock request was issued.
/// </summary>
public IEnumerable<EntityInstanceId> EntityIds { get; }

/// <summary>
/// Gets the details of the task failure, including exception information.
/// </summary>
public TaskFailureDetails FailureDetails { get; }

static string GetExceptionMessage(IEnumerable<EntityInstanceId> entityIds, TaskFailureDetails failureDetails)
{
return $"Acquisition of locks for entities '{string.Join(",", entityIds)}' failed: {failureDetails.ErrorMessage}";
}
}
Comment on lines +20 to +41
10 changes: 8 additions & 2 deletions src/Worker/Core/Shims/TaskOrchestrationEntityContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,14 @@

this.wrapper.innerContext.SendEvent(entityMessageEvent.TargetInstance, entityMessageEvent.EventName, entityMessageEvent.AsRawInput());

OperationResult result = await this.wrapper.WaitForExternalEvent<OperationResult>(criticalSectionId.ToString());

OperationResult result = await this.wrapper.WaitForExternalEvent<OperationResult>(criticalSectionId.ToString());

if (result.IsError)
{
this.EntityContext.AbandonAcquire();

Check failure on line 85 in src/Worker/Core/Shims/TaskOrchestrationEntityContext.cs

View workflow job for this annotation

GitHub Actions / smoke-tests

'OrchestrationEntityContext' does not contain a definition for 'AbandonAcquire' and no accessible extension method 'AbandonAcquire' accepting a first argument of type 'OrchestrationEntityContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in src/Worker/Core/Shims/TaskOrchestrationEntityContext.cs

View workflow job for this annotation

GitHub Actions / smoke-tests

'OrchestrationEntityContext' does not contain a definition for 'AbandonAcquire' and no accessible extension method 'AbandonAcquire' accepting a first argument of type 'OrchestrationEntityContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in src/Worker/Core/Shims/TaskOrchestrationEntityContext.cs

View workflow job for this annotation

GitHub Actions / build

'OrchestrationEntityContext' does not contain a definition for 'AbandonAcquire' and no accessible extension method 'AbandonAcquire' accepting a first argument of type 'OrchestrationEntityContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in src/Worker/Core/Shims/TaskOrchestrationEntityContext.cs

View workflow job for this annotation

GitHub Actions / build

'OrchestrationEntityContext' does not contain a definition for 'AbandonAcquire' and no accessible extension method 'AbandonAcquire' accepting a first argument of type 'OrchestrationEntityContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in src/Worker/Core/Shims/TaskOrchestrationEntityContext.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'OrchestrationEntityContext' does not contain a definition for 'AbandonAcquire' and no accessible extension method 'AbandonAcquire' accepting a first argument of type 'OrchestrationEntityContext' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in src/Worker/Core/Shims/TaskOrchestrationEntityContext.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'OrchestrationEntityContext' does not contain a definition for 'AbandonAcquire' and no accessible extension method 'AbandonAcquire' accepting a first argument of type 'OrchestrationEntityContext' could be found (are you missing a using directive or an assembly reference?)
throw new EntityLockAcquisitionFailedException(entityIds, ConvertFailureDetails(result.FailureDetails!));
}

this.EntityContext.CompleteAcquire(result, criticalSectionId);

// return an IDisposable that releases the lock
Expand Down
Loading