rfcx / arbimon-legacy

https://arbimon.org
Apache License 2.0
0 stars 0 forks source link

Research and fix places where DB operations are executed within transaction function but not within transaction #1571

Open veckatimest opened 4 months ago

veckatimest commented 4 months ago

Describe the bug When we use

connection.beginTransaction()

We should do all subsequent SQL operation within the same connection. If we don't do it, the transaction will wait of the operation to complete, and operation will wait for transaction to complete. Bad:

await db.beginTransaction();
await dbpool.query(q); // does not use the db, so the operation might stuck

Good:

await db.beginTransaction();
await dbpool.queryWithConn(db, sql);; // uses the db, so the operation is safe

And also places where transaction might start but never be commited. Or places where transaction is commited more than 1 time

Context