GeezerVison is showing github.com — dbengine: load only exactly named datafiles by stelfrag · Pull Request #24436 · netdata/netdata
Conversation
stelfrag
commented
Oct 26, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
scan_data_files() took any name for which sscanf("datafile-%1u-%10u.ndf") converted both numbers. sscanf() does not check the .ndf literal or trailing text, so:
- a copy such as
datafile-1-0000000001.ndf.bak loaded the real datafile and journal a second time (two structs for one file, disk space charged twice, one struct orphaned with its open file);
- a stray
datafile-2-<n>.ndf aborted startup on fatal_assert(tier == 1);
- the startup probe that tells ram-mode agents whether dbengine data exists counted the same names.
datafile_name_parse() accepts only the exact name generate_datafilepath() writes (tier 1, 10-digit file number, .ndf); both places use it. Other names now get the existing "Unknown file detected" warning. A unit check covers the accepted and rejected names.
Validation on test agents:
- pair +
.ndf.bak: master "loading 2 data/journal files", this PR "loading 1" and the .bak reported as unknown
datafile-2-*.ndf: master "Assertion `tier == 1' failed", this PR starts normally
- ram-mode agent with only a
.ndf.bak: dbengine_datafiles_present true on master, false here (a real datafile still sets it)
- full
-W unittest passes
Fixes F5 of #23896.
Summary by CodeRabbit
- Bug Fixes
- Datafile discovery now recognizes only correctly formatted tier-1 datafile names. Unrelated files, backup copies, and names with invalid prefixes, extensions, or file numbers are excluded, helping ensure the database engine loads the intended persisted datafiles.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
sscanf() accepted any name that starts like a datafile: a copy such as
datafile-1-0000000001.ndf.bak loaded the real datafile and journal a
second time, and a datafile-2-* name aborted startup. Both the scan and
the startup presence probe now require the exact name dbengine writes.
coderabbitai
Bot
commented
Oct 26, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Recent review info
-
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
40cae51f-80e7-4320-b914-ad2ee510eb06
Commits
-
Reviewing files that changed from the base of the PR and between 8965ee4 and 4abdfa2.
Files selected for processing: 4
-
src/daemon/config/netdata-conf-db.c
src/database/engine/datafile.c
src/database/engine/datafile.h
src/database/engine/dbengine-unittest.c
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Walkthrough
-
Datafile scans now use a parser that accepts canonical tier-1 datafile names and extracts the file number. Unit tests cover valid names and reject suffixes, incorrect prefixes or extensions, missing extensions, and short file numbers.
Changes: Datafile name validation
| Layer / File(s) |
Summary |
Canonical filename parser src/database/engine/datafile.h, src/database/engine/datafile.c, src/database/engine/dbengine-unittest.c |
A public parser accepts canonical tier-1 datafile names and returns the file number. Unit tests cover accepted and rejected names, and the dbengine test runner includes the new tests. |
Datafile scan integration src/daemon/config/netdata-conf-db.c, src/database/engine/datafile.c |
Both scans use the parser to recognize persisted datafiles. The datafile scan assigns accepted files to tier 1. |
Priority: Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: thiagoftsm
Merge Risk: Minimal · up to 4abdf
-
No actionable risk introduced by this change is established. It is ready to merge after normal checks.
Pre-merge checks: 4 · 1
-
Failed checks: 1 warning
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
 |
Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
Passed checks: 4 passed
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
 |
The title clearly and concisely describes the main change: dbengine now loads only datafiles with the exact expected names. |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR was tested on Microsoft Windows and load files and rotation happened as expected. LGTM!
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
stelfrag
added a commit
to stelfrag/netdata
that referenced
this pull request
Oct 26, 2026
sscanf() accepted any name that starts like a datafile: a copy such as
datafile-1-0000000001.ndf.bak loaded the real datafile and journal a
second time, and a datafile-2-* name aborted startup. Both the scan and
the startup presence probe now require the exact name dbengine writes.
(cherry picked from commit e55d5ff)
Ferroin
pushed a commit
that referenced
this pull request
Nov 4, 2026
sscanf() accepted any name that starts like a datafile: a copy such as
datafile-1-0000000001.ndf.bak loaded the real datafile and journal a
second time, and a datafile-2-* name aborted startup. Both the scan and
the startup presence probe now require the exact name dbengine writes.
(cherry picked from commit e55d5ff)
Reviewers
vkalintiris
Awaiting requested review from vkalintiris
vkalintiris is a code owner
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|