Commit 88c94e6
fix(indexing): yield the event loop during a synchronous custom-index backfill
A custom index (HNSW vector index) indexes synchronously: in runIndexing's
per-row loop, index.customIndex.index() runs inline and returns void, so it
never assigns lastResolution and never raises `outstanding`. The existing
yield is gated on `outstanding > MIN_OUTSTANDING_INDEXING`, so for a
custom-index backfill it never fires — the entire backfill over the populated
rows runs in a single event-loop turn, freezing the worker's main thread for
the whole build (starving replication keepalive, the operations API, and
schema signalling, and never letting isIndexing be observed; vector search
returns 503 the entire time).
Track whether a row performed synchronous custom-index work and yield once per
such row when the outstanding-based yields don't apply.
Validated on a live 5.1.0-beta.1 instance with a 100ms main-thread heartbeat
over an identical 2,000-row int8 HNSW backfill (clean A/B, same box/data):
before: max event-loop stall 71,030 ms (frozen for the entire 71.2s build)
after: max event-loop stall 166 ms; build 67.5s (no measurable throughput cost)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent a65f072 commit 88c94e6
1 file changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1334 | 1334 | | |
1335 | 1335 | | |
1336 | 1336 | | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
1337 | 1341 | | |
1338 | 1342 | | |
1339 | 1343 | | |
| |||
1347 | 1351 | | |
1348 | 1352 | | |
1349 | 1353 | | |
| 1354 | + | |
1350 | 1355 | | |
1351 | 1356 | | |
1352 | 1357 | | |
| |||
1385 | 1390 | | |
1386 | 1391 | | |
1387 | 1392 | | |
1388 | | - | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
1389 | 1396 | | |
1390 | 1397 | | |
1391 | 1398 | | |
| |||
0 commit comments