Skip to content
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

Customizable locking while database is busy #1156

Merged
merged 4 commits into from
Aug 23, 2021

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Aug 23, 2021

By submitting this pull request, I confirm the following:

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

How familiar are you with the codebase?:

10


When the gravity database is locked/busy, Pi-hole allows all queries because it has no way of detecting if they should be blocked or not. However, for very large lists and/or on very busy networks and/or on very (!) slow devices, this may open a windows of up to several seconds where undesired queries may get through, ads and unwanted telemetry could be the result.

This PR adds a config option (REPLY_WHEN_BUSY) to customize what happens to queries while the database is locked:

  1. ALLOW - as before, just allow all queries when the database is busy
  2. BLOCK - block all queries when the database is busy. This uses the configured BLOCKINGMODE (default NULL)
  3. REFUSE - refuse all queries which arrive while the database is busy
  4. DROP - just drop the queries, i.e., never reply to them at all.

In my opinion, option 4 is the best one because it will typically cause clients to retry the query after some timeout of typically a few seconds. I.e., the DNS resolution will only be delayed but we do never hand out incorrectly either allowed or blocked queries.
REFUSE first sounded like a good option, too, however, it turned out that many clients will just immediately retry, causing up to several thousands of queries per second. This does not happen in DROP mode.

@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/behavior-when-database-is-busy/48174/25

@DL6ER
Copy link
Member Author

DL6ER commented Aug 23, 2021

Connected web PR: pi-hole/web#1869

@yubiuser
Copy link
Member

Connected doc PR: pi-hole/docs#554

@dschaper
Copy link
Member

Sounds like a great idea to me.

@DL6ER DL6ER merged commit 127860e into release/v5.9 Aug 23, 2021
@DL6ER DL6ER deleted the tweak/blocking_while_busy branch August 23, 2021 18:19
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/pi-hole-ftl-v5-9-web-v5-6-and-core-v5-4-released/49544/1

@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/pi-hole-allows-blacklisted-queries-through-on-reboot/52312/12

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