Skip to content

Commit

Permalink
Merge pull request #48 from gregorg/fix_pg_replication_lag
Browse files Browse the repository at this point in the history
fix postgresql 10 replication lag
  • Loading branch information
gregorg authored Jun 5, 2018
2 parents d33f8d3 + e9f7ba5 commit 974d8d6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Driver/Connection/MasterSlavesConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function setSlaveStatus(bool $running, ?int $delay) {
private function getSlaveStatus() {
if (stripos($this->wrappedDriver->getName(), 'pgsql') !== false) {
try {
$sss = $this->wrappedConnection()->query("SELECT CASE WHEN pg_last_xlog_receive_location() IS NULL THEN NULL WHEN pg_last_xlog_receive_location() = pg_last_xlog_replay_location() THEN '00:00:00' ELSE now() - pg_last_xact_replay_timestamp() END AS replication_lag")->fetch();
$sss = $this->wrappedConnection()->query("SELECT now() - pg_last_xact_replay_timestamp() AS replication_lag")->fetch();
return $this->setSlaveStatus(true, $sss['replication_lag']);
} catch (\Exception $e) {
return $this->setSlaveStatus(false, null);
Expand Down

0 comments on commit 974d8d6

Please sign in to comment.