-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
Docker restart, wrong queries counts #2303
Comments
Yes, on exit FTL should save the queries to the database.
|
BUT upon restart query stats are not where they were but some time before! |
Upon further testing they now are...... Weird |
Please run a debug log with |
you mean in the docker container cli? |
Yes. |
Thanks. I just wanted to rule out that the databases are damaged
I have no good idea, I'll need to check myself |
I have done numerous tests today and upon restart the counters were way back.... Now 3 tests and OK. |
Note: If you are waiting for the container to stop, the data should be saved to disk (like your recent tests). If you kill the container (or pull the plug, or something similar), Pi-hole will be instantly killed and some data will be lost. Did you really wait for the container to stop every time? |
Well you might have something there. Just tested shutting down the VM (running on xcp-ng) and data was lost but the shutdown command just iniciated a OS shutdown (debian) NO power plug kill... So this is weird. |
Also when doing a "reboot" from the cli. Data lost |
Now I just stopped the docker container and restarted and data was lost. |
Looking at the logs: I clean shutdown the container with queries at 15107 and restarting:
Queries totals are not all written to database upon shutdown. That's the problem |
Is their any circumstance where FTL would not write it's in-memory query log to the database on shutdown? |
Stopped Docker with total queries in the 28.000...
The problem is quite obvious now. I even changed the value of database.DBinterval to 5 in the settings (from 60), thinking that this would help but to no avail..... |
Please note: the Total_Queries shown on the web interface are only 'A and AAAA' queries (see the mouse overlay). There might be other query types in your datatbase. |
Wait.... the overlay might be wrong in v6 |
There you go. But in the meantime I switched again to Adguard Home.... Easier to deploy and maintain. |
Sorry, I missed this before. There is no real bug here, it is expected that the numbers are slightly different. The reason for this is efficiency. Pi-hole has been designed to use as few resources as possible. Part of this is that the total number of queries (as well as some other global sums) is not always 100% precise but only updated/recomputed every 10 minutes. This allows the API to deliver these numbers in sub-milliseconds and not needing to count on every API call. Hence, the numbers you are seeing shortly before shutdown of your container may have not been recomputed for ... say ... 5 minutes. Then, on the next start of the container, the sum obviously as to be computed afresh as we do not back up such meta-information in the database. This newly computed number is then expected to be slightly different. It is logical to be slightly lower (up about to 1% if you have a perfectly uniform querying behavior in your network) but it could even be higher if you are seeing a massive load of queries immediately after the restart. TL;DR: There is nor a bug nor actually an inconsistency here. The global sums are recomputed not very often to be light on resources but a restart will force them to be recalculated. It is expected that they are slightly different by up to 1%. |
Thanks for the explanation. But I don't think this should be as it is now.... I for one don't like it at all. |
But why? As I said above, the total number is an estimate and, as such, it changes all the time. Recomputing it every time will just eat up resources without any real gain IMO. Why do you think it is worth the extra costs to always recompute it exactly each time? If you need the exact numbers for something in your network, I'd propose you directly source this number from the database instead. |
I heard you. I wouldn't even know to get it from the database.... Why don't you implement something like this: A Klick on the totaliers will recompute and show the current value. |
Maybe we could compute the number on shutdown? |
But what would we gain? When we compute it at the very end, it will immediately be lost. And recomputed anyway on the next start. We could theoretically add a signal and/or API action endpoint that triggers an immediate re-counting but it'd require careful testing what running this frequently causes to the overall performance of FTL. |
Latest Docker piholev6 installed.
When I stop and restart pihole, the Total_Queries and Queries_Blocked values are not the last ones before the stop. But from some time back.
They should be saved between restarts....?
The text was updated successfully, but these errors were encountered: