Re: Add timeline to partial WAL segments - Mailing list pgsql-hackers

From David Steele
Subject Re: Add timeline to partial WAL segments
Date
Msg-id c54fb93a-21cf-83c7-f44f-09b80327868a@pgmasters.net
Whole thread Raw
In response to Re: Add timeline to partial WAL segments  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Add timeline to partial WAL segments  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
On 12/21/18 2:10 AM, Michael Paquier wrote:
> On Thu, Dec 20, 2018 at 02:13:01PM +0200, David Steele wrote:
>> Or perhaps just always add the timeline to the .partial?  That way it
>> doesn't need to be renamed later.  Also, there would be a consistent name,
>> rather than sometimes .partial, sometimes .<timelime>.partial.
> 
> Hm.  A renaming still needs to happen afterwards anyway, no?  When a
> segment is created with a given name pg_receivewal cannot know if the
> segment it is working on will be the last partial segment of a given
> timeline.  And what would be changed in the segment name is the addition
> of the new TLI, not the previous one.

I was thinking the file would only be renamed on successful completion. 
Suppose we are on timeline 1 pg_receivewal would be writing to:

000000010000000100000001.00000001.partial

If the WAL segment is never completed (server crashes, etc.) it would 
keep that name.

If a cluster is promoted it would archive:

000000010000000100000001.00000002.partial

And then pg_receivewal would start writing on:

000000020000000100000001.00000002.partial

When that segment successfully completes it would be renamed by 
pg_receivewal to 000000020000000100000001.

In short, the *initial* name of the WAL file is set to what it should be 
if it doesn't complete so we don't need to run around and try to rename 
files on failure.  Only on success do we need to rename.

Sound plausible?

-- 
-David
david@pgmasters.net


pgsql-hackers by date:

Previous
From: denty
Date:
Subject: Re: Implementing Incremental View Maintenance
Next
From: David Steele
Date:
Subject: Re: could recovery_target_timeline=latest be the default in standbymode?