php-mysql-replication icon indicating copy to clipboard operation
php-mysql-replication copied to clipboard

GTID replication Return value of MySQLReplication\BinLog\BinLogCurrent::getBinFileName() must be of the type string, null returned

Open antonrubtsov opened this issue 4 years ago • 2 comments

System details:

  • Operating System: ubuntu:18.04
  • PHP Version: <PHP 7.2.24-0ubuntu0.18.04.9 (cli)>
  • php-mysql-replication Version: <7.0.1>
  • *mysql version (SELECT VERSION();): <5.7.35-38-log PERCONA>

Problem

$eventInfo->getBinLogCurrent()->getBinFileName(); falls with Exception 'TypeError' with message 'Return value of MySQLReplication\BinLog\BinLogCurrent::getBinFileName() must be of the type string, null returned'

Steps required to reproduce the problem.

Starting conditions:

CREATE DATABASE test;
CREATE TABLE `test`.`test_table`
(
    `id`         bigint(20) NOT NULL AUTO_INCREMENT,
    `is_clicked` tinyint(1) NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8;

Insert 1 string: insert into test.test_table (id, is_clicked) values (1,0); And run replication with GTID = ''

Reproducing error:

  1. update test.test_table set is_clicked = abs(is_clicked-1) where id = 1;
show master status ;
binlog.000005,21529,,,2b172ed7-1ad8-11ec-8570-0242ac12000e:1-100

var_dump($eventInfo->getBinlogCurrent);

  class MySQLReplication\BinLog\BinLogCurrent#85 (4) {
    private $binLogPosition =>
    int(21498)
    private $binFileName =>
    string(13) "binlog.000005"
    private $gtid =>
    string(40) "2b172ed7-1ad8-11ec-8570-0242ac12000e:100"
    private $mariaDbGtid =>
    NULL
  }
  1. Restart replication with GTID 2b172ed7-1ad8-11ec-8570-0242ac12000e:1-100
class MySQLReplication\BinLog\BinLogCurrent#85 (4) {
  private $binLogPosition =>
  int(21498)
  private $binFileName =>
  NULL
  private $gtid =>
  string(40) "2b172ed7-1ad8-11ec-8570-0242ac12000e:100"
  private $mariaDbGtid =>
  NULL
}

Expected Result.

  • binFileName = binlog.000005

Actual Result.

  • binFileName = NULL

Question

Is it a bug?

antonrubtsov avatar Oct 03 '21 09:10 antonrubtsov

krowinski/php-mysql-replication/src/MySQLReplication/BinLog/BinLogSocketConnect.php:165

if ('' !== Config::getGtid()) {
	$this->setBinLogDumpGtid();
	$this->setBinLogDump(); // This change fixes the problem, but i'm not sure that it's correct.
} else {
         $this->setBinLogDump();
}

This change fixes the problem, but i'm not sure that it's correct.

antonrubtsov avatar Oct 03 '21 09:10 antonrubtsov

If you use gitid it will set just gtid if you use binlog file it will set binlog file Its intended but not changeable. I will change this in next version.

krowinski avatar Jan 30 '24 10:01 krowinski