Closed orlovmyk closed 5 years ago
Thanks, You're completely right, previous version of the query takes into account all kind of activity, including autovacuum too. Accordingly to item's name autovacuum should be excluded.
I still have trouble setting up a test environment to run all postgres versions 9.4 up. Is it confirmed that all autovacuum queries in these versions match that pattern (and it is not over-matching?)
Based on this, it should probably be "autovacuum: " https://github.com/postgres/postgres/blob/292ae8af79b4f1b09a327d39e80ef70943a28194/src/backend/postmaster/autovacuum.c#L3138
At least it is in since decades, so I assume it is safe to match it. https://github.com/postgres/postgres/commit/7aa4164363f48c9a8345a0fda48e21de75f499d6
There is no huge difference between "autovacuum" and "autovacuum: " and proposed query will effectively cut down autovacuums.
Ideally, the query also should take into account pg_stat_activity.backend_type
field, but this field added since pg-10.
regexp changed here 09033b5, accordingly to postgres source Thanks @stephankn for observations
Thanks. Glad you double checked the field backend_type. To ensure compatibility it is better to match only the string, which should be quite unique already. I think you missed out the wildcard when changing the pattern. See me comment on the change.
yes, my mistake, returned wildcard here 00caf89
Results from transactions monitoring are also including autovacuum queries during checks, this fix will cut them down. Let me show few examples of running check queries at real database:
psql -U postgres -t -c "select coalesce(extract(epoch from max(age(now(), query_start))), 0) as exec_time, query from pg_stat_activity where state <> 'idle in transaction' and state <> 'idle' group by query order by exec_time desc"
, it will show us all running transactions, which is not in idle state in this output: quert_execution_time, query[root@zabbix ~]# zabbix_get -s ???.???.???.??? -k pgsql.transactions.active[*] 3351.53421
[root@zabbix ~]# zabbix_get -s ???.???.???.??? -k pgsql.transactions.active[*] 14.695067