From f56073707c2dedc2b054bb66a5dc4e72150cc5a3 Mon Sep 17 00:00:00 2001 From: RAMAKANT BHANDARU Date: Tue, 7 May 2024 09:33:01 -0400 Subject: [PATCH 1/2] Issue217 - Rollback transaction before throwing error when an orchestration instance has already been created by another process/thread. This is to prevent deadlocks as explained in the issue. --- src/DurableTask.SqlServer/Scripts/logic.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DurableTask.SqlServer/Scripts/logic.sql b/src/DurableTask.SqlServer/Scripts/logic.sql index 9e6fef2..e6807d8 100644 --- a/src/DurableTask.SqlServer/Scripts/logic.sql +++ b/src/DurableTask.SqlServer/Scripts/logic.sql @@ -260,6 +260,7 @@ BEGIN IF @existingStatus IN (SELECT value FROM STRING_SPLIT(@DedupeStatuses, ',')) BEGIN DECLARE @msg nvarchar(4000) = FORMATMESSAGE('Cannot create instance with ID ''%s'' because a pending or running instance with ID already exists.', @InstanceID); + ROLLBACK TRANSACTION; THROW 50001, @msg, 1; END ELSE IF @existingStatus IS NOT NULL From 18f8bf683510c03a5f0be54094c6ed1e9b824549 Mon Sep 17 00:00:00 2001 From: Chris Gillum Date: Tue, 7 May 2024 10:48:56 -0700 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad768b9..4366090 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Updates * Replace hardcoded version string + globs with build variables ([#213](https://github.com/microsoft/durabletask-mssql/pull/213)) +* Fix deadlock issue on orchestration creation ([#218](https://github.com/microsoft/durabletask-mssql/pull/218)) - contributed by [@microrama](https://github.com/microrama) ## v1.2.3