Re: pg_rewind fails on Windows where tablespaces are used

Andrew Dunstan <andrew@dunslane.net>

From: Andrew Dunstan <andrew@dunslane.net>
To: Michael Paquier <michael@paquier.xyz>, Chris Travers <chris.travers@stormatics.tech>
Cc: Farooq Rashed <farooq.rashed@desc.gov.ae>, pgsql-bugs@lists.postgresql.org
Date: 2024-07-09T16:01:17Z
Lists: pgsql-bugs

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix readlink() for non-PostgreSQL junction points on Windows.

  2. Fix stat() for recursive junction points on Windows.

  3. Fix pg_rewind with in-place tablespaces when source is remote

  4. Make unlink() work for junction points on Windows.

  5. Use in-place tablespaces in regression test.

On 2024-06-04 Tu 12:53 AM, Michael Paquier wrote:
> On Wed, May 08, 2024 at 03:02:21PM +0700, Chris Travers wrote:
>> Setup is PostgreSQL on Windows with a tablespace on a separate drive.  When
>> I go to run pg_rewind it consistently fails with the following error:
> (Chris has poked me regarding this issue last week in Vancouver.)
>
>> pg_rewind: servers diverged at WAL location 39B/7EC6F60 on timeline 2
>> pg_rewind: rewinding from last common checkpoint at 39B/7E8E3F8 on timeline
>> 2
>> pg_rewind: error: file "pg_tblspc/34244696" is of different type in source
>> and target
>>
>> The file is confirmed to be a JUNCTION to the correct location on both the
>> source and target.  So the error looks like a problem interacting with
>> Windows and detecting JUNCTION types in this case.


An EDB customer has encountered the same issue. They are not using 
in-place tablespaces.

I have reproduced this problem on release 15, not using an in-place 
tablespace.

The solution I came up with was to backpatch commits c5cb8f3b, 387803d8 
and 5fc88c5d53.

I don't think we need to do anything relating to in-place tablespaces. 
These are documented as a developer only option and not for production.

The only question in my mind is whether those patches should be 
backpatched. It's a couple of hundred lines, and I think it's safe, but 
I'd welcome other opinions. If we are going to backpatch them we should 
also look at adding to adding tests for use of tablespaces with 
pg_rewind on the back branches. Ideally we'd get this done in time for 
the next maintenance release.


cheers


andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com