PersistedQueue: offer option that de-duplicates an id only while it is pending or processing
Los mantenedores suelen responder en 1 día
@effect-bot ya está trabajando en esto.
Desde el 2/11/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Use case
A common queue pattern is "at most one job per key at a time, but run again when the next trigger arrives after the previous one finished". For example, a recompute job keyed by an entity id. Ten triggers in a burst should coalesce into one pending job. A trigger that arrives after that job has completed should enqueue a new one.
Today offer with an id de-duplicates until layerCleanup deletes the settled element (default timeToLive is 30 days). So a later trigger with the same id is silently dropped, and the work doesn't run again.
Current workaround
Before offering, rename the settled row's id so the ON CONFLICT (id, queue_name) DO NOTHING in the SQL store no longer matches:
UPDATE effect_queue SET id = id || '#' || sequence
WHERE queue_name = $1 AND id = $2 AND state IN ('completed', 'failed')
This works, but it writes to the store's own table from outside the module, so it depends on the table's schema and breaks if the store's migrations change it.
Proposal
An option on offer, for example:
queue.offer(value, { id, deduplicate: "whilePending" }) // default stays "untilCleanup"
With "whilePending", an offer is ignored while an element with that id is pending or processing, and enqueues anew once it is completed (and possibly failed, see below).
For Postgres, the offer could become:
INSERT INTO effect_queue (id, queue_name, element, state, attempts, visible_at, created_at, updated_at)
VALUES ($id, $name, $element, 'pending', 0, $visible_at, now(), now())
ON CONFLICT (id, queue_name) DO UPDATE SET
element = EXCLUDED.element, state = 'pending', attempts = 0, last_failure = NULL,
acquired_at = NULL, acquired_by = NULL,
visible_at = EXCLUDED.visible_at, updated_at = EXCLUDED.updated_at
WHERE effect_queue.state IN ('completed', 'failed')
The Redis and memory stores would need the same check on the stored state.
Open questions
- Failed elements: they are the dead-letter record, so reusing that row on a new offer erases the previous failure. An alternative is to keep the failed row and insert a new one, which needs the unique key to allow several settled rows per id. Or
"whilePending"could apply to completed elements only. - Ordering: reusing the row keeps the old
sequence, so among elements with the samevisible_atthe re-offered one sorts first. A delete followed by an insert would avoid that.
I'm happy to open a PR once you're fine with the shape.
- Lenguaje dominante
- TypeScript
- Estrellas
- 16.7k
- Forks
- 808
- Merge medio
- 11 h 3 min
- PR fusionados (30 d)
- 839
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.
Más de Effect-TS/effect
-
Support OpenTelemetry JS SDK v3 and replace deprecated tracing peers in Effect v4Posiblemente ocupada @effect-bot la tomó hoy. Abierto
Effect-TS/effect#10328 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
shorthand for mapping over tagged union schemaPosiblemente ocupada @effect-bot la tomó hace 1 día. Abiertoenhancement
Effect-TS/effect#10286 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Cluster: A way to remove processed requests from storagePosiblemente ocupada @effect-bot la tomó hace 3 días. Abiertoenhancement
Effect-TS/effect#10239 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
cluster: a runner that lost its shard lock can still write replies and messages for that shardAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 47/100
Los mantenedores suelen responder en 1 día
Todos los issues de Effect-TS/effect
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
-
bug needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
DSpace/dspace-angular#6511 ·
Los mantenedores suelen responder en 1 día
-
area: frontend area:byok bug severity:low
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Phone app shows Unknown for a remote machine whose key changedPosiblemente ocupada @janicduplessis la tomó hoy. Abiertoarea: mobile priority: P3 type: bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
appandflow/stim#5006 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Area - Local to Cloud Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
microsoft/vscode-mssql#23209 ·
Los mantenedores suelen responder en 1 día