One of the die in pt-heartbeat cannot capture the error code and exit, which lead to It still try to connect even though the master stop
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
pt-heartbeat 2.2.19
here is the command before i stop the mysql server
[root@localhost ~]# pt-heartbeat --update -h 192.168.244.20 -u monitor -p monitor123 -D test
the i stop the server
# service mysqld stop
then the command output this with stop
[root@localhost ~]# pt-heartbeat --update -h 192.168.244.20 -u monitor -p monitor123 -D test
MySQL server has gone away [for Statement "SHOW MASTER STATUS"]
Can't connect to MySQL server on '192.168.244.20' (111)
Can't connect to MySQL server on '192.168.244.20' (111)
Can't connect to MySQL server on '192.168.244.20' (111)
Can't connect to MySQL server on '192.168.244.20' (111)
...
i check the code
# vim /usr/local/
2818 my $dbh;
2819 while ( !$dbh && $tries-- ) {
2820 PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
2821 join(', ', map { "$_=>$defaults-
2822
2823 $dbh = eval { DBI->connect(
2824
2825 if ( !$dbh && $EVAL_ERROR ) {
2826 if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
2827 die "Cannot connect to MySQL because the Perl DBD::mysql module is "
2828 . "not installed or not found. Run 'perl -MDBD::mysql' to see "
2829 . "the directories that Perl searches for DBD::mysql. If "
2830 . "DBD::mysql is not installed, try:\n"
2831 . " Debian/Ubuntu apt-get install libdbd-
2832 . " RHEL/CentOS yum install perl-DBD-MySQL\n"
2833 . " OpenSolaris pgk install pkg:/SUNWapu13d
2834 }
2835 elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
2836 PTDEBUG && _d('Going to try again without utf8 support');
2837 delete $defaults-
2838 }
2839 if ( !$tries ) {
2840 die $EVAL_ERROR;
2841 }
2842 }
obviously,if the connect failed two times,then the $tries would be 0,and trigger the die,then the script quit.
but in fact,it did not quit,and still reconnect,which leaded to the memory used by the script slowly increased but steadily.
then i change the code,in line 2840,like this
die "just_test:
the i repeat this test
# service mysqld start
[root@localhost ~]# pt-heartbeat --update -h 192.168.244.20 -u monitor -p monitor123 -D test
# service mysqld stop
then we can found the script quit
# pt-heartbeat --update -h 192.168.244.20 -u monitor -p monitor123 -D test
MySQL server has gone away [for Statement "SHOW MASTER STATUS"]
just_test:DBI connect(
on '192.168.244.20' (111) at /usr/local/
i believe i could be bug,and i also have a question,why the unsuccessful connection can lead to memory increase.
Thanks
Thank you for the report.
According to the documentation at "pt-heartbeat will try to reconnect if the connection has an error, but will not retry if it can’t get a connection when it first starts.", so option tries is related to startup only.
So I can verify this as feature request only: "add option, telling to stop reconnecting to master after N failed connection attempts"