Add a way to fail lock acquisitions for poison message handling#743
Open
sophiatev wants to merge 2 commits into
Open
Add a way to fail lock acquisitions for poison message handling#743sophiatev wants to merge 2 commits into
sophiatev wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
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
EntityLockAcquisitionFailedExceptionwhen the lock acquisition response indicates an error (OperationResult.IsError). - Add a new public
EntityLockAcquisitionFailedExceptiontype inMicrosoft.DurableTask.Entitiesthat carriesEntityIdsandFailureDetails.
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}"; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.