Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
antonrubtsov opened this issue Oct 3, 2021 · 2 comments
Assignees
Labels

Comments

@antonrubtsov
Copy link

antonrubtsov commented Oct 3, 2021

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
Copy link
Author

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.

@krowinski krowinski self-assigned this Oct 26, 2021
@krowinski
Copy link
Owner

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 krowinski added the todo label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants