Re: [HACKERS] Adding hook in BufferSync for backup purposes - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: [HACKERS] Adding hook in BufferSync for backup purposes
Date
Msg-id 20170807115118.ucpvxof57gs5vtae@alvherre.pgsql
Whole thread Raw
In response to [HACKERS] Adding hook in BufferSync for backup purposes  (Андрей Бородин <x4mmm@yandex-team.ru>)
Responses Re: [HACKERS] Adding hook in BufferSync for backup purposes  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Андрей Бородин wrote:

> ==What==
> I propose to add hook inside BufferSync() function it inform extensions that we
> are going to write pages to disk. Please see patch attached. I pass a timestamp
> of the checkpoint, but it would be good if we could also pass there number of
> checkpoint or something like this to ensure that some checkpoints were not lost
> (this could yield malformed backups).
>  
> ==State==
> This is just an idea to discuss, I could not find something like this in
> pgsql-hackers as for now. Neither I could find similar hooks in the code.
> Is this hook sufficient to implement page tracking for differential backups?
> I’m not sure, but seems like it is.

Hi,

I remember discussing the topic of differential base-backups with
somebody (probably Marco and Gabriele).  The idea we had was to have a
new relation fork which stores an LSN for each group of pages,
indicating the LSN of the newest change to those pages.  The backup tool
"scans" the whole LSN fork, and grabs images of all pages that have LSNs
newer than the one used for the previous base backup.

(I think your sketch above should use LSNs rather than timestamps).

I suppose your hook idea lets you implement the LSN fork in an
extension, rather than having it be part of core.  The idea of hooking
onto BufferSync makes me uneasy, though -- like it's not the correct
place to do it.  I think it should be at the point where the buffer is
modified (i.e. when WAL is written) rather than when it's checkpointed
out.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: [HACKERS] expanding inheritance in partition bound order
Next
From: Ashutosh Sharma
Date:
Subject: Re: [HACKERS] Page Scan Mode in Hash Index