Skip to content

input_chunk: fix storage limit eviction with 32 or more outputs - #12235

Open
terrorobe wants to merge 3 commits into
fluent:masterfrom
terrorobe:terrorobe/fix-many-output-storage-limit
Open

input_chunk: fix storage limit eviction with 32 or more outputs#12235
terrorobe wants to merge 3 commits into
fluent:masterfrom
terrorobe:terrorobe/fix-many-output-storage-limit

Conversation

@terrorobe

@terrorobe terrorobe commented Aug 5, 2026

Copy link
Copy Markdown

In configurations with many outputs, storage.total_limit_size eviction can drop records queued for the wrong destination. In the reproduced case, output ID 32 reached its limit, but Fluent Bit also cleared the route for output ID 0. It then deleted the oldest chunk even though that chunk was still queued for output 0.

The storage-limit path represented over-limit outputs in a signed 32-bit integer, even though chunk routing masks support more than 32 outputs. Shifting 1 by output ID 32 is undefined; on the tested platform, it reused the bit for output ID 0.

This change checks each routed output directly against its configured limit. It keeps the existing two linear output scans and adds neither allocations nor list traversals. The regression test creates 33 outputs and verifies that eviction for ID 32 preserves the route for ID 0.

Before the fix:

build-many-output/bin/flb-it-input_chunk \
  input_chunk_limit_with_many_outputs
[input chunk] drop chunk ... with no output route from input plugin dummy.0
Check mk_list_size(&i_ins->chunks) == 2... failed

After the fix:

Test input_chunk_limit_with_many_outputs... [ OK ]
SUCCESS: All unit tests have passed.

The affected code is present in v5.0.9, so this should be backported to the 5.0 branch.

Summary by CodeRabbit

  • Bug Fixes

    • Improved filesystem storage limit handling when data is routed to multiple outputs.
    • Ensured space reclamation correctly identifies every output exceeding its configured limit.
  • Tests

    • Added coverage for storage limits and routing scenarios involving many outputs.

The storage limit path used a signed int as a secondary output selection
mask. Shifting by output IDs at or above 32 is undefined and can alias a
high-ID output to a lower output on common architectures.

Check each routed output against its configured limit directly before
releasing queue space. This keeps limit enforcement aligned with the
dynamically sized routing masks.

Signed-off-by: Michael Renner <terrorobe@github.com>
Create 33 outputs and place the constrained output at ID 32. Verify that
eviction removes only its route while preserving the unrelated route at
ID 0.

Signed-off-by: Michael Renner <terrorobe@github.com>
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 80685ca0-a319-4219-ae24-89b9b02ce251

📥 Commits

Reviewing files that changed from the base of the PR and between b1128fa and 3355097.

📒 Files selected for processing (1)
  • tests/internal/input_chunk.c
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/internal/input_chunk.c

📝 Walkthrough

Walkthrough

Filesystem space reclamation now evaluates routed output limits directly. Over-limit detection returns a boolean. A new integration test validates behavior with 33 outputs and filesystem storage.

Changes

Input chunk limit handling

Layer / File(s) Summary
Route limit evaluation
src/flb_input_chunk.c
Space reclamation no longer receives an output bitmask. It checks each routed output with a finite limit against projected filesystem usage. Over-limit detection returns FLB_TRUE when any route exceeds its limit.
Many-output limit validation
tests/internal/input_chunk.c
A new integration test configures 33 outputs, appends two chunks, verifies route ownership and high-priority output limits, and cleans up engine resources. The test is registered in TEST_LIST.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • fluent/fluent-bit#11632: Both changes modify src/flb_input_chunk.c space-limit handling and related input-chunk tests.

Suggested reviewers: cosmo0920

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the storage-limit eviction fix for configurations with 32 or more outputs.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/internal/input_chunk.c`:
- Around line 1252-1254: In the test setup around flb_input_chunk_get_real_size,
store the result in a signed ssize_t chunk_real_size, assert that it is positive
before converting it to first_chunk_size, and route assertion failure through
the function’s cleanup path. Add the cleanup label before the task teardown loop
so resources are released while failures prevent deriving total_limit_size from
a negative value.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 070dd534-fb16-4c8d-b60a-50e07dcbfca4

📥 Commits

Reviewing files that changed from the base of the PR and between cf50b7e and b1128fa.

📒 Files selected for processing (2)
  • src/flb_input_chunk.c
  • tests/internal/input_chunk.c

Comment thread tests/internal/input_chunk.c
Keep the real chunk size signed until its error result is checked. Avoid
deriving the test limit from a failed size lookup.

Signed-off-by: Michael Renner <terrorobe@github.com>
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.

1 participant