Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUnref mysql sockets so the process is not kept alive by them. Closes … #1987
Conversation
Hi @mihai1voicescu thanks so much! I'm having a lost of failures when trying to run scripts with your change. Even the script in our introduction to this module (https://github.com/mysqljs/mysql#introduction) no longer works. On |
There's no timer for waiting the server's reply to a request, is it? If it were, the fix would have worked just fine. |
I'm not sure I'm following here. Whatever you think the right solution is, please update the PR with it |
I'm talking about the simple example at https://github.com/mysqljs/mysql#introduction. It exits prematurely because there's nothing waiting for the answer to the request, now that the socket is not anymore a reason for the event loop to stay alive. |
Ah, does that mean you need to update the README in this PR? Also, would that make this change not backwards-compatible with the code out there? If so, can you write up a migration guide we can include to help people migrate their code? |
I'm entirely against putting on users' shoulders another thing to care for. The timer I'm talking about must be implemented in this module and any pending request should have an accompanying I believe that if you point @mihai1voicescu to the right place in your code, where the pairing of responses to requests is made, he'll do the necessary changes. To be honest, this is not exactly backwards compatible, as people with slower databases or more complicated queries will have to care for this new configuration parameter, no matter what default value you'd choose for it. |
Makes sense. The pairing is done in the Protocol.js file |
After some thinking I came to the conclusion that it's better to ref the socket when the associated command queue has items and unref it when the queue is empty or a fatal error occurs. This will make the code be as backwards compatible as it can. I will make a pull request but please double check that I covered all the possible cases. |
… alive only when an answer is expected. Fix procedure tests. Closes #1986
All the tests pass now. Hope it's OK. Maybe have a look in the |
I think it's OK now. |
Awesome, thank you! I tried it out and after playing around with the changes and through they were good, suddenly my MySQL user was locked out. Digging into it, it seems that this change is causing the https://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html#statvar_Aborted_clients variable to constantly increase, and eventually hits a block limit on a user. Is there a way to avoid that? I wouldn't what this module to cause account to get locked. You can query your aborted variable with I'm not sure what the correct way forward is here, and here are some of my thoughts, but I'll leave the solution up to you as the expert here (1) Maybe just add warnings all over the docs that if you don't call P.S. it looks like some of the CI builds are failing from the |
The CI builds fail because in 0.6 and 0.8 apparently there was no
As for the locking out part you are right, it's a pretty big problem but I have a very good solution. |
Ah. So that would require a new major version of this library. That's OK if that really is necessary. We can queue up a 3.0 branch you can target for this change, then
Ah, didn't know about beforeClose. That sounds like a reasonable solution to me |
I ran into some problems on the Pool side in the tests. First of all I get this warning:
Second a test fails:
From what I can tell, the problem is that when the server shuts down, releases are generated for the respective ended connections resulting in duplicate releases. Unfortunately I have no idea how to fix this Another weird thing is that running the tests still increases the
But my simple example does not.
Click for git diff
|
Any news |
Sorry I kind if forgot about this PR. I will take a look to answer your questions this evening my time. Do you know why the CI is failing for this? We wouldn't be able to merge with a failing build normally, at least |
946727b
to
37fbbdd
Closes #1986