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
Pie chart percentages add up to more than 100 % #1056
Comments
Indeed, mine show 107.5% |
This issue has been mentioned on Pi-hole Userspace. There might be relevant details there: https://discourse.pi-hole.net/t/wrong-percent-calculation-in-pie-chart/44277/7 |
This is really an issue with FTL rather than AdminLTE, but I will add my findings here anyway. The problem is that queries with certain status types are counted twice when calculating the stats. At least when reading from the database, e.g. after Lines 521 to 576 in da89cc6
The important variables to keep in mind are totalqueries , counters->blocked and upstream->count .
When queries are read form the database, the associated upstream server needs to be converted into an ID. This is done here: FTL/src/database/query-table.c Lines 390 to 406 in da89cc6
While doing so, the call of findUpstreamID() will increment upstream->count for every query with an associated upstream server, i.e. all queries with these status types (the comment in the code is not correct anymore):
However, further down the line, every one of the blocked queries is also incrementing the FTL/src/database/query-table.c Lines 498 to 544 in da89cc6
This leads to the problem: Solution 1: Make the problematic query types increment
Solution 2: Exempt these blocked queries from being counted to the respective upstream server in the first place:
I don't know if this is also true if memory is generated live or if that is really only the case when read from the database. I didn't yet get a good understanding of the Dnsmasq interface. |
Okay, I dug a little deeper and I think I understand the Dnsmasq interface a little better. This code is also affected. There are two places were the counters a corrected after the fact:
Notice how 2. is just calling 1. at the end. Because of that,
*I haven't actually tested any of the modified code yet. This begs the question: These queries were forwarded and did create a load on the DNS server before they were shot down. In case they aren't exclusive and we choose Solution 1, the correction of the counters should be removed completely. This would mean that externally blocked queries and those blocked after CNAME inspection are contributing to both Solution 2 would mean we ignore the fact that these queries were forwarded at all and just pretend they were blocked immediately. In that case the counters need to be corrected of course. (There is also FTL/src/gc.c that is also modifying these counters. Need to take a look at that as well.) I'll see if I can find some time to do a little testing over the weekend. Opinions on which solution to pick? Anything obvious I missed? |
This issue has been mentioned on Pi-hole Userspace. There might be relevant details there: https://discourse.pi-hole.net/t/wrong-percent-calculation-in-pie-chart/44277/8 |
Thanks for that digging!
In my opinion, they are mutually exclusive. From a users point of view, I would not care about where the query was blocked but only if it was blocked. For the counters I would use the My understanding is that everything that is blocked there should only contribute to blocked queries and not forwarded. This is in line with the current query log, where externally and CNAME blocked queries are shown in red (aka. blocked). |
Thanks for the research. I agree that they are considered mutually exclusive and maybe they don't have to. In the end, the question is what the diagrams should show. With the current concept, you know that everything in the forward destination is not blocked (= permitted). The same goes for the cache. However, if we'd start mixing things (like externally blocked queries contribute to both), this sharp distinction wouldn't be there anymore. Even when this would reflect better what happened on the wire, this may be less what a user expects. The GC function keeps all the internal counters consistent to ensure FTL can run months (or years) without the need for a restart. Any issues with the counters here would likely show up even earlier. The modification of the counters being inlined in the I will move this ticket into the FTL namespace as this is where it belongs. |
Proposed fix is #1057 |
Do queries with status types FTL/src/database/query-table.c Lines 537 to 541 in bfa0d99
But when those queries are removed, Lines 89 to 109 in da89cc6
|
Yes, the flow is the following:
The database code was incorrect. I pushed a fix to the same branch. |
Pi-hole FTL v5.7 has been released |
Versions
Platform
Expected behavior
The percentages in the mouseover tool tips of the pie charts should add up to (roughly) 100 %.
Actual behavior / bug
The percentages in the mouseover tool tips of the Queries answered by pie chart adds up to more than 100 %.
Steps to reproduce
Steps to reproduce the behavior:
Debug Token
Screenshots
The text was updated successfully, but these errors were encountered: