Commit 9c952ad
committed
fix(astro): add batch-size override and ECONNRESET retry to incremental search indexer
Meilisearch can silently restart mid-task under memory pressure (observed
~60s crash cycles during FR bulk upserts on the 7.6 GiB VPS), causing
ECONNRESET on either the addDocuments POST or the waitForTask polling
that follows. The previous indexer died outright on the first failure
even though the submitted task was already persisted in LMDB and would
typically resume on server recovery.
Changes (apps/astro/scripts/index-search-incremental.ts):
- New flushWithRetry() in BatchIndexer waits for /health to return
"available" (up to 180s) and retries the wait on the original taskUid
rather than resubmitting the batch. Up to 5 attempts per flush.
- New --batch-size <n> CLI flag and MEILI_BATCH_SIZE env var override
the default of 500 docs/batch. Smaller batches reduce per-flush
Meilisearch memory and let crash recovery happen between batches
instead of inside one.
- New --verbose-batches flag prints the first/last doc ID of every
flushed batch, with stdout force-flushed so the last logged ID is
durable through a crash. Combined with --batch-size 1 this isolates
poison documents.
apps/astro/CLAUDE.md already documents these flags; this commit brings
the code in line with the documentation. The full-reindex sibling
(index-search.ts) has the same OOM-vulnerable pattern and should get
the same treatment in a follow-up — scoped out of this PR because only
the incremental script was field-validated on the VPS.1 parent 7b0daec commit 9c952ad
1 file changed
Lines changed: 59 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
221 | | - | |
222 | | - | |
| 220 | + | |
223 | 221 | | |
224 | 222 | | |
225 | 223 | | |
| |||
231 | 229 | | |
232 | 230 | | |
233 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
234 | 290 | | |
235 | 291 | | |
236 | 292 | | |
| |||
0 commit comments