-
Notifications
You must be signed in to change notification settings - Fork 908
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 bookie process still alive when bookie startup is not successful and shutdown #4111
base: master
Are you sure you want to change the base?
Fix bookie process still alive when bookie startup is not successful and shutdown #4111
Conversation
@@ -821,6 +882,8 @@ public void testBookieStartException() throws Exception { | |||
loggerOutput.expect((List<LoggingEvent> logEvents) -> { |
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'd better assert startFuture and startFuture2 separately.
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.
have done.
@@ -127,7 +127,7 @@ public void start() throws InterruptedException, IOException { | |||
if (!this.bookie.isRunning()) { | |||
exitCode = bookie.getExitCode(); | |||
this.requestProcessor.close(); | |||
return; | |||
throw new InterruptedException("fail fast, bookie startup is not successful"); |
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 would better define another Exception; the InterruptedException
is for the thread
case.
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 we define it "BookieStartException", extends the BookieException ?
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.
Sounds good.
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.
have done.
@TakaHiR07 Could you take a look at the check style issue? Thanks. |
have fix checkstyle. |
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.
@TakaHiR07 Would you please help fix the failed tests? Thanks. |
69c8557
to
108d258
Compare
@hangc0276 I have fix the test since powermock is removed in master branch. |
108d258
to
3e48ecb
Compare
update the branch |
Normally, "Main" thread will wait for "component-shutdown-thread" thread to complete the "component start future". Your edition will cause future complete too soon, and main thread exit, which may cause shutdown not finished and process exit? |
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 it's not an APIException, should we define this exception in https://github.com/apache/bookkeeper/blob/master/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/ExitCode.java ?
"component start future" would complete only when exception throw. if bookie.start() encounter exception, it may catch some exception and go into shutdown(). only shutdown finish, then bookie.isRunning() become false, then go into the edition code. |
ExitCode looks like pointing out the exact reason why bookie start fail. It seems not appropriate to put this exception here, this exception only point out that bookie start fail. |
Many failed test shows that in previous design, bookieServer start failed, but not throw exception. I think these test is also unreasonable and should be fixed. Looking forward to more views, then I would fix these test. |
Motivation
When bookie startup encounter IOException in BookieImpl#readJournal(), bookie startup is not successful and then trigger shutdown(). However, bookie process is still alive.
The reason is IOException is caught in BookieImpl and trigger shutdown. Bookie actually is not running. But the exception do not throw to startComponent.
So BookieServer.main / server.Main.doMain still wait for the startComponent future to complete.
The relevant code is as following:
bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieImpl.java
Lines 654 to 660 in 3221aa3
bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
Lines 123 to 131 in 3221aa3
bookkeeper/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/ComponentStarter.java
Lines 63 to 87 in 3221aa3
Changes
throw exception to startComponent when bookie start encounter error.