Using --collect.slave_hosts with MariaDB which does not yet support SHOW REPLICAS and a user who does not have the required grants to run the SHOW SLAVE HOSTS command causes a syntax error to be logged.
This seems to originate from commit f6a64d7 (#837) which added support for SHOW REPLICAS results but the implementation assumes that the first error is due to the old syntax not being supported and overwrites the error with the result of SHOW REPLICAS which will result in a syntax error for everything other than MySQL 8.4 for users with incorrect grants.
Steps to reproduce
- Install any versio of MariaDB or MySQL 8.0
- Create a user without the REPLICATION SLAVE privilege
- Run mysqld_exporter with --collect.slave_hosts
The result should be that a syntax error is logged instead of the correct error that shows the user doesn't have the correct grants.