Redis write queue halves throughput and stalls the import drain; disabled in production
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 30/100
- Tipo de issue
- Refactorización
- Claridad
- Necesita aclaración
- Estado de actividad
- Tranquilo
- Stack tecnológico
- javascript, redis, sqlite
Línea de trabajo
Empieza leyendo client.js y el flujo de conexión alrededor de connect(), y después inspecciona createWriteWorker y la configuración de la cola de Redis. Reproduce el problema con REDIS_URL en el poller mientras observas los logs de import_entries y crawl. El trabajo estará terminado cuando selecciones e implementes un diseño de cola que evite el cuello de botella global, midas después el rendimiento y confirmes que las importaciones se vacían antes de volver a habilitar la configuración de producción.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
REDIS_URL was set on both Railway services on 2026-08-19 to switch on the write queue from #132, which had been merged but never actually wired (the variable had never existed, so connect() had always taken the serializeWrites fallback).
It made throughput worse and stalled imports outright. REDIS_URL has been removed from both services, so production is back on the in-process path. The code is still merged and correct as written — this issue exists so nobody re-enables it without knowing what happens.
Measured, same database, same hour
| with Redis | after removing it | |
|---|---|---|
| items ingested / 10 min | 4,132 | 8,132 |
| feeds crawled / 10 min | 582 | 1,003 |
| import drain | stalled — 65,474 entries, unmoved for >1h | draining again |
| poller crawl tick | ms=823314, ms=500966 |
back to normal |
The poller logged crawl log write failed: The operation was aborted due to timeout continuously while it was on.
Why — it is not Redis being slow
Redis latency is irrelevant here. The cause is that the queue serialises writes that used to run in parallel, and the resulting ceiling is below what the workload needs.
createWriteWorkerruns atconcurrency: 1, deliberately and correctly — SQLite permits one writer.- Every job is one
client.batch(statements, 'write'), i.e. one remote Turso transaction, whichclient.jsdocuments at ~370ms. - So global write throughput is capped at roughly 1 / 370ms ≈ 2.7 transactions per second, cluster-wide, for every process combined.
Before the queue, that work was not serialised that way: serializeWrites is per-process (web and poller each had their own), and the crawl path runs under TURSO_CRAWL_AUTOCOMMIT=1, which issues single-statement execute() writes. Neither wrapper overrides execute, so those went straight to the database in parallel. Turning on Redis funnelled every batch() write in the cluster through a single 2.7/s consumer.
Two consequences worth calling out:
- Head-of-line blocking. BullMQ is FIFO with one consumer, so the import drain's large periodic batch queues behind every small crawl batch. That is why it did not merely slow down, it stopped.
- No folding to compensate.
serializeWritescan fold several waiting callers into one transaction, butTURSO_WRITE_GROUP_STATEMENTS=1in production disables that (default is 1; the comment notes a 5-crawl group exceeded the 30s request deadline when canaried). So neither path folds — the Redis path just adds a global serialisation point the in-process path never had across processes.
Also seen
MaxListenersExceededWarning: 11 closing listeners added to [Queue] on the poller — connect() builds a fresh Queue + QueueEvents pair on every call, so connections accumulate. Worth memoising the client regardless of what happens to this issue.
What would need to change before re-enabling
- Batch multiple jobs per transaction in the worker (fold at the consumer, since folding at the producer is what
serializeWritesdoes and it is switched off). - Or separate queues per class of write so a bulk drain cannot block interactive writes.
- Or raise the ceiling some other way — the 2.7/s figure is the thing to beat, and it should be measured before flipping the variable, not after.
Repro is cheap: set REDIS_URL on the poller, watch import_entries stop moving.
- Lenguaje dominante
- JavaScript
- Estrellas
- 4
- Forks
- 0
- Merge medio
- 20 min
- PR fusionados (30 d)
- 54
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Issues similares
-
area:docs bug triage:confirmed
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Cotal-AI/Cotal#2875 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Feature]:Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Uuriko/project-room#1554 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 4 días
-
automated issue report
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
lirantal/discoprint#36 ·
Los mantenedores suelen responder en 1 día