-
Notifications
You must be signed in to change notification settings - Fork 39
Fix conviction policy counter go negative #466
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 conviction policy counter go negative #466
Conversation
3c28cef to
5bc688d
Compare
|
nice warpup, of you fixing the issue you raise almost 3 years ago :) |
Bouncheck
left a comment
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.
List<Connection> newConnections(HostConnectionPool pool, int count) calls List<Connection> connections = Lists.newArrayListWithCapacity(count); which should throw IllegalArgumentException when the count is negative. While it's better to guard signal against negatives which technically could still happen, was that exception ever seen? It would be weird if not.
It is 0 at the time, reduced by 1 afterwards. |
I don't follow. The |
Bouncheck
left a comment
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.
unblocking
Yes, you are correct, let me look into it furthere. |
44baa62 to
b8fe3c6
Compare
|
@Bouncheck , please check again, I have decided to remove assert, reasoning on the PR description, commit and comments. |
Bouncheck
left a comment
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.
IIUC assert removal is necessary. I think removing assert line and adding a comment is enough.
I see no reason to increment the counter when going negative. It does not fix the behavior and with this increment the number loses its meaning. Even if it was negative it would at least always be equal to <opens performed - closes performed>.
Loose connection between Connection and ConvictionPolicy (i.e Host) it is impossible to guarantee that single connection addresses same `openConnections` counter Which opens up opportunity for this assertion to fail in rare cases. Fixing this issue would involve major refactoring of `Connection.java` binding connection to `Host`, instead of `Endpoint` Giving low impact of given issue doing refactoring makes no sense.
b8fe3c6 to
fa4fbf9
Compare
You are correct, but we have to fix |
Loose connection between Connection and ConvictionPolicy (i.e Host) it is impossible to guarantee that single connection addresses same `openConnections` counter Which opens up opportunity for this assertion to fail in rare cases. Fixing this issue would involve major refactoring of `Connection.java` binding connection to `Host`, instead of `Endpoint` Giving low impact of given issue doing refactoring makes no sense.
DefaultConvictionPolicy.openConnections can become negative:
It happens because there's a loose connection between
ConnectionandConvictionPolicy(i.e.,Host), which makes it impossible to guarantee that a single connection always address sameopenConnectionscounter.This can occasionally lead to assertion failures in rare cases on given line:
assert remaining >= 0;Fixing this would require refactoring
Connection.javato bind connections toHostinstead ofEndpoint, which is not justified considering low impact of this issue.Fixes: #82