Commit 6873dbe
authored
fix: archive task messages for skipped steps and handle late callbacks (#609)
# Archive Task Messages for Skipped Steps
This PR adds message archiving functionality to prevent "zombie" tasks from being processed after a step has been skipped or completed. Key improvements:
1. Added guards in `complete_task` and `fail_task` to handle late callbacks:
- Detects when callbacks arrive after a step is no longer in 'started' state
- Archives the task message to prevent stuck work
- Returns current task state without mutating step or run state
2. Enhanced `_cascade_force_skip_steps` to archive queued/started task messages for skipped steps:
- Ensures all task messages are archived when a step is force-skipped
- Prevents workers from processing tasks for steps that are already skipped
3. Modified `fail_task` to archive sibling task messages when a step is skipped:
- When a task failure causes a step to be skipped, all sibling task messages are archived
- Prevents double-decrement of remaining_steps when multiple tasks fail on the same step
4. Improved `start_tasks` to reject tasks for skipped steps:
- Added guard conditions to only start tasks for steps in 'started' state
- Prevents race conditions where a task might be started after its step was skipped
Added comprehensive tests to verify all these behaviors work correctly.1 parent 7ae95e9 commit 6873dbe
File tree
18 files changed
+678
-29
lines changed- pkgs/core
- schemas
- supabase
- migrations
- tests
- _cascade_force_skip_steps
- complete_task
- condition_evaluation
- fail_task_when_exhausted
- start_tasks
18 files changed
+678
-29
lines changedLines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
93 | 103 | | |
94 | 104 | | |
95 | 105 | | |
| |||
100 | 110 | | |
101 | 111 | | |
102 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
103 | 125 | | |
104 | 126 | | |
105 | 127 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
43 | 67 | | |
44 | 68 | | |
45 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
50 | 80 | | |
51 | 81 | | |
52 | 82 | | |
| |||
152 | 182 | | |
153 | 183 | | |
154 | 184 | | |
155 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
156 | 188 | | |
157 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
158 | 192 | | |
159 | 193 | | |
160 | 194 | | |
| |||
193 | 227 | | |
194 | 228 | | |
195 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
196 | 241 | | |
197 | 242 | | |
198 | 243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
| |||
Lines changed: 103 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
415 | 425 | | |
416 | 426 | | |
417 | 427 | | |
| |||
422 | 432 | | |
423 | 433 | | |
424 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
425 | 447 | | |
426 | 448 | | |
427 | 449 | | |
| |||
890 | 912 | | |
891 | 913 | | |
892 | 914 | | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
893 | 939 | | |
894 | 940 | | |
895 | 941 | | |
| |||
1246 | 1292 | | |
1247 | 1293 | | |
1248 | 1294 | | |
1249 | | - | |
1250 | | - | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
1251 | 1299 | | |
1252 | 1300 | | |
1253 | 1301 | | |
| |||
1279 | 1327 | | |
1280 | 1328 | | |
1281 | 1329 | | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
1282 | 1358 | | |
1283 | 1359 | | |
1284 | 1360 | | |
| |||
1384 | 1460 | | |
1385 | 1461 | | |
1386 | 1462 | | |
1387 | | - | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
1388 | 1466 | | |
1389 | | - | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
1390 | 1470 | | |
1391 | 1471 | | |
1392 | 1472 | | |
| |||
1425 | 1505 | | |
1426 | 1506 | | |
1427 | 1507 | | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
1428 | 1519 | | |
1429 | 1520 | | |
1430 | 1521 | | |
| |||
1717 | 1808 | | |
1718 | 1809 | | |
1719 | 1810 | | |
1720 | | - | |
1721 | | - | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
1722 | 1819 | | |
1723 | 1820 | | |
1724 | 1821 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
0 commit comments