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
signature.asc
Description: PGP signature