-
Notifications
You must be signed in to change notification settings - Fork 14k
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
KAFKA-10723: Fix LogManager shutdown error handling #9596
Changes from 2 commits
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 |
---|---|---|
|
@@ -479,25 +479,33 @@ class LogManager(logDirs: Seq[File], | |
|
||
try { | ||
for ((dir, dirJobs) <- jobs) { | ||
dirJobs.foreach(_.get) | ||
val hasErrors = dirJobs.exists { | ||
future => | ||
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. Nit: this should be in the previous line. 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. |
||
try { | ||
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. You can use 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. Good idea, done. |
||
future.get | ||
false | ||
} catch { | ||
case e: ExecutionException => | ||
warn(s"There was an error in one of the threads during LogManager shutdown: ${e.getCause}") | ||
true | ||
} | ||
} | ||
|
||
val logs = logsInDir(localLogsByDir, dir) | ||
if (!hasErrors) { | ||
val logs = logsInDir(localLogsByDir, dir) | ||
|
||
// update the last flush point | ||
debug(s"Updating recovery points at $dir") | ||
checkpointRecoveryOffsetsInDir(dir, logs) | ||
// update the last flush point | ||
debug(s"Updating recovery points at $dir") | ||
checkpointRecoveryOffsetsInDir(dir, logs) | ||
|
||
debug(s"Updating log start offsets at $dir") | ||
checkpointLogStartOffsetsInDir(dir, logs) | ||
debug(s"Updating log start offsets at $dir") | ||
checkpointLogStartOffsetsInDir(dir, logs) | ||
|
||
// mark that the shutdown was clean by creating marker file | ||
debug(s"Writing clean shutdown marker at $dir") | ||
CoreUtils.swallow(Files.createFile(new File(dir, Log.CleanShutdownFile).toPath), this) | ||
// mark that the shutdown was clean by creating marker file | ||
debug(s"Writing clean shutdown marker at $dir") | ||
CoreUtils.swallow(Files.createFile(new File(dir, Log.CleanShutdownFile).toPath), this) | ||
} | ||
} | ||
} catch { | ||
case e: ExecutionException => | ||
error(s"There was an error in one of the threads during LogManager shutdown: ${e.getCause}") | ||
throw e.getCause | ||
} finally { | ||
threadPools.foreach(_.shutdown()) | ||
// regardless of whether the close succeeded, we need to unlock the data directories | ||
|
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 wrong.
exists
short-circuits. I think you wantmap
followed byexists
.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.
Thats a really good point. Done.