-
-
Notifications
You must be signed in to change notification settings - Fork 235
Improve gravity database resilience #2605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…nal tools. This change is mostly about FTL's behavior in case of missing vital database dables (such as "gravity"). So far, this was already covered but the logging was needlessly verbose when we tried to access the database tables although the preparation has already shown that there is an error Signed-off-by: DL6ER <[email protected]>
…nal constants for consistency. Note that this requires an increase in gravity database version Signed-off-by: DL6ER <[email protected]>
9313aa1 to
fe29217
Compare
|
Rebased on latest |
Co-authored-by: RD WebDesign <[email protected]> Signed-off-by: Dominik <[email protected]>
Requested changes have been addressed
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.
Pull Request Overview
This PR improves gravity database resilience and renames database views from whitelist/blacklist to allowlist/denylist terminology for consistency. The changes include optimizing memory allocation in a critical code path and improving error handling for database table access.
- Rename database views and internal constants from white/blacklist to allow/denylist terminology
- Optimize memory allocation by replacing 4 separate
asprintf()calls with 1calloc()andsnprintf() - Improve error handling and logging when database statements cannot be prepared
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test_suite.bats | Update test cases to use new allowlist/denylist view names |
| test/gravity.db.sql | Update database schema with renamed views and version bump to 20 |
| src/regex.c | Update regex loading to use new view names |
| src/enums.h | Rename enum constants from BLACKLIST/WHITELIST to DENY/ALLOW |
| src/datastructure.c | Update domain list counting to use new enum constants |
| src/database/gravity-db.c | Major refactoring with view name changes, memory optimization, and improved error handling |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Signed-off-by: Dominik <[email protected]>
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: Dominik <[email protected]>
|
Conflicts have been resolved. |
yubiuser
left a comment
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.
Tested with pi-hole/pi-hole#6386 and showed no errors
What does this implement/fix?
Improve resilience against unexpected database damage caused by external tools. This change is mostly about FTL's behavior in case of missing vital database tables (such as "gravity"). So far, this was already covered but the logging was needlessly verbose when we tried to access the database tables although the preparation has already shown that there is an error. We also reduce memory allocations from 4 to 1 in a time-critical code path.
Rename the views from white/black to allow/deny as well as some internal constants for consistency. Note that this requires an increase in gravity database version.
Releasing this change in a point release seems fair as direct interaction between users and the database is fixed in all Pi-hole internal tools (see dependent core PR).
Important
This PR needs the related core branch
tweak/rename_viewsfrom PR pi-hole/pi-hole#6386 to work as expected.Related issue or feature (if applicable): N/A
Pull request in docs with documentation (if applicable): N/A
By submitting this pull request, I confirm the following:
git rebase)Checklist:
developmentbranch.