[CONJS-171] Release connection to pool undoes last commit Created: 2021-07-13 Updated: 2022-08-01 Resolved: 2022-08-01 |
|
| Status: | Closed |
| Project: | MariaDB Connector/node.js |
| Component/s: | execute |
| Affects Version/s: | 2.5.4 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Critical |
| Reporter: | Malte Bastian | Assignee: | Diego Dupin |
| Resolution: | Incomplete | Votes: | 0 |
| Labels: | commit, pool, transactions | ||
| Environment: |
MariaDB Database: 10.5 |
||
| Description |
|
In our application, we get a connection from the pool, start a transaction, add a few records and commit them. After the commit, we release the connection. It looks like releasing the connection sporadically undoes the commit. Our script (reduced to interactions with mariadb):
If we run this multiple times we missed about 1 of 5 transactions. If we set noControlAfterUse in the pool configuration, all transactions are committed correctly. With the debug log enabled, you can see that RESET statement is sent first before the COMMIT statement.
I created a GitHub issue too, see https://github.com/mariadb-corporation/mariadb-connector-nodejs/issues/164 |
| Comments |
| Comment by Diego Dupin [ 2021-07-16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Log doesn't lies, so there is clearly a problem there, even if i cannot pinpoint the problem for now (commands are orderly queued and executed) In the meantime, can you confirm that really the code that permits to reproduced it ?
The await expression in `await conn.commit();` causes async function execution to pause , so commit command will be totally done executing `await conn.release()`. If that's not the case, it would then be a node.js issue. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Malte Bastian [ 2021-07-16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I have tried it again and I can still reproduce this problem. If I set "noControlAfterUse" in the pool configuration to true, I cannot reproduce this problem. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Diego Dupin [ 2021-07-16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
if you are able to reproduced it, could you please share the debug code, i can't understand why there is no response in log since there is `await`, like :
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Malte Bastian [ 2021-07-19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Pool
NestJS DB-Service Provider of the connection pool for the NestJS application.
API-Endpoint I have removed the business logic here, which does not interact with the database.
Debug protokoll I have the log from the start of the transaction. Do you also need a log from the execution of getConnection? Is it intended that a reset result is read in after beginTransaction? Or does this look like a problem with the queue?
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Diego Dupin [ 2021-07-23 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
>is it intended that a reset result is read in after beginTransaction? Or does this look like a problem with the queue? Your snippet code is ok. Await, by specficiation, must suspend execution until the returned promise is fulfilled or rejected, so `await conn.release();` cannot be executed before fullfillment or rejection of `await conn.commit();`. After verification of each pool implementation line i see no possible bug. For now, i'm a little dubious about what to do next, as i can only see a Typescript/node.js bug, that would be so obvious that it would be strange. Could you indicate the exact node.js version you use ? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Malte Bastian [ 2021-08-04 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I use node v14.17.3 and the target is "es2020". Should I try another version? If yes, which one? Here is our tsconfig:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Diego Dupin [ 2021-09-16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I've tryed with Typescript 4.4.3 without reproducing the issue with the same configuration you indicate. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Malte Bastian [ 2021-09-16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank you for trying to reproduce the problem. It is a pity that it did not work. Would have been too easy too... I have currently removed all transactions in our application, with the hope that you can find something so I can add them back. We lost a lot of data due to the problem, which is especially annoying since our platform is used to synchronize multiple systems. Cleaning that up is now very time consuming. I don't think I'm allowed to publish parts of our application. I can understand that it is now very difficult for you to recreate this situation and would have no problem if you close the ticket because of this. I hope that the problem does not occur other developers. Maybe it is also a combination of many coincidences together with our systems. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Diego Dupin [ 2021-12-20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
After testing with various Typescript version and target, generated code not reproduced. setting issue to stalled until further information by user or another issue like this. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ralf Gebhardt [ 2022-07-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
In two weeks, we will close this issue as incomplete since it will have spent a long time waiting for feedback. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ralf Gebhardt [ 2022-07-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
In one week we will close this issue as incomplete since it will have spent a long time waiting for feedback. |