Deadlock on wallet transfers
Your task
MySQL/InnoDB. After a feature deploy enabling a new 'transfer between two wallets' endpoint, error logs fill with Deadlock found when trying to get lock; try restarting transaction during peak traffic. It only happens when two transfers involve the same pair of wallets in opposite directions. Throughput is fine otherwise; the endpoint occasionally 500s. Triage, mitigate, and give the correct durable fix.
It covers
- Deadlock
- Lock ordering
- Retry