-
Notifications
You must be signed in to change notification settings - Fork 0
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
Use connection pause/resume to prevent kill race condition #7
Use connection pause/resume to prevent kill race condition #7
Conversation
@@ -1051,6 +1051,68 @@ module.exports = function (knex) { | |||
}); | |||
}); | |||
|
|||
it('.timeout(ms, {cancel: true}) should not cancel subsequent queries in a transaction if timeouted query completes while being cancelled', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test will fail without connectionToKill.pause()
/resume()
in Client_MySQL.cancelQuery()
method. The test simulates a race-condition when the timeouted query manages to complete while we are trying to kill it. It is simulated by slowing down Client_MySQL.acquireRawConnection()
method.
The current behaviour without connectionToKill.pause()
/resume()
:
Fixed behaviour without the race condition with connectionToKill.pause()
/resume()
:
Btw, note that query B has no timeout, to make sure it won't timeout while waiting in the queue.
lib/dialects/mysql/index.js
Outdated
@@ -179,6 +180,7 @@ class Client_MySQL extends Client { | |||
if (conn.__knex__disposed) { | |||
this.logger.warn(`Connection Error: ${conn.__knex__disposed}`); | |||
} | |||
connectionToKill.resume(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor tweak: this could be run before connection destroy, so working connection will continue to work earlier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved in f1a3d8a
…se-all-timeout-error+dequeue-in-driver+pause-resume Conflicts: test/integration/query/additional.js
* Use connection pause/resume to prevent kill race condition * Move connection resume before destroy raw connection Conflicts: lib/dialects/mysql/index.js
No description provided.