Backport(v1.19): test_in_tail: fix flaky throttling test by widening the lower time bound (#5418)#5424
Open
github-actions[bot] wants to merge 1 commit into
Open
Backport(v1.19): test_in_tail: fix flaky throttling test by widening the lower time bound (#5418)#5424github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
…und (#5418) **Which issue(s) this PR fixes**: Fixes # **What this PR does / why we need it**: The `test "lines collected with throttling"` still fails intermittently even after #5381, especially on CI runners: ``` 4) Failure: test: lines collected with throttling(TailInputTest::throttling logs at in_tail level): elapsed_seconds 1.8289766999998847 is out of allowed range: lower: 1.88 [sec] upper: 3.3200000000000003 [sec]. ``` The throttling only guarantees that consecutive *read starts* (`start_reading_time`) are at least `rate_period` apart: ``` S_{N+1} - S_N >= rate_period # always holds ``` However, the test measures the interval between *emit* events. An emit happens after a whole batch (`limit` lines, ~8MB here) has been read, i.e. at `read_start + read_duration`: ``` emit_N ~= S_N + Tread_N measured gap = (S_{N+1} - S_N) + (Tread_{N+1} - Tread_N) ~= rate_period + (Tread_{N+1} - Tread_N) ``` So when an earlier batch is read more slowly than the next one — which is common for the first batch right after the file is opened — the measured emit interval dips below `rate_period`. The observing thread's 0.1s polling jitter adds to this. The reported failures (~0.17s below 2.0s) are fully explained by this read-time skew plus polling jitter. The previous lower bound only accounted for the polling interval (`sleep_interval * safety_ratio = 0.12`), which was too tight and asymmetric with the upper bound (which already includes the watcher tick). This PR uses a symmetric jitter that also tolerates the read/observation latency, so the allowed range becomes `[0.68, 3.32]` sec. This is a test-only measurement issue, not a product bug. The strict per-cycle line-count assertion (`assert_equal(limit, d.record_count - prev_count)`) is kept intact, so a regression that actually breaks throttling (emits back to back, gap ~0s) is still detected. **Docs Changes**: N/A **Release Note**: N/A Signed-off-by: Shizuo Fujita <fujita@clear-code.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.
Which issue(s) this PR fixes:
Fixes #
What this PR does / why we need it:
The
test "lines collected with throttling"still fails intermittently even after #5381, especially on CI runners:The throttling only guarantees that consecutive read starts (
start_reading_time) are at leastrate_periodapart:However, the test measures the interval between emit events. An emit happens after a whole batch (
limitlines, ~8MB here) has been read, i.e. atread_start + read_duration:So when an earlier batch is read more slowly than the next one — which is common for the first batch right after the file is opened — the measured emit interval dips below
rate_period. The observing thread's 0.1s polling jitter adds to this. The reported failures (~0.17s below 2.0s) are fully explained by this read-time skew plus polling jitter.The previous lower bound only accounted for the polling interval (
sleep_interval * safety_ratio = 0.12), which was too tight and asymmetric with the upper bound (which already includes the watcher tick). This PR uses a symmetric jitter that also tolerates the read/observation latency, so the allowed range becomes[0.68, 3.32]sec.This is a test-only measurement issue, not a product bug. The strict per-cycle line-count assertion (
assert_equal(limit, d.record_count - prev_count)) is kept intact, so a regression that actually breaks throttling (emits back to back, gap ~0s) is still detected.Docs Changes:
N/A
Release Note:
N/A