Re: pg_receivewal fail to streams when the partial file to write is not fully initialized present in the wal receiver directory

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_receivewal fail to streams when the partial file to write is not fully initialized present in the wal receiver directory
Date: 2022-01-03 07:56:39
Message-ID: YdKsN5N2+TpHFu5C@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jan 02, 2022 at 09:27:43PM -0800, SATYANARAYANA NARLAPURAM wrote:
> I noticed that pg_receivewal fails to stream when the partial file to write
> is not fully initialized and fails with the error message something like
> below. This requires an extra step of deleting the partial file that is not
> fully initialized before starting the pg_receivewal. Attaching a simple
> patch that creates a temp file, fully initialize it and rename the file to
> the desired wal segment name.

Are you referring to the pre-padding when creating a new partial
segment, aka when we write chunks of XLOG_BLCKSZ full of zeros until
the file is fully created? What kind of error did you see? I guess
that a write() with ENOSPC would be more likely, but you got a
different problem? I don't disagree with improving such cases, but we
should not do things so as there is a risk of leaving behind an
infinite set of segments in case of repeated errors, and partial
segments are already a kind of temporary file.

- if (dir_data->sync)
+ if (shouldcreatetempfile)
+ {
+ if (durable_rename(tmpsuffixpath, targetpath) != 0)
+ {
+ close(fd);
+ unlink(tmpsuffixpath);
+ return NULL;
+ }
+ }

durable_rename() does a set of fsync()'s, but --no-sync should not
flush any data.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2022-01-03 08:00:13 Re: Use MaxLockMode in lock methods initialization
Previous Message Michael Paquier 2022-01-03 07:47:17 Re: Confused comment about drop replica identity index