Bug #73171 mysqlfailover doesn't unregister when running --daemon=stop
Submitted: 2 Jul 2014 9:32 Modified: 27 Sep 2016 13:16
Reporter: Stephane Combaudon Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Utilities Severity:S1 (Critical)
Version:1.4.3, 1.6.4 OS:Linux
Assigned to: CPU Architecture:Any

[2 Jul 2014 9:32] Stephane Combaudon
Description:
When mysqlfailover runs in the background with --daemon=start, it registers on the master as expected.
But when you stop the daemon with --daemon=stop, it doesn't unregister.

Checked with mysqlfailover 1.4.3, on Ubuntu 14.04 with 2 instances of MySQL 5.6.19.

How to repeat:
1) Create a master-slave setup with GTID replication. The master will run on localhost:13001 and the slave on localhost:13002

2) Run mysqlfailover as a daemon, for instance:
$ mysqlfailover --master=root@localhost:13001 --discover-slaves-login=root auto --daemon=start --log=/tmp/mysqlfailover.log

3) mysqlfailover is correctly registered on the master:
mysql> select * from mysql.failover_console;
+-----------+-------+
| host      | port  |
+-----------+-------+
| localhost | 13001 |
+-----------+-------+

4) Stop mysqlfailover:
$ mysqlfailover --daemon=stop

5) The tool is still registered on the master:
mysql> select * from mysql.failover_console;
+-----------+-------+
| host      | port  |
+-----------+-------+
| localhost | 13001 |
+-----------+-------+
[27 Sep 2016 13:16] Shane Bester
Verified.. with 1.6.4.    Here is the log file:

2016-09-23 14:50:33 PM INFO MySQL Utilities mysqlfailover version 1.6.4.
2016-09-23 14:50:33 PM INFO Server '127.0.0.1:3306' is using MySQL version 5.6.33-log.
2016-09-23 14:50:33 PM INFO Discovering slaves for master at 127.0.0.1:3306
2016-09-23 14:50:33 PM INFO Checking privileges.
2016-09-23 14:50:33 PM INFO Unregistering existing instances from slaves.
2016-09-23 14:50:33 PM INFO Registering instance on master.
2016-09-23 14:50:33 PM INFO Failover daemon started.
2016-09-23 14:50:33 PM INFO Failover mode = auto.
2016-09-23 14:50:37 PM INFO Master Information
2016-09-23 14:50:37 PM INFO Binary Log File: localhost-bin.000001, Position: 151, Binlog_Do_DB: N/A, Binlog_Ignore_DB: N/A
2016-09-23 14:50:37 PM INFO GTID Executed Set: None
2016-09-23 14:50:37 PM INFO Getting health for master: 127.0.0.1:3306.
2016-09-23 14:50:37 PM INFO Health Status:
2016-09-23 14:50:37 PM INFO host: 127.0.0.1, port: 3306, role: MASTER, state: UP, gtid_mode: ON, health: OK, version: 5.6.33-log, master_log_file: localhost-bin.000001, master_log_pos: 151, IO_Thread: , SQL_Thread: , Secs_Behind: , Remaining_Delay: , IO_Error_Num: , IO_Error: , SQL_Error_Num: , SQL_Error: , Trans_Behind:
2016-09-23 14:50:44 PM INFO MySQL Utilities mysqlfailover version 1.6.4.
2016-09-23 14:50:44 PM INFO Server '127.0.0.1:3306' is using MySQL version 5.6.33-log.
2016-09-23 14:50:44 PM INFO Discovering slaves for master at 127.0.0.1:3306
2016-09-23 14:50:44 PM INFO Unregistering instance on master.

But,  still registered:
mysql> select * from mysql.failover_console;
+-----------+------+
| host      | port |
+-----------+------+
| 127.0.0.1 | 3306 |
+-----------+------+
1 row in set (0.00 sec)

Subsequent startups of mysqlfailover will now fail to set auto/elect mode:

Starting failover daemon...
Multiple instances of failover daemon found for master 127.0.0.1:3306.
If this is an error, restart the daemon with --force.
Failover mode changed to 'FAIL' for this instance.
Daemon will start in 10 seconds.