Thursday, January 9, 2025
1 change · 18.0
Enhancements to existing features
Subscription invoice payment processing now uses a lighter database lock to avoid blocking related updates unnecessarily. This reduces the risk of deadlocks during automated subscription billing, improving reliability without changing user-facing workflows.
Original PR description
Before this commit, the transaction row was locked when payment was performed in the subscription invoice cron. Using `SELECT FOR UPDATE` locks the entire row, primary key included (id in our case). As a result, it could prevent insertion or update or other table refering to the id too. As it is not necessary and could trigger unnecessary deadlock, it is better to rely on `SELECT FOR NO KEY UPDATE` which allow the update of foreign keys. https://www.postgresql.org/docs/16/explicit-locking.html#LOCKING-ROWS See https://github.com/odoo/enterprise/pull/74078#discussion_r1873729342 taskid: 4391755