Re: pg_rewind in contrib - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: pg_rewind in contrib
Date
Msg-id 54FF6CE2.5000009@iki.fi
Whole thread Raw
In response to Re: pg_rewind in contrib  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: pg_rewind in contrib
List pgsql-hackers
On 03/10/2015 07:46 AM, Amit Kapila wrote:
> On Mon, Mar 9, 2015 at 7:32 PM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>>
>> Attached is a new patch version, fixing all the little things you listed.
> I believe this is pretty much ready for commit. I'm going to read it
> through myself one more time before committing, but I don't have anything
> mind now that needs fixing anymore. I just pushed the change to split
> dbcommands.h into dbcommands.h and dbcommands_xlog.h, as that seems like a
> nice-to-have anyway.
>>
>
> Few assorted comments:
>
> 1.
> +    <step>
> +     <para>
> +      Copy all those changed blocks from the new cluster to the old
> cluster.
> +
> </para>
> +    </step>
>
> Isn't it possible incase of async replication that old cluster has
> some blocks which new cluster doesn't have, what will it do
> in such a case?

Sure, that's certainly possible. If the source cluster doesn't have some 
blocks that exist in the target, IOW a file in the source cluster is 
shorter than the same file in the target, that means that the relation 
was truncated in the source. pg_rewind will truncate the file in the 
target to match the source's size, although that's not strictly 
necessary as there will also be a WAL record in the source about the 
truncation. That will be replayed on the first startup after pg_rewind 
and would do the truncation anyway.

> I have tried to test some form of such a case and it seems to be
> failing with below error:
>
> pg_rewind.exe -D ..\..\Data\ --source-pgdata=..\..\Database1
> The servers diverged at WAL position 0/16DE858 on timeline 1.
> Rewinding from last common checkpoint at 0/16B8A70 on timeline 1
>
> could not open file "..\..\Data\/base/12706/16391" for truncation: No such
> file
> or directory
> Failure, exiting

Hmm, could that be just because of the funny business with the Windows 
path separators? Does it work if you use "-D ..\..\Data" instead, 
without the last backslash?

> +# To run a test, the test script (in t/ subdirectory) calls the functions
>
> What do you mean by t/ subdirectory?

There is a directory, "src/bin/pg_rewind/t", which contains the 
regression tests.

- Heikki



pgsql-hackers by date:

Previous
From: Rahila Syed
Date:
Subject: Re: [REVIEW] Re: Compression of full-page-writes
Next
From: Jim Nasby
Date:
Subject: Re: proposal: searching in array function - array_position