[ZBX-15210] "autoreg_host" table is never cleaned up Created: 2018 Nov 26 Updated: 2025 Mar 12 Resolved: 2023 Sep 12 |
|
| Status: | Closed |
| Project: | ZABBIX BUGS AND ISSUES |
| Component/s: | Server (S) |
| Affects Version/s: | 3.0.23, 4.0.1 |
| Fix Version/s: | 6.0.22rc1, 6.4.7rc1, 7.0.0alpha5, 7.0 (plan) |
| Type: | Problem report | Priority: | Major |
| Reporter: | Oleksii Zagorskyi | Assignee: | dimir |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | autoregistration, housekeeper | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Team: | |||||||||
| Sprint: | Sprint 47, Dec 2018, Sprint 48, Jan 2019, Sprint 51 (Apr 2019), Sprint 52 (May 2019), Sprint 53 (Jun 2019), Sprint 103 (Aug 2023), Sprint 104 (Sep 2023) | ||||||||
| Story Points: | 1 | ||||||||
| Description |
|
The "autoreg_host" contains a technical runtime information about auto-registered host. Would be nice to find out some solution to delete unneeded information from the table. For example delete host, missing in "hosts" table and/or for missing IP addresses. |
| Comments |
| Comment by Vladislavs Sokurenko [ 2018 Nov 26 ] | |
|
I know that this is not enough but if it is monitored by Zabbix proxy and you remove proxy then it will also delete autoreg_host zalex_ua Yes, I know that, because of constraints on DB level. | |
| Comment by Konstantin Kornienko [ 2019 Jun 03 ] | |
|
We have more than 2000000 rows in this table. Could you advise, is it safe to perform something like this: DELETE from autoreg_host where autoreg_hostid in ( select a.autoreg_hostid )
(not tested) | |
| Comment by Andris Zeila [ 2019 Jul 22 ] | |
|
Depends. It wont crash or something, but some of auto registration events might lose the associated autoreg_host record (not likely, but in theory it can happen). What it means - if the autoregistration event was not yet processed it will be ignored. Of course when server will receive next active checks request from this host it will create new autoreg_host record and process the new event, so in most cases it would just delay host auto registration by 2 minutes (the default RefreshActiveChecks interval). So yes, it should be safe unless you have some very specific setup/requirements. | |
| Comment by dimir [ 2023 Aug 17 ] | |
|
UPD: please see the SQL in comment below. | |
| Comment by Konstantīns Ošmjans [ 2023 Aug 17 ] | |
|
Hi dimir, you wrote:
The result on my system (with PostgreSQL) is following:
| |
| Comment by dimir [ 2023 Aug 17 ] | |
|
UPD: please see the SQL in the comment below. | |
| Comment by Konstantīns Ošmjans [ 2023 Aug 17 ] | |
For me, the result is: 0 (zero). | |
| Comment by dimir [ 2023 Aug 17 ] | |
|
That probably means for those autoreg_host records the corresponding events are already deleted. Please try the following one (but please include the whole output, where the query time is seen): select count(ah.autoreg_hostid)
from autoreg_host ah
where not exists (
select null
from hosts h
where ah.host=h.host)
and not exists (
select null
from events e
where ah.autoreg_hostid=e.objectid
and e.source=2
and e.object=3);
I'm interested in amount of returned records and time spent on the statement. | |
| Comment by Konstantīns Ošmjans [ 2023 Aug 17 ] | |
The result is:
| |
| Comment by dimir [ 2023 Aug 17 ] | |
|
Thanks a lot! zalex_ua would it be possible for you to run that also? <zalex_ua> asked to get. But I'm not sure about expectation. | |
| Comment by dimir [ 2023 Aug 17 ] | |
|
konstantin.kornienko any chance to run the above mentioned SQL (this comment) to see the query execution time? | |
| Comment by dimir [ 2023 Aug 25 ] | |
|
Fixed in development branch for 6.0. | |
| Comment by dimir [ 2023 Sep 05 ] | |
OverviewThe table autoreg_host was never cleared before this fix. After this fix the records in autoreg_host table will be handled by Housekeeper. Whenever it is run it will delete records in it that do not reference any of the autoregistration events (autoreg_host.autoreg_hostid=event.objectid) and any of the hosts (autoreg_host.host=host.host) respecting the MaxHousekeeperDelete option. Fixed in
| |
| Comment by Martins Valkovskis [ 2023 Sep 07 ] | |
|
Updated documentation: | |
| Comment by Konstantīns Ošmjans [ 2023 Sep 07 ] | |
|
Thank you, guys! |