-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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-6710: Remove Thread.sleep from LogManager.deleteLogs #4771
KAFKA-6710: Remove Thread.sleep from LogManager.deleteLogs #4771
Conversation
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.
@rajinisivaram : Thanks for catching this. LGTM. Just a minor comment below.
def hasDeletableLog: Boolean = { | ||
if (!logsToBeDeleted.isEmpty) { | ||
val (_, scheduleTimeMs) = logsToBeDeleted.peek() | ||
scheduleTimeMs + currentDefaultConfig.fileDeleteDelayMs - time.milliseconds() <= 0 |
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.
Perhaps we can return the time to wait for the next task and in line 742, wait for that amount instead of always the default currentDefaultConfig.fileDeleteDelayMs. This will make the deletion time of the next item more accurate.
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.
@junrao Thanks for the review, I have updated the code.
@rajinisivaram Thanks for catching this. The change makes sense. |
@lindong28 Thanks for the review. |
@junrao @lindong28 @tedyu Thank you for the review. Merging to trunk and 1.1. |
`Thread.sleep` in `LogManager.deleteLogs` potentially blocks a scheduler thread for up to `log.segment.delete.delay.ms` with a default value of a minute. To avoid this, `deleteLogs` now deletes the logs for which `currentDefaultConfig.fileDeleteDelayMs` has elapsed after the delete was scheduled. Logs for which this interval has not yet elapsed are considered for deletion in the next iteration of `deleteLogs`, which is scheduled sooner if required. Reviewers: Jun Rao <junrao@gmail.com>, Dong Lin <lindong28@gmail.com>, Ted Yu <yuzhihong@gmail.com>
`Thread.sleep` in `LogManager.deleteLogs` potentially blocks a scheduler thread for up to `log.segment.delete.delay.ms` with a default value of a minute. To avoid this, `deleteLogs` now deletes the logs for which `currentDefaultConfig.fileDeleteDelayMs` has elapsed after the delete was scheduled. Logs for which this interval has not yet elapsed are considered for deletion in the next iteration of `deleteLogs`, which is scheduled sooner if required. Reviewers: Jun Rao <junrao@gmail.com>, Dong Lin <lindong28@gmail.com>, Ted Yu <yuzhihong@gmail.com>
Thread.sleep
inLogManager.deleteLogs
potentially blocks a scheduler thread for up tolog.segment.delete.delay.ms
with a default value of a minute. This PR skips delete when the first log is not yet ready to be deleted, freeing the scheduler thread. Logs are then deleted on the next delete iteration.Committer Checklist (excluded from commit message)