yoshinorim / mha4mysql-node

Development tree of Master High Availability Manager and tools for MySQL (MHA), Node (MySQL Server) part
http://code.google.com/p/mysql-master-ha/
GNU General Public License v2.0
398 stars 198 forks source link

purge_relay_logs fails on MariaDB 10.0 #17

Closed GeoffMontee closed 9 years ago

GeoffMontee commented 9 years ago

In MariaDB 10.0, purge_relay_logs fails because the relay_log_info_repository variable doesn't exist.

[gmontee@slave ~]$ mysql -u root --execute="SHOW SLAVE STATUS\G"
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.1.45
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: master-bin.000022
          Read_Master_Log_Pos: 359
               Relay_Log_File: slave-relay-bin.000002
                Relay_Log_Pos: 647
        Relay_Master_Log_File: master-bin.000022
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 359
              Relay_Log_Space: 944
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
                   Using_Gtid: Slave_Pos
                  Gtid_IO_Pos: 1-1-34937,0-1-34,2-1-34804
[gmontee@slave ~]$ ls -l /var/lib/mysql/*relay*
-rw-rw----. 1 mysql mysql  592 Feb 26 11:27 /var/lib/mysql/localhost-relay-bin.000004
-rw-rw----. 1 mysql mysql 1652 Feb 26 17:23 /var/lib/mysql/localhost-relay-bin.000005
-rw-rw----. 1 mysql mysql   58 Feb 26 11:27 /var/lib/mysql/localhost-relay-bin.index
-rw-rw----. 1 mysql mysql   65 May 26 16:58 /var/lib/mysql/relay-log.info
-rw-rw----. 1 mysql mysql  297 May 26 16:58 /var/lib/mysql/slave-relay-bin.000001
-rw-rw----. 1 mysql mysql  647 May 26 16:58 /var/lib/mysql/slave-relay-bin.000002
-rw-rw----. 1 mysql mysql   50 May 26 16:58 /var/lib/mysql/slave-relay-bin.index
[gmontee@slave ~]$ sudo purge_relay_logs --user=root --disable_relay_log_purge
2015-05-26 17:51:35: purge_relay_logs script started.
DBD::mysql::st execute failed: Unknown system variable 'relay_log_info_repository' at /usr/share/perl5/vendor_perl/MHA/SlaveUtil.pm line 58.
[gmontee@slave ~]$ ls -l /var/lib/mysql/*relay*
-rw-rw----. 1 mysql mysql  592 Feb 26 11:27 /var/lib/mysql/localhost-relay-bin.000004
-rw-rw----. 1 mysql mysql 1652 Feb 26 17:23 /var/lib/mysql/localhost-relay-bin.000005
-rw-rw----. 1 mysql mysql   58 Feb 26 11:27 /var/lib/mysql/localhost-relay-bin.index
-rw-rw----. 1 mysql mysql   65 May 26 16:58 /var/lib/mysql/relay-log.info
-rw-rw----. 1 mysql mysql  297 May 26 16:58 /var/lib/mysql/slave-relay-bin.000001
-rw-rw----. 1 mysql mysql  647 May 26 16:58 /var/lib/mysql/slave-relay-bin.000002
-rw-rw----. 1 mysql mysql   50 May 26 16:58 /var/lib/mysql/slave-relay-bin.index

This also appears to fail even if a path to the relay log info file is explicitly defined:

[gmontee@slave ~]$ sudo purge_relay_logs --user=root --disable_relay_log_purge --relay_log_info=/var/lib/mysql/relay-log.info 
2015-05-26 17:52:29: purge_relay_logs script started.
DBD::mysql::st execute failed: Unknown system variable 'relay_log_info_repository' at /usr/share/perl5/vendor_perl/MHA/SlaveUtil.pm line 58.
[gmontee@slave ~]$ ls -l /var/lib/mysql/*relay*
-rw-rw----. 1 mysql mysql  592 Feb 26 11:27 /var/lib/mysql/localhost-relay-bin.000004
-rw-rw----. 1 mysql mysql 1652 Feb 26 17:23 /var/lib/mysql/localhost-relay-bin.000005
-rw-rw----. 1 mysql mysql   58 Feb 26 11:27 /var/lib/mysql/localhost-relay-bin.index
-rw-rw----. 1 mysql mysql   65 May 26 16:58 /var/lib/mysql/relay-log.info
-rw-rw----. 1 mysql mysql  297 May 26 16:58 /var/lib/mysql/slave-relay-bin.000001
-rw-rw----. 1 mysql mysql  647 May 26 16:58 /var/lib/mysql/slave-relay-bin.000002
-rw-rw----. 1 mysql mysql   50 May 26 16:58 /var/lib/mysql/slave-relay-bin.index

The check that's failing appears to happen here:

https://github.com/yoshinorim/mha4mysql-node/blob/ef26bdeeeb16c4c1c5e37bdaa276d118ffdd85e7/bin/purge_relay_logs#L204

GeoffMontee commented 9 years ago

The reason that this appears to be failing is because RaiseError is set to 1 in the DBI connection string here:

https://github.com/yoshinorim/mha4mysql-node/blob/ef26bdeeeb16c4c1c5e37bdaa276d118ffdd85e7/bin/purge_relay_logs#L187

If I change the connection string to this:

    my $dbh =
      DBI->connect( $dsn, $opt{user}, $opt{password},
      { PrintError => 1, RaiseError => 0 } );

Then it works:

[gmontee@slave ~]$ sudo ./purge_relay_logs --user=root --disable_relay_log_purge --relay_log_info=/var/lib/mysql/relay-log.info 
2015-05-26 20:04:36: purge_relay_logs script started.
DBD::mysql::st execute failed: Unknown system variable 'relay_log_info_repository' at /usr/share/perl5/vendor_perl/MHA/SlaveUtil.pm line 58.
DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at /usr/share/perl5/vendor_perl/MHA/SlaveUtil.pm line 59.
 Found relay_log.info: /var/lib/mysql/relay-log.info
 Opening /var/lib/mysql/slave-relay-bin.000002 ..
 Opening /var/lib/mysql/slave-relay-bin.000003 ..
 Executing SET GLOBAL relay_log_purge=1; FLUSH LOGS; sleeping a few seconds so that SQL thread can delete older relay log files (if it keeps up); SET GLOBAL relay_log_purge=0; .. ok.
2015-05-26 20:04:39: All relay log purging operations succeeded.