-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New Pool options and refactoring. #1591
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
Conversation
Thanks a lot @ifsnow ! Is it possible to break this up into multiple PRs instead of one massive one? At the very lest to break it up into many different commits in the PR? It's a lot to really look through and understand the edge cases that will break people if this is applied without a major version bump. |
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.
Break apart so it can be reviewed easier.
@@ -11,10 +11,10 @@ server.listen(common.fakeServerPort, function (err) { | |||
pool.getConnection(function (err, connection) { | |||
assert.ifError(err); | |||
|
|||
assert.strictEqual(connection, pool._allConnections[0]); | |||
assert.strictEqual(connection, pool._connectionManager._allConnections._map[1]); |
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.
Even though this is an underscore-prefixed property, people really do use it, as I've seen throughout Stackoverflow and issues here. We can't change this without a major at this point. Hopefully it's possible to implement the idel timeout stuff without making this change.
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.
It's a sad situation. I'll work to provide important old properties.
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.
At this point in the module, probably every single property is important in some way. I would err on the site of just not changing them if you don't really need to.
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.
I really understand. but, I think it's uncommon to use those properties such as Pool._acquiringConnections
directly. It seems that it's not easy and efficient to work with all the existing ones.
I thought shortly.
pool.createPool({
...,
keepOldProperties : true
});
If the user set this, 4 properties(_acquiringConnections, _allConnections, _freeConnections, _connectionQueue) are updated. Isn't it enough?
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.
No, because if it's opt-in for backwards compatibility, then it's not backwards compatible, according to the semver spec. The old properties should be available by default without opt-in,
A quick Google search shows someone's code that is public (obviously there is probably way more non-public code) showing how people do use these properties: https://github.com/bobcui/potato/blob/e9f9def2dab26d738d45adfbf38743632a30278b/app/modules/mysql.js#L20
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 PR does not make sense if keeping all properties is essential. I'm a little worried about what to do. Unfortunately, I think I'd better close this.
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.
@ifsnow I think a lot of the pool optimizations are worth it, and certainly can make it into a major version of this module. The only real concern I have is that because this is just one giant PR, making good (but breaking) changes and making good but non-breaking changes, together, I have no option but to delay all the features in this PR until the next major. If you can simply break it up into the different pieces as multiple PRs, we can easily accept the easy ones now and discuss the breaking ones better and decide on the release of a new major version.
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.
@dougwilson I really know how difficult it's to review many changes. I'm going to think about how I can break it up but, it's not easy. That's because PoolConnectionManager
has all new functions. I wonder if it's possible to split this into multiple PRs easily.
638d79d
to
88bade0
Compare
I hope
Pool
's features will get better like the others, so I added several options such asqueueWaitTimeout
,pingCheckInterval
,startConnections
,minSpareConnections
,maxSpareConnections
,spareCheckInterval
(See Readme.md)
These were what I aimed at.
Efficient code
Pool
will work 10~50 times faster with new options.Easy-to-read code
I've tried to make the code easier to read and maintain for the following contributors, and tidy up wrong and unused logics.
Backwards compatibility code
All defaults for new options are off. All tests are passed, so existing users can use it right now.
In my opinion, It's recommended that they use the new options as other pools do.
Here is my config below.
If you agree on my opinion, you can change the default value of new options. or, I think you could add a comment at Readme.md like this.
I hope this helps.
Please let me know if you have any concerns or advice.