This repository was archived by the owner on Feb 4, 2022. It is now read-only.
pool - Corrects domain issue on _createConnection #255
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'll start with, I hate domains, but while working on some unit tests we discovered an issue related to issuing queries in a rapid fire manner which caused our domains to go haywire. After a lot of tracing we discovered the root problem.
Right now, due to a pull request I made some time ago you guys added a setting for binding the query callback to the domain that it was originally initiated on. That works fine. The problem is inside pool.js there is a spot where you will dynamically grow the pool after queries have been initiated. This can cause a call to
.find()
to result in a new pool member. If the.find()
was on a domain, then the new pool member is permanently bound to the domain. So all future queries from that pool member, whether or not they originate from a domain, will be bound to a domain, because it was created inside the internal callback structure of the.find()
.Here's a psuedo-code example
To me this makes sense because the purpose of
domainsEnabled
is to bind queries to a domain. So that way if I issue a query on a domain.find({}, cb)
, my callback is still on that domain. Now, if you guys want to be absolute sticklers, it could be refined so that we would check if the original Pool.connect was created with a domain in context, and if so we could allow THAT domain to remaind but others to not. I just don't know how realistic that use-case is, since it feels like an anti-pattern to me to create a connection on a domain, rather than issuing the connections via domain. If that's what you would like I can correct the pull request.