engine_dispatch: Address stale failed tasks on dispatch - #12254
Conversation
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
📝 WalkthroughWalkthroughThe retry dispatch failure path now records retry and drop metrics, reschedules retries within the retry limit, and releases terminal retry state. Internal tests cover ownership, retry preservation, chunk registration, metrics, and task ID reuse. ChangesRetry dispatch failure handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/internal/engine_dispatch.c (1)
30-32: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse the required control-statement brace style.
Move the opening brace to the next line for each new
if,else,while, anddoblock in this file. Line 30 is one example.Proposed fix
- if (ctx == NULL) { + if (ctx == NULL) + { return; }🤖 Prompt for 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. In `@tests/internal/engine_dispatch.c` around lines 30 - 32, Update the control statements in engine_dispatch.c to place opening braces on the following line for every if, else, while, and do block, including the block guarding ctx == NULL. Preserve all existing logic and formatting otherwise.Source: Coding guidelines
🤖 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/engine_dispatch.c`:
- Around line 28-48: The test fixture must balance Winsock lifecycle management.
Update test_ctx_create to check the WSAStartup result and record successful
initialization in test_ctx; update test_ctx_destroy to call WSACleanup only when
initialization succeeded, after resource teardown, while preserving cleanup for
failed or partially initialized fixtures.
---
Nitpick comments:
In `@tests/internal/engine_dispatch.c`:
- Around line 30-32: Update the control statements in engine_dispatch.c to place
opening braces on the following line for every if, else, while, and do block,
including the block guarding ctx == NULL. Preserve all existing logic and
formatting otherwise.
🪄 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: e0471cc7-4f77-4584-8ece-706754020b33
📒 Files selected for processing (3)
src/flb_engine_dispatch.ctests/internal/CMakeLists.txttests/internal/engine_dispatch.c
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e01062fbe6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/internal/engine_dispatch.c (1)
89-94: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the required control-block brace style.
Move each opening brace to the next line.
tests/internal/engine_dispatch.c#L89-L94: Move theif (ret != 0)opening brace.tests/internal/engine_dispatch.c#L139-L161: Move the counter-allocation failure-block opening brace.tests/internal/engine_dispatch.c#L166-L178: Move the metrics-allocation failure-block opening brace.tests/internal/engine_dispatch.c#L187-L190: Move the metrics cleanup-block opening brace.tests/internal/engine_dispatch.c#L236-L244: Move the metric null-check opening braces.tests/internal/engine_dispatch.c#L283-L292: Move the task-event-chunk and route-allocation failure-block opening braces.tests/internal/engine_dispatch.c#L333-L338: Move the output initialization failure-block opening brace.tests/internal/engine_dispatch.c#L385-L390: Move the output initialization failure-block opening brace.tests/internal/engine_dispatch.c#L451-L456: Move the output initialization failure-block opening brace.tests/internal/engine_dispatch.c#L470-L481: Move the allocation failure-block opening brace.As per coding guidelines: “Put function opening braces on the next line.”
🤖 Prompt for 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. In `@tests/internal/engine_dispatch.c` around lines 89 - 94, Apply the required next-line brace style in tests/internal/engine_dispatch.c at lines 89-94, 139-161, 166-178, 187-190, 236-244, 283-292, 333-338, 385-390, 451-456, and 470-481: move each listed if/else failure, cleanup, null-check, and allocation-block opening brace onto its own following line, without changing control flow or behavior.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@tests/internal/engine_dispatch.c`:
- Around line 89-94: Apply the required next-line brace style in
tests/internal/engine_dispatch.c at lines 89-94, 139-161, 166-178, 187-190,
236-244, 283-292, 333-338, 385-390, 451-456, and 470-481: move each listed
if/else failure, cleanup, null-check, and allocation-block opening brace onto
its own following line, without changing control flow or behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 09d52167-1e44-4865-94be-373d3a9506a7
📒 Files selected for processing (2)
src/flb_engine_dispatch.ctests/internal/engine_dispatch.c
🚧 Files skipped from review as they are similar to previous changes (1)
- src/flb_engine_dispatch.c
|
Thanks for picking this up so quickly. I built this branch and confirmed it does close the leak. One thing I would like your call on: releasing the task reaches I opened #12260 on top of this branch rather than only describing it. It keeps your fix and your drop accounting, and only spends one delivery attempt before giving up. With the default Happy to close #12260 and move it into a review comment instead if you would rather keep this PR self-contained. |
flb_input_chunk_flush() returning NULL is usually transient, so dropping the retry discards records a later attempt could still deliver. Spend a delivery attempt on it instead and only give up once the configured retry limit is reached, where the existing accounting already applies. Behaviour is unchanged with the default retry_limit of 1: the first read failure still drops immediately. Signed-off-by: ku524 <yeonjuyeong@gmail.com>
Asserts that with retry budget left the task keeps its task-map slot, its chunk and a pending retry, and that no drop accounting is recorded. Signed-off-by: ku524 <yeonjuyeong@gmail.com>
I merged your PR in this PR. Really appreciated to cooperate with you to address the issue. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/flb_engine_dispatch.c (1)
130-138: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse the required block-brace layout.
The changed
ifblocks place the opening brace on the control-statement line. Move each opening brace to the following line.
src/flb_engine_dispatch.c#L130-L138: move the retry-limitifopening brace to the next line.src/flb_engine_dispatch.c#L146-L148: move the reschedule-failureifopening brace to the next line.tests/internal/engine_dispatch.c#L540-L542: move the null-contextifopening brace to the next line.tests/internal/engine_dispatch.c#L546-L549: move the output-init failureifopening brace to the next line.tests/internal/engine_dispatch.c#L556-L560: move the null-retryifopening brace to the next line.As per coding guidelines, C control blocks must use braces on the following line.
🤖 Prompt for 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. In `@src/flb_engine_dispatch.c` around lines 130 - 138, Move each opening brace to the line following its control statement without changing behavior: the retry-limit and reschedule-failure if blocks in src/flb_engine_dispatch.c (lines 130-138 and 146-148), and the null-context, output-init failure, and null-retry if blocks in tests/internal/engine_dispatch.c (lines 540-542, 546-549, and 556-560).Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@src/flb_engine_dispatch.c`:
- Around line 130-138: Move each opening brace to the line following its control
statement without changing behavior: the retry-limit and reschedule-failure if
blocks in src/flb_engine_dispatch.c (lines 130-138 and 146-148), and the
null-context, output-init failure, and null-retry if blocks in
tests/internal/engine_dispatch.c (lines 540-542, 546-549, and 556-560).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d2e9c194-44a1-4a89-a016-778f1d9bc297
📒 Files selected for processing (2)
src/flb_engine_dispatch.ctests/internal/engine_dispatch.c
Implemented the stale-task cleanup.
Changes:
src/flb_engine_dispatch.c:72now callsflb_task_users_release(task)after destroying the failed retry.tests/internal/engine_dispatch.ccovering:tests/internal/CMakeLists.txt.Verification:
Result: both tests passed, 0 failures.
The regression test was also built and run temporarily without the production fix. It failed on the occupied task-map slot, retained task/chunk lists, and non-reused task ID. After restoring the fix, it passed.
No Python integration scenario covers this engine-dispatch lifecycle path.
Closes #12252.
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-testlabel 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.
Summary by CodeRabbit
Bug Fixes
Tests