Skip to content

tests: integration: Adjust allocation patterns for Ubuntu 26.04 - #12346

Open
cosmo0920 wants to merge 1 commit into
masterfrom
cosmo0920-adjust-for-ubuntu-26.04-malloc-patterns
Open

tests: integration: Adjust allocation patterns for Ubuntu 26.04#12346
cosmo0920 wants to merge 1 commit into
masterfrom
cosmo0920-adjust-for-ubuntu-26.04-malloc-patterns

Conversation

@cosmo0920

@cosmo0920 cosmo0920 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

This PR is leveraged with Fable5 investigation and plan and orchestrated Opus-5 agent(s).

Investigation

The test works by sandwiching fluent-bit's heap with RLIMIT_DATA: it measures baseline VmData, then restarts fluent-bit with limit = baseline + delta and sends a truncated ~29 KiB forward payload. The payload keeps a msgpack object incomplete, forcing msgpack_unpacker_reserve_buffer in receiver_to_unpacker fw_prot.c:1233 to repeatedly grow its buffer (doubling from 1 KiB up to ~32–64 KiB). The test needs a limit where connection setup succeeds but that buffer growth malloc fails, producing "could not allocate msgpack unpacker buffer".

The failure log shows the two regimes are separated by at most 16 KiB (27496 KiB → "connection allocation failed", 27512 KiB → "nothing failed"), and no probed delta lands in a working window. This machine runs Ubuntu 26.04.1 with glibc 2.43; on older glibc the heap-growth granularity left a gap where the ~32–64 KiB unpacker expansion was the first allocation to hit the limit. With glibc 2.43's malloc (different top-chunk padding/arena behavior), once the connection-setup allocations succeed, the arena already has enough slack to serve the unpacker growth too — the target window is narrower than the test's step size, or doesn't exist at all. The test's tiny 29 KiB payload makes it inherently fragile: the allocation it wants to fail is the same order of magnitude as malloc's growth granularity.

Plan

  1. Investigate empirically (Opus agent): confirm on this machine whether any window exists (1 KiB sweep across the boundary), and find a deterministic configuration — glibc tunables for the child process (MALLOC_ARENA_MAX, MALLOC_TOP_PAD_, MALLOC_MMAP_THRESHOLD_) and/or a much larger truncated payload (hundreds of KiB–MiB) so the unpacker's expansion allocation dwarfs malloc granularity and a wide limit window opens.
  2. Fix the test (Opus agent): apply the winning approach to test_in_forward_001.py, keeping the test's intent (allocation failure closes connection, then recovery), then verify with the single test and the full in_forward scenario file.

Root cause

On Ubuntu 26.04 (glibc 2.43) the test's target failure was structurally unreachable, not just flaky. The old 29229-byte payload only ever forced the msgpack unpacker to grow to 32–64 KiB, and glibc serves allocations that small from the ~128 KiB of arena top slack that already exists at startup — the kernel is never asked for memory, so RLIMIT_DATA is never consulted. Meanwhile fw_conn_add() does a single 1000 KiB flb_malloc for the connection buffer (buffer_chunk_size), which pinned the too-tight/too-loose boundary at exactly baseline+1000 KiB. A 1 KiB-step sweep confirmed the window between the two regimes was empty: no limit value could ever make the unpacker allocation fail first. glibc tunables (MALLOC_ARENA_MAX etc.) moved the boundary by only 1 KiB and were rejected.

Fix (test file only, test_in_forward_001.py)

  • Payload: now 8 entries of {"log": "R"*100000} with declared length 16, truncated/zero-padded to 800000 bytes. Peak unpacker allocation becomes ~1 MiB — roughly 8× any plausible glibc arena slack — while staying under buffer_chunk_size (1024000) so conn->buf is never realloc'd. This opens a measured ~1 MiB-wide trigger window (delta ∈ [1096, ~2160] KiB), which is granularity-independent across glibc 2.35/2.39/2.43.
  • Delta list: trimmed to [1152, 1408, 1664, 1920, 2176, 2688, 3200]; the first four all land inside the window.
  • Honest classification: a previously undetected third regime (could not register new connection, the coroutine-stack allocation failing) is now reported as its own too-tight status instead of masquerading as "allocation failure was not triggered".

Verification

  • Single test passed 3/3 runs, each in ~2.6 s (first delta triggers immediately; the old version took the full sweep and failed).
  • Full test_in_forward_001.py file: 72 passed, no regressions.
  • One unrelated pre-existing flake surfaced during verification: test_in_opentelemetry_non_matching_route_drops_all_signals[profiles-...] failed once mid-run but passes standalone and in the final clean run — worth keeping an eye on separately.

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.

Summary by CodeRabbit

  • Bug Fixes
    • Improved forward allocation failure testing for larger payloads.
    • Added clearer handling for connection-registration allocation failures.
    • Updated memory-limit scenarios to better reflect high-volume allocation behavior.

@cosmo0920
cosmo0920 requested a review from edsiper as a code owner August 28, 2026 07:44
@cosmo0920 cosmo0920 changed the title tests: integration: Adjust allotation patterns for Ubuntu 26.04 tests: integration: Adjust allocation patterns for Ubuntu 26.04 Aug 28, 2026
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@coderabbitai

coderabbitai Bot commented Aug 28, 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: 25290a45-90e3-453b-9b5d-5bee1cfa291c

📥 Commits

Reviewing files that changed from the base of the PR and between 37c279f and d4a478f.

📒 Files selected for processing (1)
  • tests/integration/scenarios/in_forward/tests/test_in_forward_001.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The forward integration test now generates a larger allocation-reproduction payload, distinguishes connection-registration failures, and uses revised memory-limit increments.

Changes

Forward allocation-failure reproduction

Layer / File(s) Summary
Update forward reproduction attempts
tests/integration/scenarios/in_forward/tests/test_in_forward_001.py
The test uses eight 100,000-byte records, creates an 800,000-byte payload, reports connection-registration failures separately, and sweeps revised memory limits.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to d4a47

This change updates a localized integration test to use a larger malformed payload and clearer allocation-failure classification without changing production behavior. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: edsiper, leonardo-albertovich

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the integration test and the allocation-pattern adjustments for Ubuntu 26.04. It accurately summarizes the main change.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cosmo0920-adjust-for-ubuntu-26.04-malloc-patterns

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.

@cosmo0920
cosmo0920 force-pushed the cosmo0920-adjust-for-ubuntu-26.04-malloc-patterns branch from aa8aa8a to d4a478f Compare August 28, 2026 07:46
@cosmo0920 cosmo0920 added this to the Fluent Bit v5.1.2 milestone Aug 28, 2026
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