in_blob: Add conditional check for database file before insert#11502
in_blob: Add conditional check for database file before insert#11502zshuang0316 wants to merge 1 commit intofluent:masterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis change updates Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
plugins/in_blob/blob_file.c (1)
81-98:⚠️ Potential issue | 🟠 MajorAdd DB rollback when blob registration fails
Line 82 inserts into the database before registration, but the error path at lines 93-95 only frees memory without calling
blob_db_file_delete(). If registration fails after a successful insert, stale database rows remain while the blob file is never registered, causing futureblob_db_file_exists()checks to skip files. Add rollback in the error path whenctx->database_fileis enabled andbfile->db_idis valid:if (ret == -1) { if (ctx->database_file && bfile->db_id >= 0) { blob_db_file_delete(ctx, bfile->db_id, bfile->path); } cfl_sds_destroy(bfile->path); flb_free(bfile); return -1; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/in_blob/blob_file.c` around lines 81 - 98, When flb_input_blob_file_register(const...) fails after a prior successful blob_db_file_insert(ctx, path, size), the code frees memory but leaves a stale DB row; update the error path after flb_input_blob_file_register (check ret == -1) to, when ctx->database_file is true and bfile->db_id >= 0, call blob_db_file_delete(ctx, bfile->db_id, bfile->path) before cfl_sds_destroy(bfile->path) and flb_free(bfile) so the DB insert is rolled back on registration failure.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@plugins/in_blob/blob_file.c`:
- Around line 81-98: When flb_input_blob_file_register(const...) fails after a
prior successful blob_db_file_insert(ctx, path, size), the code frees memory but
leaves a stale DB row; update the error path after flb_input_blob_file_register
(check ret == -1) to, when ctx->database_file is true and bfile->db_id >= 0,
call blob_db_file_delete(ctx, bfile->db_id, bfile->path) before
cfl_sds_destroy(bfile->path) and flb_free(bfile) so the DB insert is rolled back
on registration failure.
Signed-off-by: zshuang0316 <zshuang0316@163.com>
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
Refactor