fix(db): prevent deadlock in concurrent melt quote locking #1474
No reviewers
Labels
No labels
DB & Storage
Deployment
Error Handling & Logging
Maintenance
Payment Backend
backport
backport v0.13.x
backport v0.14.x
backport v0.15.x
bindings
blocked
bug
cdk-sql
ci
cli
deps
documentation
duplicate
enhancement
good first issue
help wanted
invalid
keep-open
ldk-node-ui
migrations
mint
mutation-testing
needs rebase
needs review
new nut
nut change
question
ready
rust-version
rustfmt
stacked hold
stale
testing
wallet
weekly-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cashubtc/cdk!1474
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix_psgl_quote_locking"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When multiple wallets attempt to melt quotes sharing the same request_lookup_id concurrently, the previous two-step locking approach (lock target quote, then lock all related quotes) could cause deadlocks.
Each transaction would hold its own quote's lock while waiting for locks held by other transactions, creating a circular wait condition that PostgreSQL would resolve by aborting transactions.
Fix by introducing lock_melt_quote_and_related() which acquires all related quote locks atomically in a single query, ordered by ID. This ensures consistent lock ordering across transactions, eliminating the circular wait condition.
Description
Notes to the reviewers
Suggested CHANGELOG Updates
CHANGED
ADDED
REMOVED
FIXED
Checklist
just final-checkbefore committing