Skip to content

Add a way to fail lock acquisitions for poison message handling#743

Open
sophiatev wants to merge 2 commits into
mainfrom
stevosyan/add-poison-message-handling
Open

Add a way to fail lock acquisitions for poison message handling#743
sophiatev wants to merge 2 commits into
mainfrom
stevosyan/add-poison-message-handling

Conversation

@sophiatev

Copy link
Copy Markdown
Contributor

Summary

This PR introduces a new exception that is thrown in the case an entity lock acquisition fails. This can be the case if the lock request is considered "poisoned" by the dispatchers.

Why is this change needed?

This is to support poison message handling as introduced by this PR in DT.Core.

Copilot AI review requested due to automatic review settings June 12, 2026 18:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an explicit failure path for entity lock acquisition so orchestrations can surface “poisoned” lock requests as a dedicated exception, enabling poison message handling scenarios.

Changes:

  • Throw EntityLockAcquisitionFailedException when the lock acquisition response indicates an error (OperationResult.IsError).
  • Add a new public EntityLockAcquisitionFailedException type in Microsoft.DurableTask.Entities that carries EntityIds and FailureDetails.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Worker/Core/Shims/TaskOrchestrationEntityContext.cs Throws a new exception (and abandons acquire) when lock acquisition returns an error result.
src/Abstractions/Entities/EntityLockAcquisitionFailedException.cs Introduces the new exception type surfaced to SDK consumers for lock acquisition failures.

Comment on lines +6 to +12
/// <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 +20 to +41
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}";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants