Skip to content
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

Merged
merged 2 commits into from
Mar 24, 2018

Conversation

rajinisivaram
Copy link
Contributor

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. 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)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

Copy link
Contributor

@junrao junrao left a 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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@lindong28
Copy link
Member

@rajinisivaram Thanks for catching this. The change makes sense.

@rajinisivaram
Copy link
Contributor Author

@lindong28 Thanks for the review.

@rajinisivaram
Copy link
Contributor Author

@junrao @lindong28 @tedyu Thank you for the review. Merging to trunk and 1.1.

@rajinisivaram rajinisivaram merged commit f66aebf into apache:trunk Mar 24, 2018
rajinisivaram added a commit that referenced this pull request Mar 24, 2018
`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>
hejiefang pushed a commit to hejiefang/kafka that referenced this pull request Mar 26, 2018
`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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants