Skip to content

Commit 3b06524

Browse files
zshuang0316claude
andcommitted
in_tail: fix ignore_active_older_files to re-check mtime on aged-out files
When a file's mtime exceeded ignore_older while being actively monitored, its inode was registered as aged-out and the file was removed from monitoring. If new content was later appended (updating mtime), the scan still excluded the file because the inode comparison matched without re-checking the mtime. Re-evaluate mtime in the aged-out inode branch; only skip if the file is still too old, otherwise unregister the aged-out entry and allow re-pickup. Applied to both tail_scan_glob.c (Linux/macOS) and tail_scan_win32.c (Windows). Also preserve file->offset in ignored_file_sizes when aging out a file, so that on re-pickup the scan resumes from the last-read position rather than re-reading from the beginning or silently skipping new content by seeking to EOF. Signed-off-by: zshuang0316 <zshuang0316@163.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 909efc4 commit 3b06524

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

plugins/in_tail/tail_file.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,6 +2438,11 @@ static int check_purge_deleted_file(struct flb_tail_config *ctx,
24382438
file->name,
24392439
strlen(file->name),
24402440
file->inode);
2441+
/* Preserve read offset for re-pickup if mtime is later refreshed. */
2442+
flb_tail_scan_register_ignored_file_size(ctx,
2443+
file->name,
2444+
strlen(file->name),
2445+
file->offset);
24412446
flb_tail_file_remove(file);
24422447
return FLB_TRUE;
24432448
}

plugins/in_tail/tail_scan_glob.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,13 @@ static int tail_scan_path(const char *path, struct flb_tail_config *ctx)
250250
strlen(globbuf.gl_pathv[i]),
251251
&aged_out_inode) == 0) {
252252
if (aged_out_inode == (uint64_t) st.st_ino) {
253-
flb_plg_debug(ctx->ins,
254-
"excluded=%s (ignore_active_older_files)",
255-
globbuf.gl_pathv[i]);
256-
continue;
253+
mtime = flb_tail_stat_mtime(&st);
254+
if (mtime > 0 && (now - ctx->ignore_older) > mtime) {
255+
flb_plg_debug(ctx->ins,
256+
"excluded=%s (ignore_active_older_files)",
257+
globbuf.gl_pathv[i]);
258+
continue;
259+
}
257260
}
258261

259262
flb_tail_scan_unregister_aged_out_inode(

plugins/in_tail/tail_scan_win32.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,12 @@ static int tail_register_file(const char *target, struct flb_tail_config *ctx,
109109
strlen(path),
110110
&aged_out_inode) == 0) {
111111
if (aged_out_inode == (uint64_t) st.st_ino) {
112-
flb_plg_debug(ctx->ins, "excluded=%s (ignore_active_older_files)",
113-
path);
114-
return -1;
112+
mtime = flb_tail_stat_mtime(&st);
113+
if (mtime > 0 && (ts - ctx->ignore_older) > mtime) {
114+
flb_plg_debug(ctx->ins, "excluded=%s (ignore_active_older_files)",
115+
path);
116+
return -1;
117+
}
115118
}
116119

117120
flb_tail_scan_unregister_aged_out_inode(ctx, path, strlen(path));

0 commit comments

Comments
 (0)