Skip to content

Commit f27bd7b

Browse files
Optimization for when ctx->keep_file_handle=false
1 parent 59a6cec commit f27bd7b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

plugins/in_tail/tail_fs_stat.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,20 @@ static int tail_fs_check(struct flb_input_instance *ins,
161161
file->pending_bytes = 0;
162162
}
163163

164+
/*
165+
* Skip rotation detection when keep_file_handle is false.
166+
* Rotation detection requires persistent open handles to work reliably.
167+
* Without keeping handles open, calling flb_tail_file_name() would
168+
* unnecessarily open and close handles multiple times per check cycle.
169+
* Because we are not keeping a handle, a rotation would be interpreted
170+
* as a truncation and handled by the truncation management logic.
171+
*/
172+
if (ctx->keep_file_handle == FLB_FALSE) {
173+
flb_plg_debug(ctx->ins, "tail_fs_check: skipping rotation detection for %s (keep_file_handle is false)",
174+
file->name);
175+
continue;
176+
}
177+
164178
/* Discover the current file name for the open file descriptor */
165179
name = flb_tail_file_name(file);
166180
if (!name) {

0 commit comments

Comments
 (0)