Issues with WAL Timelines on follower

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey, 

I'm happy postgresql user. Today I want to achieve a SQL query to add in our health check system.  Sometimes we change our leader server in a hot-standby platform, so the timeline changes and the followers stop to receive wal data under timeline problems. 

This is the log message: 

`timeline 4 forked off current database system timeline 3 before current recovery point 0/84000098`


If I restart, this is going to work correctly. But I want to make an SQL query (in the follower) to now if replication is working or not. Nowadays I'm using this: 

```
SELECT
    CASE
        WHEN pg_last_xlog_receive_location() = pg_last_xlog_replay_location() THEN 0
        ELSE EXTRACT (EPOCH FROM now() - pg_last_xact_replay_timestamp())::INTEGER
    END
AS replication_lag;
```

So, if the timeline is different, the result of the lag in replication is always 0. So I can't monitor that the server is in another TL. 

Any idea? I tried pg_xlogfile_name() but can't be used during the recovery. Any idea? 

PS: From the leader and pg_stat_replication can't get that it's not sync too. 

Regards

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux