-
Notifications
You must be signed in to change notification settings - Fork 973
Reorder the sequence of the bookkeeper server shutdown so that there are no read/ write ops while shutting down the bookie #2888
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
Changes from all commits
9f00279
7fec12a
66b2513
5a29761
f8c2525
b7908b9
e6b5501
15abe17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,7 +66,12 @@ protected boolean isVersionCompatible() { | |
| } | ||
|
|
||
| protected void sendResponse(int rc, Object response, OpStatsLogger statsLogger) { | ||
| channel.writeAndFlush(response, channel.voidPromise()); | ||
| if (channel.isActive()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about adding a "ELSE" branch with a log message ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently what happens when the BookieServer is shutdown is that for each in-progress op, when the response is sent it will fail because the channel is closed, and that will get logged as a metric: So either we add an ELSE branch with the same registerFailedEvent call, or we don't use an IF at all and allow it to use the existing logic flow. @pradeepbn what was the reason for avoiding
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say this change is not strictly related to shutdown reordering, so I think removing these channel checks can be removed from this PR.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If we do not check for isActive(), we will get this exception on
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a controlled exception within Netty but it will pollute the log during shutdown. So I think that's its worth keeping the IF statement. What do you think @eolivelli?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, let's keep the original "if" we could add an "else" branch with a DEBUG log that says that we are skipping the write, this would help in debugging tests failures probably one day
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the else statement with the logs. CC: @eolivelli @Vanlightly |
||
| channel.writeAndFlush(response, channel.voidPromise()); | ||
| } else { | ||
| LOGGER.debug("Netty channel {} is inactive, " | ||
| + "hence bypassing netty channel writeAndFlush during sendResponse", channel); | ||
| } | ||
| if (BookieProtocol.EOK == rc) { | ||
| statsLogger.registerSuccessfulEvent(MathUtils.elapsedNanos(enqueueNanos), TimeUnit.NANOSECONDS); | ||
| } else { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,25 +87,29 @@ protected void sendResponse(StatusCode code, Object response, OpStatsLogger stat | |
| requestProcessor.invalidateBlacklist(channel); | ||
| } | ||
| } | ||
|
|
||
| channel.writeAndFlush(response).addListener(new ChannelFutureListener() { | ||
| @Override | ||
| public void operationComplete(ChannelFuture future) throws Exception { | ||
| long writeElapsedNanos = MathUtils.elapsedNanos(writeNanos); | ||
| if (!future.isSuccess()) { | ||
| requestProcessor.getRequestStats().getChannelWriteStats() | ||
| .registerFailedEvent(writeElapsedNanos, TimeUnit.NANOSECONDS); | ||
| } else { | ||
| requestProcessor.getRequestStats().getChannelWriteStats() | ||
| .registerSuccessfulEvent(writeElapsedNanos, TimeUnit.NANOSECONDS); | ||
| } | ||
| if (StatusCode.EOK == code) { | ||
| statsLogger.registerSuccessfulEvent(MathUtils.elapsedNanos(enqueueNanos), TimeUnit.NANOSECONDS); | ||
| } else { | ||
| statsLogger.registerFailedEvent(MathUtils.elapsedNanos(enqueueNanos), TimeUnit.NANOSECONDS); | ||
| if (channel.isActive()) { | ||
|
Vanlightly marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about adding a "ELSE" branch with a log message ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| channel.writeAndFlush(response).addListener(new ChannelFutureListener() { | ||
| @Override | ||
| public void operationComplete(ChannelFuture future) throws Exception { | ||
| long writeElapsedNanos = MathUtils.elapsedNanos(writeNanos); | ||
| if (!future.isSuccess()) { | ||
| requestProcessor.getRequestStats().getChannelWriteStats() | ||
| .registerFailedEvent(writeElapsedNanos, TimeUnit.NANOSECONDS); | ||
| } else { | ||
| requestProcessor.getRequestStats().getChannelWriteStats() | ||
| .registerSuccessfulEvent(writeElapsedNanos, TimeUnit.NANOSECONDS); | ||
| } | ||
| if (StatusCode.EOK == code) { | ||
| statsLogger.registerSuccessfulEvent(MathUtils.elapsedNanos(enqueueNanos), TimeUnit.NANOSECONDS); | ||
| } else { | ||
| statsLogger.registerFailedEvent(MathUtils.elapsedNanos(enqueueNanos), TimeUnit.NANOSECONDS); | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| }); | ||
| } else { | ||
| LOGGER.debug("Netty channel {} is inactive, " | ||
| + "hence bypassing netty channel writeAndFlush during sendResponse", channel); | ||
| } | ||
| } | ||
|
|
||
| protected boolean isVersionCompatible() { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.