Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@DL6ER
Copy link
Member

@DL6ER DL6ER commented Aug 15, 2025

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_views from 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:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories development branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

DL6ER added 2 commits August 15, 2025 19:56
…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]>
@DL6ER DL6ER force-pushed the tweak/database_resilience branch from 9313aa1 to fe29217 Compare August 15, 2025 17:56
@DL6ER
Copy link
Member Author

DL6ER commented Aug 15, 2025

Rebased on latest development

@DL6ER DL6ER requested a review from rdwebdesign September 14, 2025 18:14
@DL6ER DL6ER dismissed rdwebdesign’s stale review September 14, 2025 18:14

Requested changes have been addressed

@DL6ER DL6ER requested a review from Copilot September 17, 2025 06:52
Copy link
Contributor

Copilot AI left a 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 1 calloc() and snprintf()
  • 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.

@github-actions
Copy link

github-actions bot commented Oct 5, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions
Copy link

github-actions bot commented Oct 5, 2025

Conflicts have been resolved.

Copy link
Member

@yubiuser yubiuser left a 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

@DL6ER DL6ER merged commit 331b8bc into development Oct 5, 2025
18 checks passed
@DL6ER DL6ER deleted the tweak/database_resilience branch October 5, 2025 18:33
@PromoFaux PromoFaux mentioned this pull request Oct 25, 2025
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.

4 participants