test_in_tail: fix flaky throttling test by widening the lower time bound#5418
Merged
Merged
Conversation
The `test "lines collected with throttling"` still failed intermittently even after fluent#5381, e.g. 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* are at least `rate_period` apart. However, the test measures the interval between *emit* events, and an emit happens after a whole batch (`limit` lines, ~8MB here) has been read, i.e. at `read_start + read_duration`. Since the read duration varies per batch (especially the first batch right after the file is opened), the measured emit interval can dip below `rate_period` when an earlier batch is read more slowly than the next one, plus the observing thread's polling jitter. The previous lower bound only accounted for the polling interval (`sleep_interval * safety_ratio`), which was too tight and asymmetric with the upper bound. Use a symmetric jitter that also tolerates the read/observation latency. The strict per-cycle line-count assertion (`assert_equal(limit, d.record_count - prev_count)`) is kept intact, so a regression that breaks throttling is still detected. Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
kenhys
approved these changes
Jul 9, 2026
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