ResourceNotFound exception during concurrent orchestrationService.PurgeInstanceHistoryAsync call
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- azure, csharp
- Domain
- backend, databases, distributed-systems
Research direction
Start with PurgeInstanceHistoryAsync in src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs and the tracking-store deletion logic in src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs. Investigate concurrent purge calls for the same instances and determine whether ResourceNotFound is expected; done requires an agreed fix or documented guidance for concurrent cleanup.
Written by the indexing model from the issue text.
Description
Problem statement
We have implemented a background clean up service that cleans up orchestrations in terminal state using the orchestrationService.PurgeInstanceHistoryAsync https://github.com/Azure/durabletask/blob/6d09d0353383e25caba94bdee862532b6175a847/src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs#L1986 periodically every 12 hrs. We recently got DurableTaskStorageException with an inner exception of TableTransactionFailedException with error code ResourceNotFound.
Setup
- The background clean up service runs on multiple pods and therefore there can be Purge call on same instance multiple times.
- Each orchestration instance has 6-7 activities.
Investigation findings
- This exception is usually thrown when there are lots of instances to be cleaned
- Underlying logic in tracking store lists all instances within the time window and individually calls delete instance on them. Refer https://github.com/Azure/durabletask/blob/1514129bac2cbdc67b664fca61f919ff1c225ee3/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs#L576. We believe this to be the cause of exception. As background clean up runs on multiple pods, it is possible that delete is called on an already deleted instance which causes this ResourceNotFound exception. This also aligns with the first observation as the chances of this happening increase as the number of instances to be deleted increase.
Possible solutions
- Is it advised to clean up orchestration once it is completed? This would reduce the load on the background clean up service and even remove its requirement altogether.
- We could move the background clean up to a separate service altogether (right now it is running in the same service that has orchestration logic), but could that impact locks and produce latencies in already running orchestration? I believe not as there is no locking logic in the purge call.
- Is there any general advice on performing purge of the instances?
- Dominant language
- C#
- Stars
- 1.7k
- Forks
- 335
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 6
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/durabletask
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Azure/durabletask#1398 · 2 comments ·
-
Azure/durabletask#1389 · 1 comment · 1 assignee ·
-
Difficulty 3/5 1-2 days Newbie friendliness 74/100
Azure/durabletask#1376 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Azure/durabletask#1378 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Azure/durabletask#1332 ·
All issues in Azure/durabletask
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nightscout/nocturne#1379 ·
-
priority-0
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
StackExchange/StackExchange.Redis#3249 ·
-
[Feat] 조합 영역 구분선 개선 Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100