You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/DurableTask.SqlServer/Scripts/logic.sql
+17-5Lines changed: 17 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -420,7 +420,10 @@ BEGIN
420
420
421
421
-- The instance ID is not auto-start and doesn't already exist, so we fail.
422
422
IF@@ROWCOUNT=0
423
-
THROW50000, 'The instance does not exist.', 1;
423
+
BEGIN
424
+
ROLLBACKTRANSACTION;
425
+
THROW50000, 'The instance does not exist.', 1;
426
+
END
424
427
END
425
428
426
429
-- Payloads are stored separately from the events
@@ -473,8 +476,10 @@ BEGIN
473
476
)
474
477
475
478
IF @existingStatus ISNULL
479
+
BEGIN
480
+
ROLLBACKTRANSACTION;
476
481
THROW50000, 'The instance does not exist.', 1;
477
-
482
+
END
478
483
-- If the instance is already completed, no need to terminate it.
479
484
IF @existingStatus IN ('Pending', 'Running')
480
485
BEGIN
@@ -835,8 +840,10 @@ BEGIN
835
840
WHERE [TaskHub] = @TaskHub and [InstanceID] = @InstanceID
836
841
837
842
IF@@ROWCOUNT=0
843
+
BEGIN
844
+
ROLLBACKTRANSACTION;
838
845
THROW50000, 'The instance does not exist.', 1;
839
-
846
+
END
840
847
-- External event messages can create new instances
841
848
-- NOTE: There is a chance this could result in deadlocks if two
842
849
-- instances are sending events to each other at the same time
@@ -1079,7 +1086,10 @@ BEGIN
1079
1086
-- Ignore PK violations here, which can happen when multiple clients
1080
1087
-- try to add messages at the same time for the same instance
1081
1088
IFERROR_NUMBER() <>2627-- 2627 is PK violation
1082
-
THROW
1089
+
BEGIN
1090
+
ROLLBACKTRANSACTION;
1091
+
THROW;
1092
+
END
1083
1093
ENDCATCH
1084
1094
1085
1095
-- Insert new event data payloads into the Payloads table in batches.
@@ -1368,8 +1378,10 @@ BEGIN
1368
1378
-- This can happen if the message was completed by another worker, in which
1369
1379
-- case we don't want any of the side-effects to persist.
1370
1380
IF@@ROWCOUNT<> (SELECTCOUNT(*) FROM @CompletedTasks)
1381
+
BEGIN
1382
+
ROLLBACKTRANSACTION;
1371
1383
THROW50002, N'Failed to delete the completed task events(s). They may have been deleted by another worker, in which case the current execution is likely a duplicate. Any results or pending side-effects of this task activity execution will be discarded.', 1;
0 commit comments