[backend-2fa] Migration lock (`migration_lock.rs`) does not release advisory lock on panic — subsequent deployments deadlock
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 62/100
Línea de trabajo
Start in backend-2fa/src/migration_lock.rs: trace where the advisory lock is acquired (pg_try_advisory_lock) and where the Drop cleanup runs. Decide between transaction-scoped locking and a lock timeout, then document the choice in comments. Add a test that forces a mid-migration failure and verifies the lock is no longer held; done means the lock is released after the simulated crash and the strategy is documented.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
backend-2fa/src/migration_lock.rs acquires a Postgres advisory lock before running schema migrations to prevent concurrent migration runs. If the migration process panics (e.g. due to a database error mid-migration), the advisory lock may not be released because the cleanup code runs in a Drop impl.
However, if the process is killed with SIGKILL (OOM killer, container restart), Drop does not run. Postgres advisory locks acquired with pg_try_advisory_lock are session-scoped and release when the session closes. But if the connection is kept alive (e.g. by a connection pool that recycles connections), the lock may persist across process restarts within the same connection lifetime.
Suggested Fix
- Use
pg_advisory_xact_lock(transaction-scoped) instead ofpg_try_advisory_lock(session-scoped) for the migration lock. Transaction-scoped locks are released automatically when the transaction commits or rolls back, even on panic orSIGKILL. - Alternatively, add a lock timeout (
SET lock_timeout = '30s') before acquiring the session lock. - Document the chosen lock strategy in
migration_lock.rscomments. - Add a test that simulates a mid-migration failure and asserts the lock is released.
Acceptance Criteria
- Advisory lock is reliably released even on process crash.
- Lock strategy is documented in source.
- Test covers lock release after simulated failure.
- Lenguaje dominante
- Rust
- Estrellas
- 1
- Forks
- 193
- Merge medio
- 23 h 37 min
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la 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 DogStark/PetChain-Contracts
-
infrastructure priority: medium security
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
DogStark/PetChain-Contracts#1658 ·
Los mantenedores suelen responder en 1 día
-
enhancement infrastructure priority: medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
DogStark/PetChain-Contracts#1651 ·
Los mantenedores suelen responder en 1 día
-
bug priority: medium security
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
DogStark/PetChain-Contracts#1648 ·
Los mantenedores suelen responder en 1 día
-
[Contracts] Litter registration workflow does not validate that all offspring IDs are uniqueAbiertobug Contract security
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
DogStark/PetChain-Contracts#1644 ·
Los mantenedores suelen responder en 1 día
-
bug priority: low Rust
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
DogStark/PetChain-Contracts#1642 ·
Los mantenedores suelen responder en 1 día
Todos los issues de DogStark/PetChain-Contracts
Issues similares
-
area:index v0.35.0
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
eth_get_proof reports another account's fields for an absent accountPosiblemente ocupada @Indian-boult la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
jelmer/debian-parsers#515 ·