Skip to content

in_tail: Add error log when flb fails to update the DB. Currently it fails silently.#11417

Open
hardikkhurana wants to merge 2 commits intofluent:masterfrom
hardikkhurana:master
Open

in_tail: Add error log when flb fails to update the DB. Currently it fails silently.#11417
hardikkhurana wants to merge 2 commits intofluent:masterfrom
hardikkhurana:master

Conversation

@hardikkhurana
Copy link

@hardikkhurana hardikkhurana commented Feb 1, 2026

Fixes #11416

Description:
When using the in_tail plugin with a database configured (db parameter), if the SQLite database becomes locked (e.g., receives SQLITE_BUSY or SQLITE_LOCKED), the plugin silently fails to update the file offset. The function flb_tail_db_file_offset returns -1, but no error message is logged to indicate that the persistence failed.

Change:
Add an error log line so that the error is not silent.


Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
[SERVICE]
    Flush 1
    Log_Level info
[INPUT]
    Name tail
    Path /tmp/test.log
    DB   /tmp/tail.db
[OUTPUT]
    Name stdout
  • Debug log output from testing the change
[error] [input:tail:tail.0] db: cannot update file offset for /tmp/test.log (id=1), ret=5
  • [ N/A ] 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.

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

Documentation

  • [N/A ] Documentation required for this feature

Backporting

  • [N/A] 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 error logging and handling in the tail input plugin when updating tracked file offsets fails. This enhances diagnostic messages and operational visibility, making it easier to detect and troubleshoot file-tracking and offset-management issues during log collection, improving reliability of continuing or resuming log ingestion.

@coderabbitai
Copy link

coderabbitai bot commented Feb 1, 2026

📝 Walkthrough

Walkthrough

Adds an error log in flb_tail_db_file_offset when sqlite3_step fails to update a file offset in the SQLite DB; the code logs the filename, DB id and return code before performing existing cleanup and fallback logic.

Changes

Cohort / File(s) Summary
Error Logging Enhancement
plugins/in_tail/tail_db.c
Add an error log when sqlite3_step does not return SQLITE_DONE during file-offset update; existing cleanup/reset and re-insert-on-zero-changes logic unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

Poem

🐰 I hopped through bytes and found a clue,

When offsets slipped and no one knew.
I call a warning, clear and bright,
So restarts don't replay the night.
🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding an error log when flb fails to update the DB for the in_tail plugin.
Linked Issues check ✅ Passed The PR implements the core requirement from issue #11416: adding an error log when flb_tail_db_file_offset fails to update the DB.
Out of Scope Changes check ✅ Passed All changes are within scope: only a 3-line addition of error logging to the flb_tail_db_file_offset function.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ff5d8bfbcc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@plugins/in_tail/tail_db.c`:
- Around line 301-304: The flb_plg_error call in tail_db.c is broken by an
unterminated format string and misplaced quotes; fix the call in the error
branch where ctx->stmt_offset is handled by replacing the broken literal with a
single properly formatted format string and moving the variables into the
argument list (e.g. "db: cannot update file offset for %s (id=%" PRIu64 "),
ret=%d" , file->name, file->db_id, ret). Ensure the format uses the PRIu64 macro
concatenation exactly as above, remove the stray quote, and keep the subsequent
sqlite3_clear_bindings(ctx->stmt_offset) call unchanged.

@hardikkhurana hardikkhurana changed the title tail plugin: Add error log when flb fails to update the DB. Currently it fails silently. in_tail: Add error log when flb fails to update the DB. Currently it fails silently. Feb 2, 2026
hardikkhurana and others added 2 commits February 4, 2026 19:21
… it fails silently.

Signed-off-by: Hardik Khurana <43683221+hardikkhurana@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Hardik Khurana <43683221+hardikkhurana@users.noreply.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.

in_tail fails silently when SQLite DB is locked (offset update failure)

1 participant