[BP-2.3][FLINK-37892][tests] Fix spurious TimeoutException in TestUtils#waitUntil for non-monotonic conditions#28401
Open
lihaosky wants to merge 1 commit into
Conversation
…ntil for non-monotonic conditions (apache#28400) TestUtils#waitUntil evaluated the condition twice: once in the polling loop and again to decide whether to throw. A condition that is momentarily true and then false again (e.g. a live thread count matched with ==) could exit the loop on the first evaluation and then fail the second one, producing a TimeoutException within milliseconds despite a 30s budget. This is the failure mode behind SplitFetcherManagerTest#testCloseBlockingWaitingForFetcherShutdown flaking on CI with sub-second 'timeouts'. Evaluate the condition once per iteration and latch the result, so a condition observed as true always completes the wait. Add a regression test with a condition that is satisfied exactly once. (cherry picked from commit 61723a0)
Collaborator
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What is the purpose of the change
Backport of #28400 to
release-2.3(clean cherry-pick of 61723a0).Fixes the failure mode behind FLINK-37892 (
SplitFetcherManagerTest#testCloseBlockingWaitingForFetcherShutdownflaking on CI).TestUtils#waitUntilevaluates the condition twice — once in the polling loop and again to decide whether to throw. A non-monotonic condition that is momentarily true and then false again can exit the loop on the first evaluation and fail the second, producing aTimeoutExceptionwithin milliseconds despite a 30s budget.SplitFetcherManagerTestpasses exactly such a condition (findThread(THREAD_NAME_PREFIX).size() == 2— a live thread count that can flicker as fetcher threads start/exit).Brief change log
TestUtils#waitUntil(Supplier, Duration, String)to evaluate the condition once per iteration and latch the result: a condition observed as true always completes the wait;TimeoutExceptionis thrown only when the condition was actually false at the deadline.TestUtilsTestwith a regression test whose condition is satisfied exactly once and false afterwards.Verifying this change
This change added tests and can be verified as follows:
TestUtilsTest#testWaitUntilSucceedsForConditionSatisfiedOnlyOncefails against the old implementation with the same spuriousTimeoutException(in ~0.04s) and passes with the fix.SplitFetcherManagerTestpasses against the fixed utility.Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation
Was generative AI tooling used to co-author this PR?
Yes