-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Removed ability to disable connection pool #337
Conversation
@@ -503,6 +503,14 @@ void connectionOpened(final ClientCnx cnx) { | |||
cnx.channel().close(); | |||
return null; | |||
} | |||
|
|||
if (client.getConfiguration().getConnectionsPerBroker() == 0) { |
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.
Wouldn't it be better to close the connection after it gets not used anymore instead than after errors?
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.
How this would fix cases in which a producer is created and then closed? Or the connection used to do a topic lookup?
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.
You are right - the fix won't work in these scenarios .. I will try another approach - call close in the finalize method of ClientCnx
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.
uhm... I really don't like to get into the finalizer()
business... It can be very unpredicably called and you shouldn't do anything that could possibly block..
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 think there are still other cases in which the connections might be leaked:
- As you were doing initially, a producer might fail to create
- Connections used for topic and metadata lookups
@@ -430,16 +432,27 @@ void registerConsumer(final long consumerId, final ConsumerImpl consumer) { | |||
consumers.put(consumerId, consumer); | |||
} | |||
|
|||
void closeIfNotUsedAgain() { | |||
if (producers.size() == 0 && consumers.size() == 0 && isConnectionPoolingDisabled) { |
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.
The cheapest check is for the final
boolean flag:
if (isConnectionPoolingDisabled && producers.isEmpty() && consumers.isEmpty()) {
....
}
@merlimat
|
4baa728
to
1dc10ea
Compare
@jai1 The only reason to disable connection pooling was for testing purposes, to simulate multiple connections hitting broker. I don't see any other good reason to disable pooling. If it's just for the test, then it may make more sense to enforce the pool to be always there (>=1) and if we want to test with many connections, just use a huge number of connections per host in the pool settings. What do you think? |
3042f7a
to
f9e0d37
Compare
@merlimat - This looks ok? |
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.
👍
* Avoid producer deadlock on connection closing * Fixed constants init * Avoid creating timer instance each time, if channel is not full * Added debug statements
Fixes apache#336 Besides applying the LightProto generated new package name and some new APIs, this PR also fixes the tests error caused by apache#9240, which introduces a new method PulsarService#createLocalMetadataStore. And some tests are affected by the wrong parse of entry data after the pulsar update, this PR fixes the test failures.
Motivation
Fix for #331
Modifications
Check if the cnxpool is off and close the connection if cnx failed
Result
Client can't open too many connections on broker.