-
Notifications
You must be signed in to change notification settings - Fork 7.3k
ZOOKEEPER-3253: client should not send requests with cxid=-4, -2, or -1 #787
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
Conversation
|
Interesting. |
|
Yeah, I've got the 3.4 one ready, 3.5 presumably also easy. |
eolivelli
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.
awesome work @athanatos
I left a couple of comments, please take a look
| * the server. Thus, getXid() must be public. | ||
| */ | ||
| synchronized public int getXid() { | ||
| // xid values of -4, -2, and -1 are special, see SendThread.readResponse |
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.
What about introducing constants for these special values ? (and replace in readResponse)
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 do protocol level constants like that usually get put?
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.
Also, that seems a bit intrusive for a patch I want to backport since it would also touch the server side. I suppose I could add it as an additional commit and only backport the actual fix?
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 am thinking about having constants only locally to this file, this way it will be easier to understand the code and the patch wouldn't be so intrusive.
In the (hopefully near) future we will separate client size code from server side code so introducing new shared constants would be overkilling.
I don't fell strong about having such constants, it is only a thought/suggestion.
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'm inclined to keep the patch minimal since grepping for those identifiers wouldn't tell you where those packets get sent. Also, the numerical values are useful to see here. I don't feel strongly about it though.
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.
no problem from my side, let's keep the patch simple
| } | ||
| } | ||
|
|
||
| protected ClientCnxn createConnection(String chrootPath, |
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.
what about overriding this method only in your new testcase?
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 figured that the xid manipulation methods might be generally useful. Also, createClient test helper method explicitly creates a TestableZooKeeper, so I'd have to create another version of that, I think. Doesn't seem worthwhile.
eolivelli
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.
LGTM
thank you
+1 (non binding)
|
Is this waiting on something from me? |
|
We need two committers to review and then merge. Tagging @anmolnar |
|
Anything I can do to move this along? |
|
@anmolnar can we include this in 3.5.5 and 3.4.14? |
|
@eolivelli 3.5.5 is fine, but 3.4.14 is already cut, I wouldn't touch it anymore. We can make an exception if it's critical, but we need at least one more committer to review. |
nkalmar
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.
Nice and simple fix, good test addition.
+1, thanks!
zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java
Outdated
Show resolved
Hide resolved
49e93a5 to
3cd4e8a
Compare
|
Ok, I pushed a version that wraps from MAX to 1 avoiding negative values entirely. @phunt |
anmolnar
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.
+1 lgtm
|
So here's my current concern, which I have not had time yet to look at and I think should be addressed before this is committed - what happens on the server side? Is it allowing the cxid to "go back in time", if so is that ok, if not then what happens? (e.g. does it disco the client session?) |
|
@phunt I was unable to find anything server side that actually compares cxids other than to check equality. I believe this patch to be safe so long as two requests with the same cxid on the same session are not live at the same time -- which a 31 bit cxid is probably sufficient to ensure. Note, the current implementation already permits wrapping from MAX to MIN. This behavior occurs regularly in our environment and the only misbehavior it seems to cause is that the requests submitted with a cxid value of -4, -2, or -1 hang or cause a reconnect. The patch also includes a test to exercise the behavior specifically. |
3cd4e8a to
381d167
Compare
|
Pushed to fix the commit message -- forgot to update it before. |
phunt
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.
+1 looks good to me with a minor nit that should be addressed. I will then commit this.
We want this to go into master, seems like we should also commit to at least 3.5? Anyone with strong opinions re 3.4? (I would probably lean towards commiting there as well)
| } | ||
| }, null); | ||
| Assert.assertTrue("setData should complete within 5s", | ||
| latch.await(5, TimeUnit.SECONDS)); |
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 is generally an anti-pattern in the tests and leads to flakey tests. e.g. we can see on some test environments that are oversubscribed. I'd suggest something very large, e.g. 30 seconds or just using the session timeout.
- Add test for cxid rollover to 1 - Modify ClientCnxn.SendThread.getXid() to increment from MAX to 1.
381d167 to
904cc30
Compare
|
@phunt I pushed a version with that changed. The JenkinsMaven failure doesn't appear related to this patch. |
|
+1, lgtm. thanks @athanatos I also reviewed the server side code and it looks like client xid "going back in time" (my earlier concern) is fine. I did notice this however - notice negative client xids circumvent throttling! So we're fixing this bug as well by resetting the xid before it rolls over. |
- Add test for cxid rollover to 1 - Modify ClientCnxn.SendThread.getXid() to increment from MAX to 1. Author: Samuel Just <sjust@salesforce.com> Reviewers: phunt@apache.org Closes #787 from athanatos/forupstream/ZOOKEEPER-3253 Change-Id: Ib3d111170bb086d6982f2cf0ee5cf8afd5157588 (cherry picked from commit e10c93a) Signed-off-by: Patrick Hunt <phunt@apache.org>
- Add test for cxid rollover to 1 - Modify ClientCnxn.SendThread.getXid() to increment from MAX to 1. Author: Samuel Just <sjust@salesforce.com> Reviewers: phunt@apache.org Closes #787 from athanatos/forupstream/ZOOKEEPER-3253 Change-Id: Ib3d111170bb086d6982f2cf0ee5cf8afd5157588 (cherry picked from commit e10c93a) Signed-off-by: Patrick Hunt <phunt@apache.org>
- Add test for cxid rollover to 1 - Modify ClientCnxn.SendThread.getXid() to increment from MAX to 1. Author: Samuel Just <sjust@salesforce.com> Reviewers: phunt@apache.org Closes apache#787 from athanatos/forupstream/ZOOKEEPER-3253 Change-Id: Ib3d111170bb086d6982f2cf0ee5cf8afd5157588 (cherry picked from commit e10c93a) Includes backport of createConnection testability refactor from 9f82798. Signed-off-by: Samuel Just <sjust@salesforce.com>
- Add test for cxid rollover to 1 - Modify ClientCnxn.SendThread.getXid() to increment from MAX to 1. Author: Samuel Just <sjustsalesforce.com> Reviewers: phuntapache.org Closes #787 from athanatos/forupstream/ZOOKEEPER-3253 Change-Id: Ib3d111170bb086d6982f2cf0ee5cf8afd5157588 (cherry picked from commit e10c93a) Includes backport of createConnection testability refactor from 9f82798. Signed-off-by: Samuel Just <sjustsalesforce.com> Author: Samuel Just <sjust@salesforce.com> Reviewers: phunt@apache.org Closes #844 from athanatos/forupstream/ZOOKEEPER-3235-3.4
- Add test for cxid rollover to 1 - Modify ClientCnxn.SendThread.getXid() to increment from MAX to 1. Author: Samuel Just <sjust@salesforce.com> Reviewers: phunt@apache.org Closes apache#787 from athanatos/forupstream/ZOOKEEPER-3253 Change-Id: Ib3d111170bb086d6982f2cf0ee5cf8afd5157588
- Add test for cxid rollover to 1 - Modify ClientCnxn.SendThread.getXid() to increment from MAX to 1. Author: Samuel Just <sjust@salesforce.com> Reviewers: phunt@apache.org Closes apache#787 from athanatos/forupstream/ZOOKEEPER-3253 Change-Id: Ib3d111170bb086d6982f2cf0ee5cf8afd5157588
Uh oh!
There was an error while loading. Please reload this page.