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

Fixed unresolved promise in cancelQuery(..) ... #3666

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 11 additions & 20 deletions lib/dialects/mysql/index.js
Expand Up @@ -171,27 +171,18 @@ Object.assign(Client_MySQL.prototype, {

canCancelQuery: true,

cancelQuery(connectionToKill) {
const acquiringConn = this.acquireConnection();

// Error out if we can't acquire connection in time.
// Purposely not putting timeout on `KILL QUERY` execution because erroring
// early there would release the `connectionToKill` back to the pool with
// a `KILL QUERY` command yet to finish.
return timeout(acquiringConn, 100)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Short story: I remove the 100ms timeout here.

I think the logic was intended to "cancel the cancellation" if it took too long. In reality, it was just returning control to the caller after 100ms; yet the actual cancellation operation was still running.

.then((conn) =>
this.query(conn, {
method: 'raw',
sql: 'KILL QUERY ?',
bindings: [connectionToKill.threadId],
options: {},
})
)
.finally(() => {
// NOT returning this promise because we want to release the connection
// in a non-blocking fashion
acquiringConn.then((conn) => this.releaseConnection(conn));
async cancelQuery(connectionToKill) {
const conn = await this.acquireConnection();
try {
return await this.query(conn, {
method: 'raw',
sql: 'KILL QUERY ?',
bindings: [connectionToKill.threadId],
options: {},
});
} finally {
await this.releaseConnection(conn);
}
},
});

Expand Down