Commit c2030f2
committed
fix(cp): free the delegation slot via RAII so task abort cannot leak it
Self-review round-2 finding. serve() released its inflight slot with a plain
call after the execute().await — but the client ABORTS serving tasks that
outlive the 5s drain window on disconnect, and an aborted task never runs
code after its await point. The leaked entry then survives reconnection
(executor state is process-lifetime), permanently consuming capacity: with
the default max_delegated_sessions = 1, one abort turns the worker into a
zombie that refuses every delegation while heartbeating happily.
The window is realistic, not theoretical: the bounded (5s) session/cancel
added in the previous fix means a wedged agent stdin makes the task overrun
the equally-sized drain window by construction.
release() now lives in a Drop guard taken at admission, so the abort's
unwind frees the slot. Regression test aborts a serving task mid-run and
asserts active() == 0; mutation-verified (plain-release pattern fails it
5/5, the guard passes).1 parent a9906f8 commit c2030f2
1 file changed
Lines changed: 53 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
223 | | - | |
224 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
225 | 232 | | |
226 | 233 | | |
227 | 234 | | |
| |||
353 | 360 | | |
354 | 361 | | |
355 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
356 | 376 | | |
357 | 377 | | |
358 | 378 | | |
| |||
863 | 883 | | |
864 | 884 | | |
865 | 885 | | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
866 | 916 | | |
0 commit comments