microsoft / durabletask-mssql

Microsoft SQL storage provider for Durable Functions and the Durable Task Framework
MIT License
87 stars 32 forks source link

Fix problem terminating orchestration with running activity #83

Closed cgillum closed 2 years ago

cgillum commented 2 years ago

Resolves #81

We were incorrectly raising an error from SQL if an activity task completes for an instance that's no longer running (e.g., a terminated instance). Because of this, we'd never delete the task-scheduled message, and it would re-execute continuously. This PR updates the _CompleteTasks sproc to handle this case correctly by ensuring we always delete the task-scheduled message.

While testing the fix, I also found an issue where we don't delete the task-scheduled message payloads after an activity completes (successfully or not), resulting in unreferenced payload data in the database (until the instance is purged). This is also fixed in this PR.