-
Notifications
You must be signed in to change notification settings - Fork 15
Fix race condition causing 'pool not open' errors #5882
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -399,15 +399,16 @@ public void addPool(InetSocketAddress server) { | |
|
||
public void removePool(InetSocketAddress removedServerAddress) { | ||
blacklist.remove(removedServerAddress); | ||
CassandraClientPoolingContainer containerToRemove = currentPools.get(removedServerAddress); | ||
currentPools.remove(removedServerAddress); | ||
try { | ||
currentPools.get(removedServerAddress).shutdownPooling(); | ||
containerToRemove.shutdownPooling(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. technically doesn't fully solve the issue: what if there are in-flight requests on the pool-to-be-closed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, yes - ideally we'd have something that will: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like once we've called I'm not averse to adding something like this if it's proven to be necessary (and I can follow up this PR with logging to help us to determine this), but for now I think in-flight requests should continue to work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's pretty nice, actually! |
||
} catch (Exception e) { | ||
log.warn( | ||
"While removing a host ({}) from the pool, we were unable to gently cleanup resources.", | ||
SafeArg.of("removedServerAddress", CassandraLogHelper.host(removedServerAddress)), | ||
e); | ||
} | ||
currentPools.remove(removedServerAddress); | ||
} | ||
|
||
public void cacheInitialCassandraHosts() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
type: fix | ||
fix: | ||
description: Fixed a race condition where we would potentially attempt to use a | ||
Cassandra client pool that we had already closed. | ||
links: | ||
- https://github.com/palantir/atlasdb/pull/5882 |
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.
remove
returns the value removed, so we shouldn't need the get as well.