-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-2669; Fix LogCleanerIntegrationTest #327
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
39c356a
KAFKA-2669; Fix LogCleanerIntegrationTest
2616cad
improve awaitCleaned as reviewers suggested
6cbb4a5
add timeout for awaitCleaned
74cd5e7
replace return with nested function
0f4d1cf
minor change
lindong28 69ffb13
address comments
lindong28 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 you check if this is only used in a test? Ideally, we should use the timeout to prevent indefinite blocking
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.
Yeah, we don't want the test to hang forever instead of failing with a time out.
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.
Sure. I have verified that this is only used in test.
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.
Also note that the "timeout" is not specified in API, not used in any invocation, or implemented in the function. If I were to implement this, I need to find a good default value that doesn't break existing test. Since it is only used in the test, I prefer to leave it as it is and only implement it when we have a good usecase.
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.
@lindong28 The bug here is that the timeout was not implemented in the function. Because there is a default value (30000L), callers are expecting that timeout so I don't agree with your assessment that it is not used in invocations. This pattern is really common in our tests (see TestUtils.waitUntil* methods) and callers usually don't override the default timeout. Given that, I think we already have a use-case, it is why the parameter exists in the first place.
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.
@ijuma Yeah I know we have default value of 30000L for timeout. My point is that, since it is not explicitly specified in the invocation it probably means users don't care about it. It is important that, if we enable this timeout, existing tests won't fail due to low timeout value.
I am not sure.. but can you explain why 30000 ms is a good default value for timeout? Note that log cleaner's default backoffMs is 15000 ms.
Alternatively, how about I set timeout to be LONG.MAX by default? This won't accidentally fail existing test while still allow developers to use timeout when they want.
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 disagree with the assertion that because the callers didn't explicitly set the timeout, they don't care about a timeout. We have several examples of callers of
TestUtils.waitUntilTruethat care about a timeout, but don't set it explicitly because the default is OK (that's a big reason why default arguments are useful).I don't know what is a good default for this method, but I certainly know that we can't wait indefinitely for things in tests. It means that a bug can cause the whole test suite to hang, which is a very bad outcome (even worse than accidentally failing tests, which is also bad).
Ideally we'd set a timeout that would not cause tests to fail, but that wouldn't delay the test suite by too long if it were to fail. It's OK to err on the side of caution, but Long.MaxValue is far too long. Why not choose a value that you think is appropriate and then run the test suite a few times in a loop to see if it's OK?
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 have already run
LogCleanerIntegrationTestandDeleteTopicTesta few times with infinite timeout and the tests run well. That is the reason why I think inifinite timeout works for existing tests. I don't think setting a default timeout value that is large enough for existing invocation in tests is a very good idea -- a default time value should ideally be good for most usecase from first principle.But I agree with your point that we should never allow tests to run forever. How about I make the following change:
give default timeout value of 60*1000 ms. This is 4X the default
backoffMswhich is long enough for existing tests.let
awaitCleanedreturn a boolean value to indicate whether it has timed out or not -- this allows the tests to fail in case of timeout so that we can look into the problem.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.
Chiming late here: I also feel setting an infinite timeout value is generally not a good idea since IF there are any issue causing the test to block, it is hard to detect this issue: for example today we also encounter blocking-forever test cases in Jenkins from time to time, and because we set the Jenkins time to 1 hour (? not sure if the value is exact), we ended up seeing an "timed out" failed Jenkins without much information which test case caused it.
I think the current approach of setting a large enough default value is a better option.
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.
Thanks for the comment. I definitely agree that we should prevent test from running forever.