Skip to content
7 changes: 6 additions & 1 deletion src/MySQLReplication/BinLog/BinLogSocketConnect.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,14 @@ private function getBinlogStream(): void
$this->executeSQL('SET @master_binlog_checksum = @@global.binlog_checksum');
}


if ($this->config->heartbeatPeriod > 0.00) {
// master_heartbeat_period is in nanoseconds
$this->executeSQL('SET @master_heartbeat_period = ' . $this->config->heartbeatPeriod * 1000000000);
if(version_compare($this->repository->getVersion(),"8.4.0")>=0){
$this->executeSQL('SET @source_heartbeat_period = ' . $this->config->heartbeatPeriod * 1000000000);
}else{
$this->executeSQL('SET @master_heartbeat_period = ' . $this->config->heartbeatPeriod * 1000000000);
}

$this->logger->info('Heartbeat period set to ' . $this->config->heartbeatPeriod . ' seconds');
}
Expand Down
20 changes: 10 additions & 10 deletions src/MySQLReplication/Repository/MySQLRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,21 @@ public function isCheckSum(): bool

public function getVersion(): string
{
$r = '';
$versions = $this->getConnection()
->fetchAllAssociative('SHOW VARIABLES LIKE "version%"');

foreach ($versions as $version) {
$r .= $version['Value'];
}
$res = $this->getConnection()
->fetchAssociative('SHOW VARIABLES LIKE "version"');

return $r;
return $res['Value']??"";
}

public function getMasterStatus(): MasterStatusDTO
{
$data = $this->getConnection()
->fetchAssociative('SHOW MASTER STATUS');
if(version_compare($this->getVersion(),"8.4.0")>=0){
$data = $this->getConnection()
->fetchAssociative('SHOW BINARY LOG STATUS');
}else{
$data = $this->getConnection()
->fetchAssociative('SHOW MASTER STATUS');
}
if (empty($data)) {
throw new BinLogException(
MySQLReplicationException::BINLOG_NOT_ENABLED,
Expand Down