-
Notifications
You must be signed in to change notification settings - Fork 7.3k
ZOOKEEPER-3575: Moving sending packets in Learner to a separate thread #1116
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
|
retest maven build |
1 similar comment
|
retest maven build |
|
@eolivelli |
|
Yes. |
2f29cc7 to
6eb5e81
Compare
|
retest maven build |
|
@eolivelli we didn't see the 'restart' button on the Jenkins page, any permission we need to set up? |
ddd33f8 to
859b83f
Compare
@lvfangmin You might need administrative permission to manage Jenkins (create new project, configure, and restart jobs...). See https://cwiki.apache.org/confluence/display/INFRA/Jenkins for more details. |
|
@lvfangmin @fpj can grant you acess (only the PMCC as far as I know) |
|
|
||
| @Test | ||
| public void testLearnerMetricsTest() throws Exception { | ||
| Learner.setAsyncSending(asyncSending); |
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.
please reset the value in a @before method
it is a static flag, so it will affect other tests
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 assume you mean "reset in @after?"
| @Before | ||
| public void setup() { | ||
| System.setProperty("zookeeper.DigestAuthenticationProvider.superDigest", "super:D/InIHSb7yEEbrWz8b9l71RjZJU="/* password is 'test'*/); | ||
| Learner.setAsyncSending(asyncSending); |
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.
please reset the value in a @before method
it is a static flag, so it will affect other tests
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.
reset in @afterclass
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Learner.java
Show resolved
Hide resolved
| break; | ||
| } | ||
|
|
||
| learner.messageTracker.trackSent(p.getType()); |
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.
here https://github.com/apache/zookeeper/pull/1116/files#diff-c8b414c1ca2084ecb9fe32a0a3832d44R170
we accessing learner internal variables inside a synchronized block.
it looks like an inconsistent synchronization
maybe it depends on the fact that this feature is enabled or not, but I am not sure we are 100% safe
can you please motivate or at least leave some comment for future inspection and understanding of the flow ?
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.
Without LearnerSender, there might be more than one thread writing to leaderOs so synchronization is required.
With LearnerSender, there still might be more than one thread calling writePacket but they are writing to a BlockingQueue so it's fine. Reading from the queue and writing to leaderOs is one thread (the learner sender thread), so we don't need synchronization. It's like we synchronize on the blockingQueue implicitly.
This is tricky. I may have missed some thing. Let me know and I'll fix the code.
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.
Can you add a minimal comment to explain this point?
I agree with your explanation
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 looks good to me, it might be better to not visit the internal variable directly, but using things like get to make the code easier to manage and reason about though.
|
Refer to this link for build results (access rights to CI server needed): |
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 left one last request to add a comment
@lvfangmin @hanm PTAL
We need one more reviewer
| self.closeAllConnections(); | ||
| self.adminServer.setZooKeeperServer(null); | ||
|
|
||
| if (sender != null) { |
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.
nit: diff shows a missing space
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.
good catch
| break; | ||
| } | ||
|
|
||
| learner.messageTracker.trackSent(p.getType()); |
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.
Can you add a minimal comment to explain this point?
I agree with your explanation
lvfangmin
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, thanks Jie for upstreaming this.
| break; | ||
| } | ||
|
|
||
| learner.messageTracker.trackSent(p.getType()); |
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 looks good to me, it might be better to not visit the internal variable directly, but using things like get to make the code easier to manage and reason about though.
|
Let's merge |
|
@eolivelli Added a comment to explain the synchronization on leaderOs. |
lvfangmin
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, thanks @jhuan31, I'll merge this tomorrow if there is no objection.
|
Merged to master, thanks @jhuan31! |
Author: Jie Huang <[email protected]> Reviewers: [email protected], [email protected] Closes apache#1116 from jhuan31/ZOOKEEPER-3575
Author: Jie Huang <[email protected]> Reviewers: [email protected], [email protected] Closes apache#1116 from jhuan31/ZOOKEEPER-3575
Author: Jie Huang <[email protected]> Reviewers: [email protected], [email protected] Closes apache#1116 from jhuan31/ZOOKEEPER-3575 (cherry picked from commit 7c1251d)
Author: Jie Huang <[email protected]> Reviewers: [email protected], [email protected] Closes apache#1116 from jhuan31/ZOOKEEPER-3575
Author: Jie Huang <[email protected]> Reviewers: [email protected], [email protected] Closes apache#1116 from jhuan31/ZOOKEEPER-3575
No description provided.