| From: | Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> |
|---|---|
| To: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: pg_rewind: Skip vanished source files during traversal |
| Date: | 2026-07-06 14:45:56 |
| Message-ID: | CAJTYsWUt+7PB6kAiO3YM9XHSr-eZkRTwTgC+PU5Vd+oVhZSkUg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi.
On Mon, 6 Jul 2026 at 18:49, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
> On 28/05/2026 09:01, Ayush Tiwari wrote:
> >
> > Does this interpretation make sense, or is there a reason we should
> continue
> > processing the entry after ENOENT?
>
> So, the full comment is:
>
> > /*
> > * File doesn't exist anymore. This is ok, if the new primary
> > * is running and the file was just removed. If it was a data
> > * file, there should be a WAL record of the removal. If it
> > * was something else, it couldn't have been anyway.
> > *
> > * TODO: But complain if we're processing the target dir!
>
> That explanation doesn't make a whole lot of sense to me. We don't
> support running pg_rewind on a source directory while the source server
> is running. We do support the "connection" mode on a running server, but
> that doesn't use this function. (And it's not clear what the "couldn't
> have been anyway" means here. Mea culpa, I wrote that comment)
> And it would indeed be nice to implement that TODO. But AFAICS we should
> just always throw an error here. It's not OK if a file goes missing in
> the target dir, and we don't expect it in the source dir either, because
> the server shouldn't be running.
>
Ahh, yes you are right. I'd only been looking at the uninitialized
fst.st_mode read (lstat() fails, but the code still inspects st_mode),
and continue was the minimal way to avoid it.
In supported paths, recurse_dir() only runs on a stopped local source
data directory or the target data directory; the running-source case
goes through libpq_traverse_files(). So a vanished file isn't expected
there, and erroring would be the better fix.
v2 attached: it just pg_fatal()s on lstat() failure, dropping the ENOENT
special case and the TODO.
Regards,
Ayush
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-pg_rewind-Error-out-on-unexpectedly-vanished-file.patch | application/octet-stream | 2.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2026-07-06 14:51:36 | Re: postgres_fdw: fix cumulative stats after imported foreign-table stats |
| Previous Message | Alexander Pyhalov | 2026-07-06 14:42:42 | Re: Asynchronous MergeAppend |