Skip to content

Commit 0b0464a

Browse files
Leonardo Alminanaedsiper
authored andcommitted
storage_backlog: changed the release strategy
The output queue release strategy was changed from a transaction based approach to a non transaction based approach in order to allow rollover to work properly. Additionally, the default behavior when chunks are mapped was changed to set them down in order to honor max_chunks_up. Signed-off-by: Leonardo Alminana <[email protected]>
1 parent 09120dd commit 0b0464a

File tree

1 file changed

+9
-8
lines changed
  • plugins/in_storage_backlog

1 file changed

+9
-8
lines changed

plugins/in_storage_backlog/sb.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static int sb_append_chunk_to_segregated_backlogs(struct cio_chunk *target_chun
9191
int sb_segregate_chunks(struct flb_config *config);
9292

9393
int sb_release_output_queue_space(struct flb_output_instance *output_plugin,
94-
size_t required_space);
94+
ssize_t *required_space);
9595

9696
ssize_t sb_get_releasable_output_queue_space(struct flb_output_instance *output_plugin,
9797
size_t required_space);
@@ -441,9 +441,10 @@ ssize_t sb_get_releasable_output_queue_space(struct flb_output_instance *output_
441441
}
442442

443443
int sb_release_output_queue_space(struct flb_output_instance *output_plugin,
444-
size_t required_space)
444+
ssize_t *required_space)
445445
{
446446
struct mk_list *chunk_iterator_tmp;
447+
struct cio_chunk *underlying_chunk;
447448
struct mk_list *chunk_iterator;
448449
size_t released_space;
449450
struct flb_sb *context;
@@ -469,18 +470,17 @@ int sb_release_output_queue_space(struct flb_output_instance *output_plugin,
469470
chunk = mk_list_entry(chunk_iterator, struct sb_out_chunk, _head);
470471

471472
released_space += chunk->size;
473+
underlying_chunk = chunk->chunk;
472474

473-
cio_chunk_close(chunk->chunk, FLB_TRUE);
474-
sb_remove_chunk_from_segregated_backlogs(chunk->chunk, context);
475+
sb_remove_chunk_from_segregated_backlogs(underlying_chunk, context);
476+
cio_chunk_close(underlying_chunk, FLB_TRUE);
475477

476-
if (released_space >= required_space) {
478+
if (released_space >= *required_space) {
477479
break;
478480
}
479481
}
480482

481-
if (released_space < required_space) {
482-
return -3;
483-
}
483+
*required_space -= released_space;
484484

485485
return 0;
486486
}
@@ -618,6 +618,7 @@ static int cb_queue_chunks(struct flb_input_instance *in,
618618
* queue but we need to leave it in the remainder queues.
619619
*/
620620
sb_remove_chunk_from_segregated_backlogs(chunk_instance->chunk, ctx);
621+
cio_chunk_down(ch);
621622

622623
/* check our limits */
623624
total += size;

0 commit comments

Comments
 (0)