-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Support aborting queries #14247
Comments
If I understand correctly, what you're trying to do is cancel/abort a query? |
Yes. I am in need of it. I also think that for this some portions of "sequelize-pool" and "retry-as-promised" will also have to be updated. But I think this is something which has to be looked at. |
In my opinion, if we were to support aborting queries, it would be done using i.e. const controller = new AbortController();
const promise = User.findAll({ signal: controller.signal });
controller.abort(); The setup to kill the query would be handled internally by Sequelize There is a thread discussing aborting transactions, which includes a potential solution for postgres which seems to be based on the same idea. (#11395). As far as I know it could be simple to implement, at least for pg & MySQL (more research needed though). In MySQL it could be something like: signal.addEventListener('abort', () => {
connection.query(`KILL QUERY ${connection.processID}`);
}, { once: true }); |
I had read that recently it was introduced, but was under the impression that it would support only fetch calls. If it can be integrated inside sequelize... then that is exactly what I was wanting. |
In theory it could work on any query type. But research & testing required to determine how safe it would be on non-SELECT queries. Edit: Oh sorry you meant fetch as in the JS API
|
Issue Creation Checklist
[x] I have read the contribution guidelines
Feature Description
Is your feature request related to a problem? Please describe.
Now I am trying to implement a query kill scenario, where in from code If I decide that the current running DB query is not required, then I would be able to cancel it (keeping mysql in mind). For this I have an idea, that before executing any query where I want it to be killable later, I will execute a "SELECT CONNECTION_ID()", it will return me the connection id of the thread where this query is running.. and then If I execute the query (which is to be made killable) inside that thread id, when what I can do is this, I can kill that query later with "KILL " and my job will be done.
Describe the solution you'd like
For this I think if I can return an ID/the thread ID/the thread object in the response of the query, and then I can resupply that in the next query, then what can be done is I can execute the query in that same thread (if possible)
Why should this be in Sequelize
Since threadpool are managed inside sequelize, I was thinking of implementing in inside sequelize itself.
Describe alternatives/workarounds you've considered
Additional context
Feature Request Checklist
Is this feature dialect-specific?
Would you be willing to implement this feature by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: