I have two tables A and B related to ledger. Many transactions happen in both A and B parallely.
Problem faced is:
[28] - A insert success for source entity_id: id001
[28] - B update success for destination entity_id: id002
[28] - A insert success for destination entity_id: id002
[71] - B update success for source entity_id: id001
[28] - commit success for [28] with amount 100
Thread 71 updates table B before thread 28 commits the changes to the ledger.
It is happening because postgres locks the table when a process is using it.
Postgres locks the record by default. Refer docs for the same.
For the logs provided, the last log must be after committing the transaction. Whenever the transaction is complete, the waiting thread immediately takes over and that must be the reason your logs showed up that way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With