Repository navigation
fix(file source): preserve findable state on transient fingerprinting errors - #27315
lukesteensen wants to merge 2 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da70328a03
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Inject transient EACCES across multiple glob cycles. | ||
| std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o000)).unwrap(); | ||
| tokio::time::sleep(Duration::from_millis(100)).await; |
There was a problem hiding this comment.
Verify that the test actually injects a fingerprinting error
When this test runs as root with permission-bypass capabilities, changing the file mode to 000 does not prevent Fingerprinter::fingerprint from reopening it. The emitter discards all errors, so nothing verifies that a fingerprinting failure occurred; the test then passes even with the original buggy discovery logic. Inject a deterministic fingerprinting failure, or verify that opening the file returns PermissionDenied and explicitly skip unsupported execution contexts, so a successful regression test demonstrates that the new branch was exercised.
Useful? React with 👍 / 👎.
| for watcher in fp_map.values_mut() { | ||
| if watcher.path == path { | ||
| watcher.set_file_findable(true); | ||
| } |
There was a problem hiding this comment.
Separate error preservation from successful fingerprint discovery
During rename-and-create rotation, if the replacement app.log is temporarily unreadable and is discovered before the readable app.log.1, this marks the old file's watcher as already found before its actual fingerprint is encountered at app.log.1. The subsequent was_found_this_cycle check therefore takes the duplicate-fingerprint branch instead of the rename branch. If the replacement has an equal or newer modification time, that branch never updates the watcher's path, so remaining records from the rotated file are emitted with the replacement's filename for the duration of the error. Preserve the watcher on transient errors without treating that preservation as a successful fingerprint match for rename detection.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Two distinct issues are flagged: a logic flaw at line 213 where marking a watcher as found during transient preservation can suppress correct rename detection (causing rotated lines to carry the wrong filename and risking premature deletion), and a test-reliability gap at line 736 where the regression test may silently pass on privileged runners because chmod(000) does not block fingerprinting and no assertion verifies that the permission-denied path was actually exercised.
🤖 Bits Code Review · Commit da70328
| // or reap the watcher as if the file were deleted. | ||
| for watcher in fp_map.values_mut() { | ||
| if watcher.path == path { | ||
| watcher.set_file_findable(true); |
There was a problem hiding this comment.
Separate transient preservation from confirmed fingerprint sightings
If app.log rotates to app.log.1 and its replacement encounters a transient fingerprinting error first, this marks the old watcher findable before discovering its actual rotated path. The successful fingerprint of app.log.1 then enters duplicate-fingerprint handling instead of rename handling. When the replacement has a newer modification time, update_path is skipped, so unread lines from the rotated file receive filename app.log. Record transient paths separately and apply preservation after processing successful fingerprints so preservation cannot suppress confirmed rename detection.
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
What each reaction means
- 👍 Useful: correct, and you're fixing it or will.
- 👎 Wrong: the finding is incorrect, for example the bug can't happen or the code was misread.
- 😕 Unclear: you can't tell what it means or why it matters.
- 👀 Right, not acting: correct, but intended, out of scope for this PR, a known risk, or too minor.
🤖 Bits Code Review · Open Bits AI session
| tokio::time::sleep(Duration::from_millis(60)).await; | ||
|
|
||
| // Inject transient EACCES across multiple glob cycles. | ||
| std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o000)).unwrap(); |
There was a problem hiding this comment.
Verify that the regression test triggers a fingerprint error
When run as root with permission-bypass capabilities, chmod(000) leaves fingerprinting able to open the file. A focused filesystem reproduction confirmed that open succeeds under those conditions. Since NoopEmitter discards errors and the test never asserts a fingerprint failure occurred, the regression test can pass with the original buggy behavior. Use deterministic fault injection or unprivileged execution, and verify that the fingerprint-error path was exercised.
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
What each reaction means
- 👍 Useful: correct, and you're fixing it or will.
- 👎 Wrong: the finding is incorrect, for example the bug can't happen or the code was misread.
- 😕 Unclear: you can't tell what it means or why it matters.
- 👀 Right, not acting: correct, but intended, out of scope for this PR, a known risk, or too minor.
🤖 Bits Code Review · Open Bits AI session
Summary
Fixes a bug where a transient I/O error during file discovery fingerprinting (such as
EACCESorEIO) is treated identically to file deletion (!file_findable()).Previously,
FileServer::runclearedfindable = falseon all watched files before globbing, andFingerprinter::fingerprint_or_emitreturnedNoneon any error. When a live watched file encountered a transientPermissionDeniedorEIOerror,findableremainedfalse, causingFileWatcher::read_lineon EOF to immediately flush any buffered partial line without a newline and mark the watcher dead (tearing the line in half and/or causing duplicate re-reads once the error cleared).This PR adds
FingerprintOutcome(Found,Skipped,TransientError) andFingerprinter::fingerprint_or_emit_outcome, and keeps existing watchers atpathmarked findable onTransientError.Vector configuration
N/A
How did you test this PR?
file_server::tests::transient_eacces_does_not_tear_partial_line(buffers a partial line, applies transientchmod 000across glob cycles, restoreschmod 644, appends the remainder +\n, and asserts the full line is emitted intact without tearing).cargo clippy -p file-source-common -p file-source --all-targets -- -D warningscargo test -p file-source --lib transient_eacces_does_not_tear_partial_lineDoes this PR include user facing changes?
no-changeloglabel to this PR.