From 1c1f93429d8604c66b0cb57c925e9c61455b0b7c Mon Sep 17 00:00:00 2001 From: Braydon Kains <93549768+braydonk@users.noreply.github.com> Date: Mon, 18 Dec 2023 12:43:29 -0500 Subject: [PATCH] input_chunk: skip overlimit check in mem mode (#8199) *input_chunk: storage type when overlimit When an output plugin is configured to use `storage.total_limit_size` while the input plugin uses memory storage mode, it would previously continue calculating and eventually pass an empty pointer to the storage context in the function that releases space. This PR adds a validationg in the overlimit route check that will cause the check to be skipped, ensuring that the rest of the space freeing routines are never executed. Signed-off-by: Braydon Kains * input_chunk: skip overlimit check in mem mode This commit uses a different implementation than the previous; instead of checking in each output plugin and logging, this will just skip the check entirely when not in FS mode. The downside is that there is no log indicating that the memory plugin is going to an output with `storage.total_limit_size` where it has no effect, but this is a reasonable expectation to configure for so that would just be adding extra work just to be able to do some debug logging. Signed-off-by: Braydon Kains --------- Signed-off-by: Braydon Kains --- src/flb_input_chunk.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/flb_input_chunk.c b/src/flb_input_chunk.c index 079bfb26d90..754e0e65993 100644 --- a/src/flb_input_chunk.c +++ b/src/flb_input_chunk.c @@ -508,11 +508,14 @@ int flb_input_chunk_has_overlimit_routes(struct flb_input_chunk *ic, int flb_input_chunk_place_new_chunk(struct flb_input_chunk *ic, size_t chunk_size) { int overlimit; - overlimit = flb_input_chunk_has_overlimit_routes(ic, chunk_size); - if (overlimit != 0) { - flb_input_chunk_find_space_new_data(ic, chunk_size, overlimit); - } + struct flb_input_instance *i_ins = ic->in; + if (i_ins->storage_type == CIO_STORE_FS) { + overlimit = flb_input_chunk_has_overlimit_routes(ic, chunk_size); + if (overlimit != 0) { + flb_input_chunk_find_space_new_data(ic, chunk_size, overlimit); + } + } return !flb_routes_mask_is_empty(ic->routes_mask); }