Reading timeline from pg_control on replication slave

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Reading timeline from pg_control on replication slave
Date: 2017-10-27 08:04:28
Message-ID: BF2AD4A8-E7F5-486F-92C8-A6959040DEB6@yandex-team.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, hackers!

I'm working on backups from replication salve in WAL-G [0]
Backups used to use result of pg_walfile_name(pg_start_backup(...)). Call to pg_start_backup() works nice, but "pg_walfile_name() cannot be executed during recovery."
This function has LSN as argument and reads TimeLineId from global state.
So I made a function[1] that, if on replica, reads timeline from pg_control file and formats WAL file name as is it was produces by pg_wal_filename(lsn).

Are there any serious dangers? Obviously, this hack is not crisp and clear. Is the risk of reading stale timeline really a problem? By reading TimeLineId from file I'm fighting those precautions in pg_walfile_name(..) which were implemented for a reason, I guess.

Thanks for reading this. I'll be happy to hear any comments on the matter.

[0] https://github.com/wal-g/wal-g/pull/32
[1] https://github.com/wal-g/wal-g/pull/32/files#diff-455316c14fb04c9f9748a0798ad151d9R158

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rajkumar Raghuwanshi 2017-10-27 08:05:39 Re: path toward faster partition pruning
Previous Message Robert Haas 2017-10-27 07:44:36 Re: Re: Is anything preventing us from allowing write to foreign tables from standby?