-
Notifications
You must be signed in to change notification settings - Fork 963
[bk-gc] Fix GC thread gets blocked #1937
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
|
Fwiw, we saw a similar hang which turned out to be caused by apache/zookeeper#787 I think this patch may be a good idea nevertheless. I'd like to see the timeout passed as a param, however. |
| while (!ctx.done) { | ||
| ctx.wait(); | ||
| try { | ||
| ctx.wait(TimeUnit.SECONDS.toMillis(OP_TIME_OUT_SEC)); |
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.
In this case, if no one calls ctx.done = true, the thread will just keep waiting in 2sec blocks, but it will never exit, right?
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.
umm.. if no one calls ctx.done = true; ctx.notifyAll(); at line#238 then ctx.wait(timeout) will throw InterruptedException and ctx.done will be true; at line#249 which takes out thread out of while loop. So, it will not keep waiting but exit. right?
| try { | ||
| zkActiveLedgers = ledgerListToSet( | ||
| ZkUtils.getChildrenInSingleNode(zk, ledgerRootPath), ledgerRootPath); | ||
| ZkUtils.getChildrenInSingleNode(zk, ledgerRootPath, ZkUtils.OP_TIME_OUT_SEC), |
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 I mean is, it should probably be passed in from the gc thread. The gc caller should probably get its value from a config. Doing it here doesn't allow different users with different tolerances to provide different bounds. Also, passing in 0 should mean no limit.
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 to what @athanatos suggested. I would like to see a setting configurable.
|
@rdhabalia without fixing the real issue (taking forever to fetch ledgerznodes), how would this fix help? It can run into the same issue again, right? |
the real issue is when zk does zxid rollover, it restarts the leader and zk-client doesn't receive the callback for in transit requests. however, new outgoing requests will not have the issue once zk quorum will come back. so, with this fix, blocked zk-call will be timeout and next time it will succeed. |
|
@rdhabalia No, the patch I linked above addresses a problem with the zk client side cxid (which unlike the zxid increments with reads), not the zk server side zxid. Rolling the client side cxid is actually harmless and does not require a leader election. With that patch, this call won't hang in the first place. However, that may not be the only such bug and there are other ways for zk calls to hang, so this patch may nevertheless be useful for some auxiliary zk users like the gc scan. |
| } | ||
|
|
||
| /** | ||
| * Get zk-operation timeout in seconds used by GC while performing zk |
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.
If this is only for GC we should provide a more meaningful name.
Can you change it please?
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 this could be generic configuration for timeout and can be used at anywhere where bookie needs blocking zk call. However, I think we can also use existing zkTimeout which can genuinely guarantees that zk-session is alive and callback couldn't complete. or let me know if you guys think we need different name?
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.
We can save adding this new knob and use zkTimeout * N in your change, infact our problem is that we want to put an upperbound to the time spent waiting.
I think that our Zookeeper clients retries and creates new 'sessions' in case of session expiration. So I don't know which value is most suitable for N, we can start with 2.
How does this sounds to you?
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.
@eolivelli sure, that will be also fine. I have fixed it.
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.
Looks good.
Thank you
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.
You didn't update etcd driver and CI is failing.
Please fix
sijie
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.
can you add the settings to conf/bk_server.conf?
|
|
@eolivelli sorry I didn't follow the discussion. I just checked the conversation. I am not sure if using 2 * zkTimeout is a good idea. I would prefer a separate setting called zkOpTimeout, so people can really configure op timeout. We can set the default |
Ok @sijie A new parameter works for me as well but I think it should be stated clearly that it is only for GC operations |
if it is only for GC operations, I am fine with current approach. |
Yes, in previous commit, I have added separate config but then we realize that for now, it only needs for GC and GC should expect response before zk-session time out happens so, |
|
run integration tests |
|
run integration tests |
|
@eolivelli can we merge this PR? |
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.
Sure. Go ahead
Sorry, I forgot to 'approve'
|
Merging now |
Motivation
It addresses below thread-stuck while performing gc in bookie.
Changes
add time-out to zk operation to avoid GC thread blocking.