Commit 889f04c
Drain an upload even while the crawler is catching up (#135)
A list of 109,474 URLs was submitted at 09:21 today. Every entry staged into
import_entries within 55 seconds, and then nothing happened at all:
queued_count stayed 0, and the page the submitter was given said "0% of 0 of
109,474 feeds — working". It would have said that for ever.
The cause was position. `drainImport` sat eleven lines below
`if (catchupOnly) return`, and CRAWL_CATCHUP=1 is set on the poller. Nothing
errored and nothing logged, because from the tick's point of view nothing went
wrong — it simply never reached the queue somebody was waiting on. The only way
to find it was to read this file.
Catch-up mode is right about everything else it skips. Discovery finds feeds on
its own schedule, cards and clusters decorate what is already indexed, and none
of it has a person watching a page. An import is the opposite: somebody handed
over a list and was given a URL to follow. A slice a tick is a small enough
price that it never had to be deferred.
`notifyFinishedSubmissions` moves with it, because the two are a pair — this
file already said so, that the daemon draining the queue is the one that tells
the submitter it drained. Draining in catch-up mode while leaving that below
would finish an upload and never say so, which is a stranger failure than not
draining. It is now guarded, too: down there a throw cost only the housekeeping
that followed, up here it would cost the crawl.
`notifyFinishedDiscoveries` deliberately stays below. Nobody is waiting on it.
The test is a source-order assertion, which is a compromise worth naming:
index.js connects to a database and starts timers at import, so `tick()` cannot
be loaded by a test without a refactor far larger than the bug. Checking the
order of three lines is crude and it does hold the one invariant whose
violation is invisible from outside. Verified it fails three ways with the
drain moved back below the return.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 36595fd commit 889f04c
2 files changed
Lines changed: 130 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
313 | 365 | | |
314 | 366 | | |
315 | 367 | | |
| |||
360 | 412 | | |
361 | 413 | | |
362 | 414 | | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | 415 | | |
390 | 416 | | |
391 | 417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 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 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
0 commit comments