Skip to content

in_tail: fix typo of @follow_inodes in detach_watcher - #5514

Merged
Watson1978 merged 1 commit into
masterfrom
in_tail-fix-follow-inodes-typo
Oct 2, 2026
Merged

Watson1978 merged 1 commit into
masterfrom
in_tail-fix-follow-inodes-typo

Conversation

@ashie

@ashie ashie commented Oct 2, 2026

Copy link
Copy Markdown
Member

Which issue(s) this PR fixes:
Fixes #

What this PR does / why we need it:
TailInput#detach_watcher checked @follow_inode, which is not defined anywhere, instead of @follow_inodes. The typo was introduced in 52e46f0 ("in_tail: Fix a stall bug on !follow_inode case", #4327).

With follow_inodes true, position entries are keyed by inode, and the inode of a rotated file is dropped from @tails when its TailWatcher is detached by update_watcher. So detach_watcher must unwatch the position entry of that inode even if the same path is still followed by a new watcher. With the typo, the condition was always
nil || !@tails[tw.path], so the entry was left in the position file.

Note that tw.unwatched is currently set to true only when follow_inodes is false (since 51848da), so this doesn't change the behavior of the existing code paths. It makes the condition work as intended so that the position entry handling stays correct when the unwatched flag is used with follow_inodes too.

Add tests for detach_watcher:

  • with follow_inodes true, the position entry of the rotated inode is unwatched even while the path is still followed by another watcher.
  • with follow_inodes false, the position entry of the path is kept while the path is still followed by a watcher.

Docs Changes:
None

Release Note:
None

Assisted-by: LLM Qwen3.8-Flash-Next

**Which issue(s) this PR fixes**:
Fixes #

**What this PR does / why we need it**:
TailInput#detach_watcher checked `@follow_inode`, which is not defined
anywhere, instead of `@follow_inodes`. The typo was introduced in 52e46f0
("in_tail: Fix a stall bug on !follow_inode case", #4327).

With `follow_inodes true`, position entries are keyed by inode, and the
inode of a rotated file is dropped from `@tails` when its TailWatcher is
detached by `update_watcher`. So `detach_watcher` must unwatch the position
entry of that inode even if the same path is still followed by a new
watcher. With the typo, the condition was always
`nil || !@Tails[tw.path]`, so the entry was left in the position file.

Note that `tw.unwatched` is currently set to true only when `follow_inodes`
is false (since 51848da), so this doesn't change the behavior of the
existing code paths. It makes the condition work as intended so that the
position entry handling stays correct when the `unwatched` flag is used
with `follow_inodes` too.

Add tests for `detach_watcher`:
- with `follow_inodes true`, the position entry of the rotated inode is
  unwatched even while the path is still followed by another watcher.
- with `follow_inodes false`, the position entry of the path is kept while
  the path is still followed by a watcher.

**Docs Changes**:
None

**Release Note**:
None

Assisted-by: LLM Qwen3.8-Flash-Next
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
@ashie
ashie requested a review from Watson1978 October 2, 2026 02:12
@Watson1978 Watson1978 added this to the v1.20.0 milestone Oct 2, 2026
@Watson1978 Watson1978 added the backport to v1.19 We will backport this fix to the LTS branch label Oct 2, 2026
@ashie

ashie commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

I don't think it's needed to port to v1.19 since it's a dead condition in the current code.

@ashie ashie removed the backport to v1.19 We will backport this fix to the LTS branch label Oct 2, 2026

@Watson1978 Watson1978 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@Watson1978
Watson1978 merged commit 7580e2b into master Oct 2, 2026
24 checks passed
@Watson1978
Watson1978 deleted the in_tail-fix-follow-inodes-typo branch October 2, 2026 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants