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
CXX-336 remove connection pool and associated cruft #167
Conversation
|
||
// Assert here instead of returning NULL since the contract of this method is such | ||
// that returning NULL means none of the nodes were good, which is not the case here. |
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 comment should probably stay.
Adam overall this looks good. I have one general comment and two high level concerns:
|
re: whitespace changes, I think I'm just going to bite the bullet and undo them I don't think it should be hard to implement a pool. The DBClient supplies a public sStillConnected() method to check if a connection is still up. The rest of the work required is just constructing a threadsafe mapping of HostAndPort to List/Stack of DBClientConnection objects, which is still entirely doable. Regarding cost of creating/destroying connections, this is definitely a concern. The ReplicaSetMonitor relies on the pool to cheaply contact monitored hosts in RSM::Refresher::_refreshUntilMatches. With SCRAM this could be overly expensive. I think a stopgap would be to implement a pared down pool, private to the ReplicaSetMonitor and make ScopedDbConnection completely internal to the library. I will try to rework this PR in that direction. |
So I added a connection caching mechanism to ReplicaSetMonitor. It's pretty simple and should amortize the cost of frequently executing isMaster on RS members while refreshing RS state. It also serves as a simple example of how an end-user of the driver could implement a pool since it uses no non-public methods of DBClientConnection. |
// that returning NULL means none of the nodes were good, which is not the case here. | ||
uassert(16532, str::stream() << "Failed to connect to " << _lastSlaveOkHost.toString(), | ||
newConn != NULL); | ||
uassert(17889, "Unable to construct DBClientConnection", _lastSlaveOkConn.get()); |
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.
Where did this uassert code come from?
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.
done, just going to use 0.
This is looking good. I want to chat about the conn cache a little bit and maybe do one more round: I think it may be able to be simplified somewhat |
f0a0d54
to
8b86dca
Compare
removed whitespace changes, cleaned up conn cache, and removed unnecessary null checks. @acmorrow let me know what you think. |
const HostAndPort& _host; | ||
}; | ||
|
||
// Caller must hold cache lock. |
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.
Don't think this comment is true anymore.
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.
whoops, fixed.
LGTM. Ship it! |
8b86dca
to
6fb1d7f
Compare
sweet. |
includes a small number of trailing whitespace removal noise, but given the pretty large changes to the files involved, I think its acceptable