[X] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[ ] This change requires a documentation update
Description
IMPORTANT TO KNOW
With the recent changes in the error logs i was able to track down the origin of the deadlock into the queries to the GetVendor function, specifically to the call of UpdateAccountBalanceByOpenPayments <- which is a bad function because it mixes the usage of pgx.Tx and normal database transactions. In the verification we call GetVendor 2x so actually we were updating the balance 4 times in the verification process which lead to the deadlocks.
Builds on top of #151
Learnings:
never mix pgx.Tx and non Tx Database calls
Always add a meaningful error message
Check the code testing coverage from time to time to see which part of the code is actually tested
CHANGES
GetVendor shouldn't always update the balance, because in the verification it's already taking care to do this.
TODO
Clean up the mixed usage of tgx.Tx and normal transactions in queries.go -> follow up pr.
Checklist:
[X] I have commented my code (or ChatGPT did), particularly in hard-to-understand areas
[ ] I have made corresponding changes to the documentation
[ ] My changes generate no new warnings, neither in my IDE nor in my browser
[ ] I have added tests that prove my fix is effective or that my feature works
Type of change
Description
IMPORTANT TO KNOW
With the recent changes in the error logs i was able to track down the origin of the deadlock into the queries to the
GetVendor
function, specifically to the call ofUpdateAccountBalanceByOpenPayments
<- which is a bad function because it mixes the usage ofpgx.Tx
and normal database transactions. In the verification we callGetVendor
2x so actually we were updating the balance 4 times in the verification process which lead to the deadlocks.Builds on top of #151
Learnings:
CHANGES
GetVendor shouldn't always update the balance, because in the verification it's already taking care to do this.
TODO
Clean up the mixed usage of tgx.Tx and normal transactions in
queries.go
-> follow up pr.Checklist: