Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Records of transaction after commit are missing if noControlAfterUse is not set to true #164

Closed
BC-M opened this issue Jul 13, 2021 · 2 comments

Comments

@BC-M
Copy link
Contributor

BC-M commented Jul 13, 2021

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):

const conn = await pool.getConnection();
await conn.beginTransaction();

// insert rows
const res = await conn.query('XXX');
if(res.affectedRows < 1) throw new Error('insert failed');

await conn.commit();
await conn.release();

If we run this multiple times we missed about 1 of 5 transactions. How is that possible?

If we set noControlAfterUse in the pool configuration, all transactions are committed correctly.

Setup:
MariaDB Database: 10.5
MariaDB Package: 2.5.4
NodeJS: 14 and 15

@BC-M
Copy link
Contributor Author

BC-M commented Jul 13, 2021

With the debug log enabled, you can see that RESET statement is sent first before the COMMIT statement.

==> conn:1105470 Reset(0,5)
+--------------------------------------------------+
|  0  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f |
+--------------------------------------------------+------------------+
| 01 00 00 00 1F                                   | .....            |
+--------------------------------------------------+------------------+

==> conn:1105470 Query(0,11)
+--------------------------------------------------+
|  0  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f |
+--------------------------------------------------+------------------+
| 07 00 00 00 03 43 4F 4D  4D 49 54                | .....COMMIT      |
+--------------------------------------------------+------------------+

@BC-M
Copy link
Contributor Author

BC-M commented Sep 16, 2021

@BC-M BC-M closed this as completed Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant