tests(tail): fix race in untailable-symlink test - #13704
Open
eduardomourar wants to merge 1 commit into
Open
Conversation
The test replaced the watched file with a symlink via remove() followed by symlink_file(), letting the poller observe a transient "file missing" state and report "has become inaccessible" instead of "replaced with an untailable symbolic link". It also asserted the process was alive 500ms after spawn without confirming tail's initial read had completed, so under scheduler contention the swap could land before tail's first (legitimately symlink-following) open of the file, leaking the secret before the follow-loop's guard was active. Wait for the initial content to appear in stdout before swapping, and perform the swap as an atomic rename over a freshly created symlink so the intermediate missing-file state is never observable.
Merging this PR will improve performance by 3.03%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | cksum_crc32b |
40.9 ms | 39.7 ms | +3.03% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing eduardomourar:fix/tail-symlink-race-test (0079d4c) with main (0c8a3c7)
Footnotes
-
46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
GNU testsuite comparison: |
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.
Fixes intermittent CI failures in test_tail::test_follow_name_replaced_by_symlink_is_untailable, e.g. this run (https://github.com/uutils/coreutils/actions/runs/30700365364/job/91373194296?pr=13688), which failed with:
Root cause
The test swapped the watched file for a symlink via remove() followed by symlink_file() — two separate syscalls.
Under polling (--use-polling, 0.1s interval), the poller could observe the transient "file missing" state in between,
reporting "has become inaccessible" instead of the intended "untailable symlink" message. The test also only checked the process was alive 500ms after spawn, without confirming tail's initial read had completed — under scheduler contention the symlink swap could happen before tail's first read of the file, which legitimately follows symlinks (no different from any other file open) since the untailable-symlink guard only applies to the follow loop, not the initial read.
Fix