-
Notifications
You must be signed in to change notification settings - Fork 1.9k
in_tail: reconcile files after missed inotify events #11750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sandy2008
wants to merge
2
commits into
fluent:master
Choose a base branch
from
sandy2008:codex/in-tail-inotify-reconcile
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Propagate offset-state persistence failures instead of swallowing them.
update_resumable_offset_state()ignores failures from DB/marker persistence. That makes truncate recovery and post-read progress updates report success even when resumable state update failed.Proposed fix
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for flagging this — talked it through with my reviewer agents and we landed on pushing back on the propagate-up suggestion. Tracing the call sites:
update_resumable_offset_stateruns afterconsume_bytes()has already shifted data out offile->buf_dataand after records have been emitted to the engine. By the time we hit the persist call, the data is gone from the in-process buffer.If the helper returns
-1and we propagate that up toflb_tail_file_chunk→FLB_TAIL_ERROR,tail.cmaps that toflb_tail_file_remove(file)(tail.c:117-119). On the next scan the file gets re-discovered and re-tailed from the last persisted offset — so a transient sqlite-lock blip would replay every record we just emitted. That's a worse outcome than the current "log and continue, accept that we may replay this batch on a hard restart" behavior.The swallow pattern is also pre-existing — master swallows
flb_tail_db_file_offsetreturns attail_file.c:1204,:1227,tail_fs_stat.c:144, plus the two sites this PR refactored into the helper. This PR didn't introduce the silent-failure shape, just consolidated two of the call sites.That said, your underlying concern about visibility is fair —
flb_tail_db_file_offsetalready logs lock failures, but the sqlite_step path andflb_tail_file_update_offset_markerdon't. Happy to do a targeted follow-up PR that adds debug-level logging insideupdate_resumable_offset_state(and/or inside thecompute_offset_markerfailure path) without changing return semantics, if that addresses the operability gap. Wanted to keep this PR scoped to the inotify reconcile work it started as.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sandy2008, that's a well-reasoned pushback and I'm convinced. The key point I missed is that the persist call happens after the buffer has been drained and records emitted — so converting a persist failure intoFLB_TAIL_ERROR→flb_tail_file_removecreates a guaranteed duplication path (re-tail from last persisted offset) for what is likely a transient SQLite contention blip. "Accept potential replay only on a hard restart" is clearly the lesser evil compared to "guarantee replay on every transient lock failure." The pre-existing pattern on master further confirms this is a deliberate choice, not an oversight.The follow-up PR adding
flb_plg_debug/flb_plg_warninsideupdate_resumable_offset_stateand thecompute_offset_markerfailure path would address the operability gap without touching return semantics — that sounds like the right scope. Happy to review it when it lands.Withdrawing the original suggestion.
✏️ Learnings added
🧠 Learnings used