Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output: allow records size 0 on flb event type logs processor #9554

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions include/fluent-bit/flb_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,14 @@ static FLB_INLINE void output_pre_cb_flush(void)

co_switch(coro->caller);

/* Skip flush if type is FLB_EVENT_TYPE_LOGS and event chunk has zero records */
if (persisted_params.event_chunk &&
persisted_params.event_chunk->type == FLB_EVENT_TYPE_LOGS &&
persisted_params.event_chunk->total_events == 0) {
flb_debug("[output] skipping flush for event chunk with zero records.");
FLB_OUTPUT_RETURN(FLB_OK);
}

/* Continue, we will resume later */
out_p = persisted_params.out_plugin;

Expand Down Expand Up @@ -676,20 +684,13 @@ struct flb_output_flush *flb_output_flush_create(struct flb_task *task,
evc->tag, flb_sds_len(evc->tag),
evc->data, evc->size,
&p_buf, &p_size);
if (ret == -1 || p_size == 0) {
if (ret == -1) {
flb_coro_destroy(coro);
flb_free(out_flush);
return NULL;
}

records = flb_mp_count(p_buf, p_size);
if (records == 0) {
flb_coro_destroy(coro);
flb_free(out_flush);
flb_free(p_buf);
return NULL;
}

tmp = flb_event_chunk_create(evc->type, records, evc->tag, flb_sds_len(evc->tag), p_buf, p_size);
if (!tmp) {
flb_coro_destroy(coro);
Expand Down
Loading