diff options
author | Michael Paquier <michael@paquier.xyz> | 2021-07-20 12:12:51 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2021-07-20 12:12:51 +0900 |
commit | fb2b86015a9f3e2e59ddbb59e18cda98363cbd7b (patch) | |
tree | 450255c1dbbc1fdb8a3d5f50247cc469310c3837 /src/bin/pg_basebackup/walmethods.h | |
parent | ce413eba411633c5c5c9e326d6d0313c9764c711 (diff) | |
download | postgresql-fb2b86015a9f3e2e59ddbb59e18cda98363cbd7b.tar.gz postgresql-fb2b86015a9f3e2e59ddbb59e18cda98363cbd7b.zip |
Fix some issues with WAL segment opening for pg_receivewal --compress
The logic handling the opening of new WAL segments was fuzzy when using
--compress if a partial, non-compressed, segment with the same base name
existed in the repository storing those files. In this case, using
--compress would cause the code to first check for the existence and the
size of a non-compressed segment, followed by the opening of a new
compressed, partial, segment. The code was accidentally working
correctly on most platforms as the buildfarm has proved, except
bowerbird where gzflush() could fail in this code path. It is wrong
anyway to take the code path used pre-padding when creating a new
partial, non-compressed, segment, so let's fix it.
Note that this issue exists when users mix successive runs of
pg_receivewal with or without compression, as discovered with the tests
introduced by ffc9dda.
While on it, this refactors the code so as code paths that need to know
about the ".gz" suffix are down from four to one in walmethods.c, easing
a bit the introduction of new compression methods. This addresses a
second issue where log messages generated for an unexpected failure
would not show the compressed segment name involved, which was
confusing, printing instead the name of the non-compressed equivalent.
Reported-by: Georgios Kokolatos
Discussion: https://postgr.es/m/YPDLz2x3o1aX2wRh@paquier.xyz
Backpatch-through: 10
Diffstat (limited to 'src/bin/pg_basebackup/walmethods.h')
-rw-r--r-- | src/bin/pg_basebackup/walmethods.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bin/pg_basebackup/walmethods.h b/src/bin/pg_basebackup/walmethods.h index 9a661c673cc..f9bd59d0cdc 100644 --- a/src/bin/pg_basebackup/walmethods.h +++ b/src/bin/pg_basebackup/walmethods.h @@ -53,6 +53,15 @@ struct WalWriteMethod ssize_t (*get_file_size) (const char *pathname); /* + * Return the name of the current file to work on, without the base + * directory. This is useful for logging. + */ + char *(*get_file_name) (const char *pathname, const char *temp_suffix); + + /* Return the level of compression */ + int (*compression) (void); + + /* * Write count number of bytes to the file, and return the number of bytes * actually written or -1 for error. */ |