Commit 3f8ed8b
committed
fix(redis-worker,run-engine): close the remaining ways a batch item is stranded or run twice
Releasing a slot could silently do nothing. The release pipeline never inspected
its per-command errors, and ioredis resolves a pipeline whose commands failed, so
a failed SREM reported success and the caller went on to destroy the in-flight
record. Release now throws on a failed command.
Reclaim then acted on that false success: it released per message, swallowed any
error, and requeued regardless, which is exactly how a slot ends up held with the
message gone. It now frees the whole timed-out batch in one pipeline before any of
them is requeued, and a failure aborts the requeue so the messages stay in-flight
for the next tick. That also restores the single round trip per shard.
Requeuing removed the message from in-flight before writing it back to the queue.
Redis does not roll back a script that fails partway, so a failed queue write lost
the message outright. The order is now write-then-remove.
Batch items were never heartbeated, so any item slower than the visibility timeout
was reclaimed and handed to a second consumer while the first was still running it,
executing the item twice. Items are now heartbeated for as long as their callback
runs, and the visibility timeout is configurable so this is testable.1 parent c6524ca commit 3f8ed8b
7 files changed
Lines changed: 259 additions & 139 deletions
File tree
- internal-packages/run-engine/src/batch-queue
- tests
- packages/redis-worker/src/fair-queue
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| |||
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| 73 | + | |
| 74 | + | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
| |||
95 | 100 | | |
96 | 101 | | |
97 | 102 | | |
| 103 | + | |
| 104 | + | |
98 | 105 | | |
99 | 106 | | |
100 | 107 | | |
| |||
154 | 161 | | |
155 | 162 | | |
156 | 163 | | |
157 | | - | |
| 164 | + | |
158 | 165 | | |
159 | 166 | | |
160 | 167 | | |
| |||
752 | 759 | | |
753 | 760 | | |
754 | 761 | | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
755 | 785 | | |
756 | 786 | | |
757 | 787 | | |
| |||
820 | 850 | | |
821 | 851 | | |
822 | 852 | | |
823 | | - | |
824 | | - | |
825 | | - | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
826 | 857 | | |
827 | 858 | | |
828 | 859 | | |
| |||
837 | 868 | | |
838 | 869 | | |
839 | 870 | | |
840 | | - | |
841 | | - | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
842 | 875 | | |
843 | 876 | | |
844 | 877 | | |
| |||
Lines changed: 52 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
953 | 953 | | |
954 | 954 | | |
955 | 955 | | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
956 | 1008 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
217 | 223 | | |
218 | 224 | | |
219 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
107 | 131 | | |
108 | 132 | | |
109 | 133 | | |
| |||
127 | 151 | | |
128 | 152 | | |
129 | 153 | | |
130 | | - | |
| 154 | + | |
131 | 155 | | |
132 | 156 | | |
133 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1498 | 1498 | | |
1499 | 1499 | | |
1500 | 1500 | | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
1501 | 1504 | | |
1502 | 1505 | | |
1503 | 1506 | | |
1504 | 1507 | | |
1505 | | - | |
1506 | | - | |
1507 | | - | |
1508 | | - | |
1509 | | - | |
1510 | | - | |
1511 | | - | |
1512 | | - | |
1513 | | - | |
1514 | | - | |
1515 | | - | |
1516 | | - | |
1517 | | - | |
1518 | | - | |
1519 | | - | |
1520 | | - | |
1521 | | - | |
1522 | | - | |
| 1508 | + | |
1523 | 1509 | | |
1524 | 1510 | | |
1525 | 1511 | | |
| |||
1559 | 1545 | | |
1560 | 1546 | | |
1561 | 1547 | | |
1562 | | - | |
1563 | | - | |
1564 | | - | |
1565 | | - | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
1566 | 1552 | | |
1567 | | - | |
1568 | | - | |
| 1553 | + | |
| 1554 | + | |
1569 | 1555 | | |
1570 | 1556 | | |
1571 | 1557 | | |
1572 | | - | |
1573 | | - | |
1574 | | - | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
1575 | 1561 | | |
1576 | 1562 | | |
1577 | 1563 | | |
1578 | 1564 | | |
1579 | | - | |
1580 | | - | |
1581 | | - | |
1582 | | - | |
1583 | 1565 | | |
1584 | | - | |
1585 | | - | |
1586 | | - | |
1587 | | - | |
| 1566 | + | |
| 1567 | + | |
1588 | 1568 | | |
1589 | 1569 | | |
1590 | 1570 | | |
1591 | 1571 | | |
1592 | 1572 | | |
1593 | 1573 | | |
1594 | | - | |
1595 | | - | |
1596 | | - | |
1597 | | - | |
1598 | | - | |
1599 | | - | |
1600 | | - | |
1601 | | - | |
1602 | | - | |
1603 | | - | |
1604 | | - | |
1605 | | - | |
1606 | | - | |
1607 | | - | |
1608 | | - | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
1609 | 1590 | | |
1610 | | - | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
1611 | 1598 | | |
1612 | 1599 | | |
1613 | 1600 | | |
| |||
0 commit comments