Add a way to run callbacks after a transaction commits
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
- 38/100
Línea de trabajo
Start with opsqueue/src/db/mod.rs, where Connection::transaction() is defined, and read the linked discussion in issues #182 and #193 for context. The issue proposes storing callbacks on transactions, running them after a successful outermost commit, and propagating them from nested transactions. Done means callbacks run only after commit and nested transactions pass them upward; the issue leaves key design details open.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Related: https://github.com/channable/opsqueue/issues/182#issuecomment-5698854050, https://github.com/channable/opsqueue/issues/193
We currently have three things that need to happen after a transaction commits:
- Prometheus metrics accounting.
- Notifying via
notify_on_insert. - Notifying via
submission_status_changed(when https://github.com/channable/opsqueue/pull/187 lands).
Ideally we would like to define these actions close to where they most sense on a semantic level (e.g. within insert_submission). However, once transactions come into play this becomes problematic, because these side-effects should only be executed if and when the transaction commits. Since the callee doesn't control, nor has insight in, if and when that commit would happen we have no choice but to defer that execution to the caller. We currently either ignore the problem (for Prometheus metrics), or handle the defer manually (e.g. by returning a bool, and making the caller check that after commit). Both are not ideal.
To remedy this I propose we offer users of opsqueue::db::Connection::transaction() something like the following API:
conn.transaction(move |mut tx| { async move {
...
// Register a callback to run on commit.
tx.on_commit(|| notify_on_insert.notify());
...
} .boxed()}).await?;
To implement that we would have to:
- Store a list of
on_commitcallbacks somewhere on the transaction (TBD where exactly). - Within
opsqueue::db::Connection::transaction()we check if the transaction committed. If so, and we are not in a nested transaction we execute all the callbacks. If we are in a nested transaction we propagate the callbacks upwards.
- Lenguaje dominante
- Rust
- Estrellas
- 97
- Forks
- 2
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
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 channable/opsqueue
-
Reserver does not need to be genericPosiblemente ocupada @jerbaroo la tomó hace 13 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
channable/opsqueue#195 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Make `submissions_canceled` and `add_chunks_done_to_submissions_failed` migrations bidirectionalAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
channable/opsqueue#193 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de channable/opsqueue
Issues similares
-
area:cli bug dotnet good first issue priority:medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
rtk-ai/rtk#4844 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
delta-io/delta-kernel-rs#3757 ·
Los mantenedores suelen responder en 3 días
-
area: library data-loss type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
alplabai/signex#1740 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
test(fslc): the unreadable mutate catalog test pins the Unix I/O error text and fails on WindowsPosiblemente ocupada @rizumita la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
Los mantenedores suelen responder en 1 día