Fix slave-user and slave-password with pt-table-checksum
When using pt-table-checksum without --sync-to-master and the DSN as the master to sync all slaves, the --slave-user and --slave-password parameters are ignored.
Steps to reproduce:
- Set up master-slave replication with percona-server-5.7
- Create a user to be used as the
slave-userwith a random password:
This user will get replicated to the slaves.GRANT ALL PRIVILEGES ON *.* TO 'pt-table-checks' IDENTIFIED BY 'auW2phohsiey'; - Run
pt-table-checksumto create thepercona.checksumstable:
This uses thept-table-checksum --slave-user=pt-table-checks --slave-password=auW2phohsieyslave-userparameter correctly and finishes successfully. - Run
pt-table-syncon the master with theslave-userparameter to sync the slaves to the master:
This fails with:pt-table-sync --replicate=percona.checksums --dry-run localhost
Because it's not using theCannot connect to h=10.4.28.78slave-userparameter to connect to the slave.
Please merge this! I just wasted hours trying to find out why setting the "--slave-user" option has no effect.
Currently, you can provide a replica username and password as part of the DSN.
Other issues with the fix are:
- options take precedence even if user and password defined in the dsns table. This could cause issues if users have, say, 10 replicas with the same user/password pairs and two with different ones.
- you access tool options in the library code
- there is no test case.
There is also a similar PR at https://github.com/percona/percona-toolkit/pull/425
We will consider similar https://github.com/percona/percona-toolkit/pull/425 instead.