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

input_chunk: update records in the right place #8223

Merged
merged 4 commits into from
Nov 28, 2023

Conversation

braydonk
Copy link
Contributor

@braydonk braydonk commented Nov 27, 2023

In commit ac4ec1f, the input chunk writing was moved down from the previous spot to be below where input metrics are updated. This PR moves the metric update below the input chunk write so that the ret == CIO_OK check is actually right, and so that the metrics are only updated after the write has occurred.

I also moved adding to total_records outside of the metric ifdef. This appears to have been here for some time, but there are numerous output plugins that rely on event_chunk->total_events, which is set from this total_records value. This will mean it always gets updated, even if metrics are disabled.


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:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

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.

In commit ac4ec1f, the input chunk writing was moved down from the
previous spot to be below where input metrics are update. This PR moves
the metric update below the input chunk write so that the `ret ==
CIO_OK` check is actually right, and so that the metrics are only
updated after the write has occurred.

I also moved adding to `total_records` outside of the metric ifdef. This
appears to have been here for some time, but there are numerous output
plugins that rely on `event_chunk->total_events`, which is set from this
total_records value. This will mean it always gets updated, even if
metrics are disabled.

Signed-off-by: braydonk <braydonk@google.com>
@braydonk
Copy link
Contributor Author

@leonardo-albertovich please review if you can to make sure this fix makes sense with your original commit.

@@ -1499,31 +1499,6 @@ static int input_chunk_append_raw(struct flb_input_instance *in,
flb_chunk_trace_do_input(ic);
#endif /* FLB_HAVE_CHUNK_TRACE */

/* Update 'input' metrics */
#ifdef FLB_HAVE_METRICS
if (ret == CIO_OK) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When in this spot, this check would fail because the last time ret is set is by a function that returns CIO_TRUE. CIO_TRUE is a !0 macro. CIO_OK is 0, meaning this check would always fail when flb_chunk_is_up or cio_chunk_up_force succeeded.

`total_events` is expected to be set even in scenarios where
`FLB_HAVE_METRICS` is not defined. Remove the guard around actually
setting that value from the input chunk.

Signed-off-by: braydonk <braydonk@google.com>
Adds a test that checks whether the input chunk that was created during
the test has a `total_records` value set.

Signed-off-by: braydonk <braydonk@google.com>
@braydonk
Copy link
Contributor Author

The macos jemalloc tests seem to be the same flakes that are always happening and are unrelated to the PR.

Similarly to other spots, total_records is expected to be set in a few
plugins outside of FLB_HAVE_METRICS definitions. This makes it so when
this value is set on filter, it happens outside of the definition so
that filters that change the size of total_records will still have the
values reflected.

Signed-off-by: braydonk <braydonk@google.com>
@edsiper edsiper merged commit 4820a1f into fluent:master Nov 28, 2023
43 of 44 checks passed
@edsiper
Copy link
Member

edsiper commented Nov 28, 2023

thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants