[backend-2fa] Migration lock (`migration_lock.rs`) does not release advisory lock on panic — subsequent deployments deadlock
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 62/100
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Rust
- 星标
- 1
- 派生
- 193
- 平均合并
- 23 小时 37 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DogStark/PetChain-Contracts 的其他 Issue
-
infrastructure priority: medium security
难度 2/5 1-3 小时 新手友好度 66/100
DogStark/PetChain-Contracts#1658 ·
维护者通常 1 天内回复
-
enhancement infrastructure priority: medium
难度 2/5 1-3 小时 新手友好度 78/100
DogStark/PetChain-Contracts#1651 ·
维护者通常 1 天内回复
-
bug priority: medium security
难度 2/5 1-3 小时 新手友好度 76/100
DogStark/PetChain-Contracts#1648 ·
维护者通常 1 天内回复
-
bug Contract security
难度 2/5 1-3 小时 新手友好度 62/100
DogStark/PetChain-Contracts#1644 ·
维护者通常 1 天内回复
-
bug priority: low Rust
难度 2/5 1-3 小时 新手友好度 82/100
DogStark/PetChain-Contracts#1642 ·
维护者通常 1 天内回复
查看 DogStark/PetChain-Contracts 的全部 Issue
相似的 Issue
-
area:index v0.35.0
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
eth_get_proof reports another account's fields for an absent account可能已有人在做 @Indian-boult 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 2/5 1-3 小时 新手友好度 74/100
jelmer/debian-parsers#515 ·