Skip to content

Commit

Permalink
flb_input_chunk: storage type when overlimit
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
braydonk committed Nov 17, 2023
1 parent 281aea0 commit fe062da
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/flb_input_chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ int flb_input_chunk_has_overlimit_routes(struct flb_input_chunk *ic,
int overlimit = 0;
struct mk_list *head;
struct flb_output_instance *o_ins;
struct flb_input_instance *i_ins = ic->in;


mk_list_foreach(head, &ic->in->config->outputs) {
o_ins = mk_list_entry(head, struct flb_output_instance, _head);
Expand All @@ -484,6 +486,12 @@ int flb_input_chunk_has_overlimit_routes(struct flb_input_chunk *ic,
continue;
}

if (i_ins->storage_type == CIO_STORE_MEM) {
flb_plg_debug(i_ins, "plugin is in memory storage mode, storage.total_limit_size "
"from output %s has no effect", o_ins->name);
continue;
}

FS_CHUNK_SIZE_DEBUG(o_ins);
flb_debug("[input chunk] chunk %s required %ld bytes and %ld bytes left "
"in plugin %s", flb_input_chunk_get_name(ic), chunk_size,
Expand All @@ -508,6 +516,7 @@ 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);
Expand Down

0 comments on commit fe062da

Please sign in to comment.