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-4051: Use nanosecond clock for timers in broker #1768

Closed
wants to merge 1 commit into from

Conversation

rajinisivaram
Copy link
Contributor

Use System.nanoseconds instead of System.currentTimeMillis in broker timer tasks to cope with changes to wall-clock time.

@rajinisivaram
Copy link
Contributor Author

This is a small change to the broker to fix the specific issue reported in the JIRA where broker restarts are necessary to handle consumer rebalance when the clock is moved backwards by a significant amount. Note that this PR does not address the dependency on wall-clock time in Java clients. I have run manual tests on Linux and Mac to ensure that the issue reported in the JIRA is fixed by this PR. Also ran benchmark tests of the system test runs to compare the results with and without the PR, and comparing the results over a couple of runs, there is no noticeable impact beyond the differences between test runs. The results with the PR are https://jenkins.confluent.io/job/system-test-kafka-branch-builder/501/ and the results of the same trunk level without the PR are https://jenkins.confluent.io/job/system-test-kafka-branch-builder/500/.

@gwenshap
Copy link
Contributor

LGTM. Thank you!

@asfgit asfgit closed this in dedacd0 Aug 22, 2016
@@ -44,6 +46,8 @@ trait Time {

def nanoseconds: Long

def hiResClockMs: Long = TimeUnit.NANOSECONDS.toMillis(nanoseconds)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have we implemented this here instead of SystemTime with a different implementation for MockTime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @gwenshap, @ijuma.
@ijuma Couldn't think of a reason for a different implementation in MockTime, but happy to move it if you think it will be useful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that for the Scala implementation, the mock time implementation should just return the same time unless sleep is called. For the Java one, we have an optional autoTick functionality, but we don't care about that here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ijuma Thank you for looking into this. Since MockTime.scala maintains only one time, shall I leave the common implementation above in Time.scala?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I understand now, my bad. You are relying on Time.nanoseconds in your implementation instead of System.nanoTime. Thanks for explaining. :)

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.

3 participants