Replies: 1 comment
-
I think I understood it now. Since all the sqls are executed in non blocking fashion , it would never result in hang . |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am trying to understand the following sequelize test case which tries to initiate multiple async requests to update a table and it uses current mysql2 driver.
mentioned here https://github.com/sequelize/sequelize/blob/main/test/integration/model/create.test.js
Test Description:
A function , findOrCreate is called 50times in async fashion . findOrCreate function opens a transaction, does a select call and a row is inserted if row not found.
Clarification on the exclusive lock behaviour.
findOrCreate has following sqls to run; start txn, select, insert, commit txn. As per my understanding, for insert sql , an exclusive lock is taken on that row which is released only after running sql "commit txn".
If multiple async calls to findOrCreate function are initiated , is it possible one of the async request just hangs on insert sql while other async request has not done a commit . when running the test case multiple times, hang however is never seen. It always happens that a second insert won't get called before the first commit .
Can someone please clarify how this is ensured in the driver.
Beta Was this translation helpful? Give feedback.
All reactions