-
Notifications
You must be signed in to change notification settings - Fork 630
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
fix for issue #715 - ensure cached consul connections are specific to… #716
Conversation
… a thread to avoid concurrent use of the connections across threads
Codecov Report
@@ Coverage Diff @@
## 1.6.x #716 +/- ##
=========================================
Coverage 49.73% 49.73%
Complexity 1915 1915
=========================================
Files 261 261
Lines 11738 11738
Branches 1663 1663
=========================================
Hits 5838 5838
Misses 5209 5209
Partials 691 691
Continue to review full report at Codecov.
|
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.
@miklish It looks good to me. I found a method needsToCreateConnection called from the send method to ensure that the connection is open before using it. Thanks.
It looks good. Thanks. But if local thread is closed, the connection will be still in the cache map. Even the local thread ill be reused by JVM, but in special case the connection cache map could be group to big size:
I would like suggest to add a feature to clear the connection pool cache if it reach config size (for example, 1000), we clear the map and let it rebuild by new connection: connectionPool.clear() |
@stevehu Yes, I saw that too. That is why I didn't add any code in getConnection to check if cached connections were still alive (as we had discussed yesterday). |
the default max work threads size is 200, maybe we are find with the cache size |
If the HTTP connection inside the ConsulConnection object is not used for a long time, I believe either undertow or Consul will kill the connection. So only the ConsulConnection object will remain holding a closed connection. If later (after the connection has been closed), and a thread requests that same ConsulConnection object, the ConsulConnection object first checks the status of the connection it holds, and will create a new one if needed. |
… a thread to avoid concurrent use of the connections across threads (#716)
@chenyan71 @jsu216 Can you folks approve today? @chenyan71 You have a tight timeline... it appears you are OK with the changes. If you could approve asap it would be appreciated. |
@chenyan71 @jsu216 Nevermind, I see that this has been merged already :) |
…ecific to a thread to avoid concurrent use of the connections across threads (networknt#716)
… a thread to avoid concurrent use of the connections across threads.
See issue #715 for details.