diff --git a/src/MySQLReplication/BinLog/BinLogSocketConnect.php b/src/MySQLReplication/BinLog/BinLogSocketConnect.php index 9fd34f2..5fc24fd 100644 --- a/src/MySQLReplication/BinLog/BinLogSocketConnect.php +++ b/src/MySQLReplication/BinLog/BinLogSocketConnect.php @@ -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'); } diff --git a/src/MySQLReplication/Repository/MySQLRepository.php b/src/MySQLReplication/Repository/MySQLRepository.php index ee7a779..07a3a8a 100644 --- a/src/MySQLReplication/Repository/MySQLRepository.php +++ b/src/MySQLReplication/Repository/MySQLRepository.php @@ -57,21 +57,22 @@ 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'); + var_dump($this->getVersion()); + 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,