Commit bc906da
fix: atomic session slots, partial-index cleanup, watcher serialization
- server.py: the MAX_ACTIVE_BOTS check ran in offer() while the increment
happened inside the detached bot task, several awaits later, so concurrent
offers all passed the guard together. Capacity is now reserved atomically
under a lock before the offer is handled; ownership transfers to the bot task
once it is created, and offer() releases the slot on every path where it was
not. run_interview_bot wraps its whole body so even the early readiness raise
releases. Measured with 10 simultaneous offers: peak active went 10 -> 2,
with 8 x 503 and no leaked slots.
- indexer.ts: a rebuild that threw after the stale delete left the documents it
had already upserted in the index, while the caller dropped the persisted
cache — the only record of their ids — stranding them in search results.
Extracted discardPartialIndex(), now used by the cancel path and the catch.
If that cleanup itself fails it clears discardedPreviousIndex so the cache is
kept and a later rebuild can retry, rather than losing the ids entirely.
- indexer.ts: the `indexing` guard only stopped watcher work from starting, so
an upsert/remove already awaiting a file read could write during a rebuild's
cleanup. Added a generation counter bumped per rebuild and re-checked after
every await before any write, plus in-flight op tracking that rebuild drains
before it mutates anything.
- .env.example: MAX_ACTIVE_BOTS now precedes SESSION_HANDSHAKE_TIMEOUT_SECS.
Verified: 10-way offer burst and the reserve-then-fail path; rebuild throwing
mid-scan with cleanup succeeding and failing; and a watcher write racing a
rebuild with and without the generation guard.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent caf0519 commit bc906da
3 files changed
Lines changed: 193 additions & 59 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | | - | |
28 | | - | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
112 | 133 | | |
113 | 134 | | |
114 | 135 | | |
| |||
744 | 765 | | |
745 | 766 | | |
746 | 767 | | |
747 | | - | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
748 | 780 | | |
749 | 781 | | |
750 | 782 | | |
| |||
756 | 788 | | |
757 | 789 | | |
758 | 790 | | |
759 | | - | |
760 | 791 | | |
761 | 792 | | |
762 | 793 | | |
| |||
931 | 962 | | |
932 | 963 | | |
933 | 964 | | |
934 | | - | |
935 | 965 | | |
936 | 966 | | |
937 | 967 | | |
| |||
1127 | 1157 | | |
1128 | 1158 | | |
1129 | 1159 | | |
1130 | | - | |
| 1160 | + | |
1131 | 1161 | | |
1132 | | - | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
1133 | 1165 | | |
1134 | 1166 | | |
1135 | 1167 | | |
1136 | | - | |
| 1168 | + | |
1137 | 1169 | | |
1138 | 1170 | | |
1139 | 1171 | | |
1140 | | - | |
1141 | | - | |
1142 | | - | |
1143 | | - | |
1144 | | - | |
1145 | | - | |
1146 | | - | |
1147 | | - | |
1148 | | - | |
1149 | | - | |
1150 | | - | |
1151 | | - | |
1152 | | - | |
1153 | | - | |
1154 | | - | |
1155 | | - | |
1156 | | - | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
1157 | 1175 | | |
1158 | | - | |
1159 | | - | |
1160 | | - | |
1161 | | - | |
1162 | | - | |
1163 | | - | |
1164 | | - | |
1165 | | - | |
1166 | | - | |
1167 | | - | |
1168 | | - | |
1169 | | - | |
1170 | | - | |
1171 | | - | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
1175 | | - | |
1176 | | - | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
1177 | 1219 | | |
1178 | 1220 | | |
1179 | 1221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
| |||
110 | 114 | | |
111 | 115 | | |
112 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
113 | 120 | | |
114 | 121 | | |
| 122 | + | |
115 | 123 | | |
116 | 124 | | |
117 | 125 | | |
| |||
216 | 224 | | |
217 | 225 | | |
218 | 226 | | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
| 227 | + | |
229 | 228 | | |
230 | 229 | | |
231 | 230 | | |
| |||
247 | 246 | | |
248 | 247 | | |
249 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
250 | 257 | | |
251 | 258 | | |
252 | 259 | | |
| |||
263 | 270 | | |
264 | 271 | | |
265 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
266 | 298 | | |
267 | 299 | | |
268 | 300 | | |
269 | 301 | | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
270 | 312 | | |
271 | 313 | | |
272 | 314 | | |
273 | 315 | | |
274 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
275 | 320 | | |
276 | | - | |
| 321 | + | |
277 | 322 | | |
278 | 323 | | |
279 | 324 | | |
| |||
287 | 332 | | |
288 | 333 | | |
289 | 334 | | |
290 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
291 | 339 | | |
292 | 340 | | |
293 | 341 | | |
294 | 342 | | |
295 | | - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
296 | 349 | | |
297 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
298 | 354 | | |
299 | 355 | | |
300 | 356 | | |
| |||
306 | 362 | | |
307 | 363 | | |
308 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
309 | 372 | | |
310 | 373 | | |
311 | 374 | | |
312 | 375 | | |
313 | 376 | | |
314 | | - | |
| 377 | + | |
315 | 378 | | |
316 | 379 | | |
317 | 380 | | |
318 | | - | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
319 | 385 | | |
320 | 386 | | |
321 | 387 | | |
| |||
397 | 463 | | |
398 | 464 | | |
399 | 465 | | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
400 | 492 | | |
401 | 493 | | |
402 | 494 | | |
| |||
0 commit comments