1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-06-20 01:17:49 +02:00

4839 Commits

Author SHA1 Message Date
David Steele 5cc9d25817 Remove unused pathSync parameter in SFTP storage driver.
The SFTP storage driver did not set the pathSync method but had logic to see if pathSync was set. This led to some tortured tests since pathSync had to be injected into the interface after the storage object had been created.

Remove the pathSync parameter from storageWriteSftpNew() and also remove related tests.
2025-09-16 14:58:49 +02:00
David Steele 9c7f064864 Unnest HTTP/TLS/socket timeouts.
These timeouts were nested, i.e. an error in the socket connection would also retry in the TLS and HTTP layers. This led to a multiplying effect such that it took nine minutes to fully timeout with the default io-timeout of 60 seconds.

A fix for this was attempted in 5314dbff but it reduced retries by too much and had to be reverted in fa5b2d44.

Instead fix by moving connection attempts to the lower layer (e.g. TLS -> socket) out of the exception block but leave it within the retry loop. So, for example, if the socket connection fails after retries then the error will not be retried by TLS. But if the TLS session fails the socket will be reconnected.
2025-09-05 11:42:00 -04:00
Zsolt Parragi adc5e5b23b Fix possible segfault in page checksum error message.
The STRDEF definition of plural is out of scope in the error message just below it, which may lead to either garbage in the log message or a crash with SIGSEGV.

This is particularly visible with pg_tde, which encrypts tables: if pgbackrest is run with checksum enabled, it tries to emit this message for all encrypted files.

Fix by using simple char * constants in the error message.
2025-08-25 11:51:54 -04:00
David Steele 779cb763af Fix comment typo. 2025-08-23 14:23:30 -04:00
David Steele 5de5ed842a New CI container build for PostgreSQL 18 beta3.
Rebuild all containers to get the most recent versions of PostgreSQL.

Update the Debian repository install to match current recommendations. This has already been done for the documentation in fcd00a45.
2025-08-23 11:40:34 -04:00
David Steele 87339004e5 Add HTTP retries for 408 and 429 errors.
HTTP client errors 408 and 429 were not being retried but there seems to be some benefit to doing so.

408 has only been seen once and in that case the server was returning 400 (with Request Timeout in the response body) but it seems worth doing since this could happen during times of high congestion. Requests are not sent until request content is ready so there is not much else to be done to handle this error.

429 has been seen occasionally in the past but now seems to be common on Cloudflare R2. Ideally we would have a large initial back off here but it is not clear that is worth it at this time. The existing Fibonacci back off should be enough to allow operations to proceed if possible during the configured timeout.
2025-08-13 10:12:29 -04:00
David Steele fcd00a45f5 Update user guide and tests to Ubuntu 22.04.
20.04 is EOL so update the user guide and tests to 22.04.

The contributing guide was updated to 22.04 in d55836e7e.
2025-08-04 17:42:16 -04:00
David Steele 03cabe2644 Begin v2.57.0 development. 2025-07-21 13:08:40 -04:00
David Steele eca9290a2a v2.56.0: Progress Info Improvements
Bug Fixes:

* Fix issue with adhoc expiration when no backups in a repository. (Reviewed by Stefan Fercot. Reported by Anup Gupta.)

Features:

* Add restore progress to info command output. (Contributed by Denis Garsh, Maxim Michkov. Reviewed by David Steele.)
* Add progress-only detail level for info command output. (Contributed by Denis Garsh. Reviewed by David Steele, Stefan Fercot.)

Improvements:

* Retry failed reads on object stores. (Reviewed by David Christensen.)
* Fix defaults in command-line help. (Reviewed by David Christensen, Chris Bandy.)

Documentation Improvements:

* Describe discrete option values in a list where appropriate. (Contributed by Anton Kurochkin. Reviewed by David Steele.)
* Fix "less than" in help output for archive-mode option. (Contributed by Anton Kurochkin. Reviewed by David Steele.)
release/2.56.0
2025-07-21 10:12:22 -04:00
David Steele a2a246bba9 New CI container build for PostgreSQL 18 beta2. 2025-07-18 11:42:12 -04:00
Denis Garsh 8cdd9ce1c4 Add restore progress to info command output.
The prior implementation of the restore command did not provide any progress information. Implement it similarly to the backup command and also update the info command to display restore progress alongside backup progress.

Restore is a read operation and should not block other commands. The only exception is that multiple restores with the same lock and repository path are not allowed, as each restore must write progress to a separate file. Therefore, no lock is needed for restores with a remote role and the restore command should not be terminated when the stop command is executed.
2025-07-16 12:49:34 -04:00
David Steele d55836e7e8 Update contributing guide to Ubuntu 22.04.
20.04 is EOL and Docker is now noisy during installation so update.
2025-07-15 09:45:36 -04:00
David Steele ff944585ca Add funding information. 2025-07-07 16:57:08 -04:00
Denis Garsh 2706168f60 Add progress-only detail level for info command output.
The info command fetches a lot of information from the repository about backups and archives, so this operation can be slow. Because progress data is stored in local lock files, accessing the repository is unnecessary when only progress information is required.

This patch introduces the `--detail-level=[progress|full]` option, with `full` as the default. The `progress` level limits the info command output to progress details without querying the repository. The only remaining operations are scanning the folder structure to list available stanzas and reading lock files.

Note: When `progress` is selected, the info command performs no checks beyond verifying stanza availability.
2025-06-26 17:40:05 -04:00
David Steele 277b4db46f Move variable to scope where it is used. 2025-06-26 08:04:33 -04:00
David Steele 638815b4cd Fix issue with adhoc expiration when no backups in a repository.
If there are no backups in one or more repositories then the following error occurs during adhoc expiration:

ASSERT: [025]: cannot get index 0 from list with 0 value(s)

Fix this by skipping the adhoc logic when there are no backups in a repository.
2025-06-24 12:35:18 -04:00
David Steele 3780057866 Update Fedora test image to Fedora 42. 2025-06-22 17:46:54 -04:00
David Steele d0072945fa Add VR_NON_STRING macro for nonstring attribute.
The nonstring variable attribute specifies that an object or member declaration with type array of char, signed char, or unsigned char, or pointer to such a type is intended to store character arrays that do not necessarily contain a terminating NUL.

Newer versions of gcc will warn if this attribute is missing.
2025-06-22 15:38:32 -04:00
David Steele 44e3ee33d2 Improve defaults and allow lists with option value dependencies.
Some defaults and allow lists were determined in cfgLoadUpdateOption() because they depended on the values of other options, .e.g. compress-level.

Instead build this functionality into the config parser. Not only does this standardize the defaults and allow lists but it makes it possible to automate the documentation, which is also done in this commit.
2025-06-16 17:21:33 -04:00
David Steele 435f8a3ad7 Remove cfgParseOptionDefault() and cfgParseOptionRequired().
It is currently not possible to determine the default of all options knowing just the command. Some defaults are set in cfgLoadUpdateOption() and in an upcoming commit defaults may be based on the value of other options.

It would be possible to update parser to provide this information but that will complicate the parser and since the logic is only used to simplify options passed to remotes it does not seem worth the effort.

For the same reason cfgParseOptionRequired() can also be removed.
2025-06-16 17:05:35 -04:00
David Steele 5e14692588 Retry failed reads on object stores.
There is currently a retry if the initial get request fails (depending on the error code) but if the read fails later on while fetching blocks of data it is fatal. In most cases there is a higher level retry (e.g. restore) but restarting the restore job might be expensive depending on how many files are being restored.

Add a retry that will catch read errors and retry from where the last data was successfully read.

A bit of history -- this patch was first started three years ago but the memory context model at that time would not allow the interface (StorageRead) to own the driver (e.g. StorageReadS3). Subsequent improvements in memory contexts have allowed this ownership model and in fact it is now the default so no ownership changes are required in this patch except in StorageReadRemote which was not updated in f6e3073.
2025-06-16 16:25:50 -04:00
David Steele 1e23e38730 Update support and recognition documentation. 2025-06-16 16:04:35 -04:00
Anton Kurochkin 2e76e9fc69 Describe discrete option values in a list where appropriate.
In the documentation and help output the possible values for most options are described as a list but there were several commands for which formatting was done in a different style.

Formatting has been applied to commands and their options to display option values as a list:

* `info` command, `--type` option
* `verify` command, `--output` option
* `version` command, `--output` option
* `manifest` command, `--output` option
2025-06-09 10:34:17 -04:00
David Steele 8aa2d88bac Update unit tests to work with Alpine Linux and musl libc.
A few bugs have been reported over the years on Alpine with musl libc and generally it has been possible to figure them out without testing on that platform but a few newer ones cannot be reproduced elsewhere.

Also, testing with additional libc implementations helps portability so it makes sense to add support.

For the most part musl libc works as expected with a few caveats:

1) The FD_*() macros won't accept an int file descriptor without warning when -Wsign-conversion is enabled. I opened https://www.openwall.com/lists/musl/2025/05/23/4 to discuss this and I was referred to https://www.openwall.com/lists/musl/2024/07/16/1 which explains why this happens. It was not a very satisfying answer but clearly it is not going to be addressed so a meson probe was added to detect the issue and disable the warning.

2) Floating point numbers are rounded differently than in GNU/Mac libc when formatted with printf() and friends. This is fine for the core code but causes issues in the unit tests that expect log entries to match exactly. This was solved in ad7ba46b by adding our own rough and ready formatting routines.

3) Some error messages are different from GNU/Mac libc. This was solved with a new error macro that accepts multiple messages in b5fbb16c.

4) For some reason ninja on Alpine outputs "nothing to do" messages to stderr whereas they go to stdout on other distributions. Redirecting stderr to stdout is our standard fix for this issue so do that. A non-zero result code will let us know that something has gone wrong.

5) It appears that profiling is not supported on Alpine, which is pretty surprising. For now fix this by only unit testing the profiling code when coverage is enabled. This is not a great solution since we would rather test profiling on any system that supports it but for now this will do.
2025-06-05 17:33:18 -04:00
David Steele b5fbb16cce Add TEST_ERROR_MULTI() macro.
This macro allows the error to be tested against multiple strings and it passes if any of them match.

This is useful for supporting multiple libc versions/implementations that have different error messages and is needed for an upcoming commit to add unit test support for musl libc.
2025-06-05 15:35:28 -04:00
David Steele ad7ba46bc6 Improve the predictability of floating point numbers formatted as strings.
Some C libraries (e.g.musl) render floating point numbers differently when using printf(). This does not cause any problems for the core code but the unit tests require more predictability to function smoothly without a lot of exceptions.

To accomplish this, wrap the various floating point operations in functions that mostly continue doing math using double but format the output string using integers. This leads to more predictable output at the cost of some complexity.

Rounding could also be accomplished using nearbyint() but this would require linking the math library, which does not seem worth it for a fairly simple operation.
2025-06-05 13:27:45 -04:00
David Steele a30442f168 Update invalid address check in common/io-tls unit test.
The prior check would result in a segfault from musl libc, which is understandable but not OK for a test.

Instead set all the flags to get the expected invalid result.

The second invalid test was not required for coverage so remove it. This was likely added before the earlier test was required for additional coverage.
2025-05-31 10:08:13 -04:00
Anton Kurochkin cb673225e9 Fix "less than" in help output for archive-mode option. 2025-05-28 15:33:38 -04:00
David Steele f494dd21ad Fix architecture labeling for multi-architecture container builds.
When the architecture was not specified it was being set to x86_64 rather than the host architecture.
2025-05-27 17:14:18 -04:00
David Steele f4e1adf059 Fix issue with calling lstClear() twice.
The list pointer was not nulled out so calling lstClear() caused a double free.

This is not a production issue but was noticed in some upcoming test code.
2025-05-27 16:33:32 -04:00
David Steele b5a26d99a0 Use dup2() to redirect stderr in the common/error unit test.
The assignment was obviously not kosher but seemed fine for a test in short-lived fork. However, musl libc defines stderr as read-only so this trick won't work.

Instead use dup2(), which is pretty clearly the correct way to do this.
2025-05-26 12:49:47 -04:00
David Steele 8737cad566 Fix defaults in command-line help.
This is another attempt to fix broken defaults in the command-line help. PR #2395 tried to do this by removing current and default values (at least from the list) but this removed much of the value of command-line help being context sensitive. Improvements were made to current values in b3ca2e34 but defaults were left as-is, i.e. broken in some cases.

This new approach handles defaults much the same way as current values. If there are multiple defaults for an option then it is displayed in the option list as <multi> and enumerated in the specific option help. For example, if repo1-type=s3 and repo2-type=azure then the defaults for repo1-storage-upload-chunk-size and repo2-storage-upload-chunk-size will differ.

However, getting the above right means we can no longer display defaults for options that are not valid in the current context. For instance, if repo1-type=posix then none of the repo1-s3-* options are valid and therefore their defaults are not displayed in help. In this case they don't have defaults and if you tried to set one of these options you would get an error.
2025-05-12 13:33:42 -04:00
David Steele 7b1b1f5322 New CI container build for PostgreSQL 18 beta1.
Since the addition of libcurl4-openssl-dev requires a rebuild of the Debian containers go ahead and rebuild all containers to include new PostgreSQL minor release versions.
2025-05-09 17:45:05 -04:00
David Steele 34b916f323 Use 'x86_64' instead of 'amd64' for container testing.
This aligns with what is reported by 'uname -m' and required by Docker naming conventions.

Also convert a 'aarch64' string to the VM_ARCH_AARCH64 constant.
2025-05-09 12:56:57 -04:00
David Steele 7786b5d847 Rename unsigned char to uint8_t.
These data types are equivalent so no code changes required -- just renaming.

The advantage is that uint8_t makes it clear that this is byte data. It also has the advantage of being shorter.
2025-05-09 09:25:38 -04:00
David Steele 1e98684148 Add default type for current pgbackrest binary.
These defaults were being set in cfgLoadUpdate() but they can be better documented if they are part of the option rules. This is part of a general trend to move away from custom-coded defaults.
2025-05-08 09:16:30 -04:00
David Steele 6869543b7a Make default-literal option configuration with default-type.
This allows default types to be added without adding more boolean flags.
2025-05-08 09:12:38 -04:00
David Steele 32b69e9acc Rename cfgExe() to cfgBin().
This aligns better with naming in an upcoming commit.
2025-05-07 09:35:54 -04:00
David Steele d45da0363e Flag pg-host-config-include-path and pg-host-config-path as required.
These options had defaults so this doesn't really change anything but it does prevent some difficult to explain churn in a future commit.
2025-05-06 14:12:38 -04:00
David Steele e38e3e0090 Merge v2.55.1 release. 2025-05-05 13:40:14 -04:00
David Steele 975516ae6d Remove context wrapper when processing defaults during config parsing.
Once upon a time storing the default required creating a new string that needed to be assigned to the config mem context but that was a very long time ago and now only constants are used, so no need for a context switch.
2025-05-04 13:56:13 -04:00
David Steele beeb93225f Fix typo in comment. 2025-05-03 17:29:38 -04:00
David Steele 96dfdce085 Revert "calculate content-md5 on S3 only when required".
20bfd14 removed content-md5 where allowed by the specification but failed to notice that either content-md5 or x-amz-content-* is required for PUT when object lock is enabled.

On top of that it appears Scality S3 (at least?) won't accept alternate content checksums when object lock is enabled. Technically this is a violation of the specification but nonetheless the change breaks working installations.

For now it seems safer to revert this change and pursue a better solution for a future feature release.
2025-04-29 15:12:11 -04:00
David Steele 9958b17834 Fix lower bounds checking for option keys.
Specifying an indexed option with a key of 0, e.g. pg0-path, would lead to a segfault.

Add lower bounds checking to fix the issue.
2025-04-28 14:33:56 -04:00
David Steele 1d89e3d75b Add details about notifying packagers to release instructions. 2025-04-23 13:17:19 -04:00
David Steele 01c8c0f864 Begin v2.56.0 development. 2025-04-21 18:51:50 -04:00
David Steele 6c90196e74 v2.55.0: Verification Improvements and PostgreSQL 18 Support
Bug Fixes:

* Fix block incremental restore issue on non-default repository. (Reviewed by David Christensen, Aleksander Łukasz. Reported by Aleksander Łukasz.)
* Do not set recovery_target_timeline=current for PostgreSQL < 12. (Reviewed by Stefan Fercot.)
* Fix expire archive range logging. (Reviewed by Stefan Fercot. Reported by Aleš Zelený.)
* Fix error reporting for queries with no results. (Reviewed by Stefan Fercot. Reported by Susantha Bathige.)

Features:

* Verify recovery target timeline. (Reviewed by Stefan Fercot.)
* Allow verification of a specified backup. (Contributed by Maxim Michkov. Reviewed by David Steele.)
* Add support for S3/GCS requester pays. (Contributed by Timothée Peignier. Reviewed by David Steele.)
* PostgreSQL 18 experimental support. (Reviewed by Stefan Fercot.)
* Allow connections to PostgreSQL on abstract domain sockets. (Reviewed by Chris Bandy. Suggested by Chris Bandy.)
* Add numeric output to version command. (Contributed by Stefan Fercot. Reviewed by David Steele.)

Improvements:

* Allow backup command to operate on remote repositories. (Reviewed by Stefan Fercot.)
* Use lz4 for protocol compression. (Reviewed by Stefan Fercot.)
* Calculate content-md5 on S3 only when required. (Reviewed by David Christensen.)
* Warn when a value for a multi-key option is overwritten. (Reviewed by David Christensen, Stefan Fercot.)
* Add detail logging for expired archive path. (Contributed by Stefan Fercot. Reviewed by David Steele.)
* Remove support for PostgreSQL 9.4. (Reviewed by Stefan Fercot.)
* Remove autoconf/make build. (Reviewed by David Christensen.)

Documentation Improvements:

* Fix documentation for specifying multiple stanzas with tls-server-auth. (Reviewed by David Christensen, Stefan Fercot. Suggested by Terry MacAndrew.)
* Clarify incremental backup expiration. (Reviewed by Stefan Fercot.)
* Clarify requirement for local/remote pgBackRest versions to match. (Contributed by Greg Clough. Reviewed by David Steele.)
* Add FAQ about exporting self-contained cluster. (Contributed by Stefan Fercot. Reviewed by David Steele.)
* Caveat --tablespace-map-all regarding tablespace creation. (Reviewed by Stefan Fercot, Christophe Courtois. Suggested by Christophe Courtois.)
* Clarify behavior of --repo-retention-full-type. (Reviewed by Antoine Beaupré. Suggested by Antoine Beaupré.)
* Change --process-max recommendation for object stores to --repo-bundle. (Reviewed by Stefan Fercot.)
* Update unix_socket_directory to unix_socket_directories. (Contributed by hyunkyu han. Reviewed by David Steele.)
* Recommend not placing spool-path within pg_xlog/pg_wal. (Reviewed by Martín Marqués, Don Seiler. Suggested by Martín Marqués.)
release/2.55.0
2025-04-21 18:25:00 -04:00
Yegor 4bb7cb1ac6 Fix incorrect not-equal comparison in TEST_RESULT_Z_NE().
This comparison was not being used for strings in the tests but best to fix it so it does not cause confusion in the future.
2025-04-21 09:02:56 -04:00
Stefan Fercot 9386920b79 Add FAQ about exporting self-contained cluster. 2025-04-16 12:26:15 -05:00
David Steele c2f64bb03b Fix highlight error in user guide.
87776bc9 updated the RHEL documentation to PostgreSQL 13/14 but did not update recovery highlighting to be compatible with RHEL. This was not caught because the RHEL documentation was being build as PDF, which does not do highlighting.

Instead build the RHEL documentation as HTML in the first stage (and PDF in the second) so the error is caught.

Finally, fix the RHEL documentation to generate the highlight by concatenating the log.
2025-04-15 16:50:40 -05:00