-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
filter_rewrite_tag: fix in_emitter data loss when using ring buffers. #10097
base: master
Are you sure you want to change the base?
Conversation
…eek. Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
…add missing skip_count argument. Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
…mbers and skip the size check. Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
e1d6562
to
01deb22
Compare
@@ -39,6 +39,7 @@ static int emitter_create(struct flb_rewrite_tag *ctx) | |||
{ | |||
int ret; | |||
struct flb_input_instance *ins; | |||
char ring_buffer_size[42]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is that magic number coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a "large enough" buffer size that can accommodate the representation of a 109 bit unsigned number and the null terminator.
It was just a ballpark and not critical, in reality we needed it to be 25 (24 + 1) bytes long to ensure that 64 bit numbers fit.
Summary
This PR seeks to avoid data loss when using the optional ring_buffer on emitters when using
filter_rewrite_tag
. To do so two new functions were added for the ring buffer API: peek and seek.Description
During my work on #9919 I noticed that
in_emitter
had code to enable a ring buffer:fluent-bit/plugins/in_emitter/emitter.c
Line 221 in cfc9ba9
This PR seeks to solve it by:
emitter_ring_buffer_size
tofilter_rewrite_tag
to enable and set the size of the ring buffer for it'sin_emitter
.flb_ring_buffer_peek
andflb_ring_buffer_seek
to theflb_ring_buffer
API so buffers can be read then absorbed only once they have been successfully submitted.I changed the use of
flb_ring_buffer_read
toflb_ring_buffer_peek
andflb_ring_buffer_seek
so that when the buffer is ingested it first callspeek
to read the buffer then submit it and only seeks the buffer only if the buffer has been successfully ingested byflb_input_log_append
, ie: it returns a non-error value.The work adding the
flb_ring_buffer
APIs could and should be applied to the main ring buffer as well. If this is required now I can split out that part of the work into a separate PR and leave just the fixes for the emitter andfilter_rewrite_tag
here.Enter
[N/A]
in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-test
label to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.