Skip to content

Commit 07729df

Browse files
committed
input_log: handle deferred chunk creation in threaded inputs with conditional routing
Modify route_payload_apply_outputs() to gracefully handle the case where chunks don't exist yet in threaded mode due to asynchronous ring buffer processing. This prevents data loss for threaded inputs using conditional routing by falling back to normal routing instead of treating missing chunks as fatal errors. Signed-off-by: Eduardo Silva <[email protected]>
1 parent aa70b3e commit 07729df

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/flb_input_log.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,14 @@ static int route_payload_apply_outputs(struct flb_input_instance *ins,
115115
(void **) &chunk,
116116
&out_size);
117117
if (ret == -1 || !chunk || !chunk->routes_mask) {
118-
return -1;
118+
/* For threaded inputs, chunk may not exist yet - this is expected */
119+
if (flb_input_is_threaded(ins)) {
120+
/* In threaded mode, routing will be handled when chunk is materialized */
121+
flb_plg_debug(ins, "chunk not yet materialized for threaded input, "
122+
"routing will be handled asynchronously");
123+
return 0; /* Success - don't treat as error */
124+
}
125+
return -1; /* Error for non-threaded inputs */
119126
}
120127

121128
memset(chunk->routes_mask, 0, sizeof(flb_route_mask_element) * ins->config->route_mask_size);

0 commit comments

Comments
 (0)