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

4783 Commits

Author SHA1 Message Date
David Steele 119c089ccc Update uncrustify to recognize .c.inc files.
But ignore .auto.c.inc and .vendor.c.inc files.
2026-02-19 22:33:05 +07:00
David Steele 1ce2522e35 Refactor info/manifest module into included modules.
Similar to 1db52ef9 break up this module to make it more maintainable.
2026-02-19 22:28:36 +07:00
David Steele 27fff599ee Move info/manifest.c to info/manifest/manifest.c.
This module will be split up so move it to its own path first.
2026-02-19 22:23:01 +07:00
David Steele cf003f67e7 Move static build defines to build.h.
Putting these defines in meson.build is a bit annoying because of the added syntax and double commenting. Since the defines are static there is no good reason to have them there.

This also creates a place for test builds to add global defines -- again rather than in meson.build.
2026-02-17 15:05:33 +07:00
David Steele b9eb7f8113 Fix test error message typos and add error details. 2026-02-16 10:00:35 +07:00
David Steele 27319dde50 Explicitly free block map read in restoreFile().
This will be freed when the current file is complete but freeing it before the write is opened saves memory.
2026-02-16 09:03:39 +07:00
David Steele 17db234f1b Reverse sort order in backup and restore comparators.
Both of these lists were sorted descending so all comparisons in the comparator had to be reversed. This made it hard to reason about sort order.

It makes more sense to sort ascending and have the comparisons also be ascending. The final sort order remains the same.
2026-02-14 12:57:35 +07:00
David Steele 1db52ef9f3 Refactor restore module into included modules.
The restore module has been large and unwieldy for some time but I have been loathe to split it into separate compilation units because it means maintaining additional header files, updating build files, and losing optimizations from static functions. These functions are only used internally by restore and it seems wasteful to extern them.

We already have a number of cases where C files are included directly into other C files, especially .vendor.c.inc and .auto.c.inc files. We also include C files to add functionality needed for build/doc/test to core objects without having to add that functionality to core. See src/build/common/string.c for an example.

The test/coverage code already supports C includes but I had to update it to recognize the new extension.
2026-02-13 10:20:47 +07:00
David Steele bc3ef20679 Move initialization of StorageRead and StorageWrite to interface.
Moving initialization to the interface consolidates code and removes duplication in the drivers. This will become critical as the interface manipulates multiple drivers to improve performance.

This refactor is less important for StorageWrite but it seems better to keep them consistent.
2026-02-09 22:23:40 +07:00
David Steele 8d59a6f67e Remove package build testing.
This made sense during the days when the project was juggling Perl code, a C binary, and a C library. These days the build is far simpler and this dependency just means build failures when salsa.debian.org is cranky (often) without any apparent benefit.
2026-02-08 17:39:14 +07:00
David Steele 6079651443 Minor memory context optimization in restoreFile().
The temp mem context block was outside the if statement that determines if a file needs to be copied or not, which meant that some mem contexts would never be used.

Reverse this order to avoid creating unused mem contexts.
2026-02-07 17:01:32 +07:00
David Steele 06b99d93dc Calculate limit for Posix/SFTP during read instead of when created.
This was not a bug since the Posix/SFTP drivers do not allow read retries but it could easily turn into a bug if retries are enabled in the future so it seems safer to move the logic to a location that will work with retries.
2026-02-07 13:19:08 +07:00
David Steele e11fe39d0b Improve designated initializers in data arrays.
Designated initializers were being used to initialize the structs but not the arrays. Adding designated initializers makes the code a little clearer.

In the packTypeMapData array designated initializers also allow removal of the explicit zero padding and make initialization order unimportant (though it is better to keep them in order to match the enum).
2026-02-01 11:35:05 +07:00
David Steele 10d18be719 Fix comments in common/pack module. 2026-02-01 11:23:41 +07:00
David Steele 449529f98f Fix typo in NEWS.md. 2026-01-30 08:18:06 +07:00
David Steele b8b0dbceb3 Fix float-equal compiler warnings.
ed390780 added this warning but included an extra dash which caused it to be ignored. Remove the extra dash so the warning is applied.

Also remove some unused test code that violated the new warning.
2026-01-23 16:10:09 +07:00
David Steele c2b10a85b7 Use more specific warning for nonstring meson compiler probe.
Previously -Wextra was used, which is overly broad and led to the issue in 303e7458. Instead use a specific error to avoid side effects.

It is possible that this warning will not be recognized by all compilers but that is not an issue since this is only important for development. Warnings are ignored for production builds.
2026-01-23 10:17:56 +07:00
David Steele d4465bd6f7 Suppress unused parameter errors in meson compiler probes.
The main() parameters in meson compiler probes were not being used but could cause unused parameter errors.

Since the parameters are not needed remove them. This also has the benefit of making the code a bit simpler.
2026-01-23 10:08:48 +07:00
David Steele af8a9e1ea7 Update NEWS.md for new version and features. 2026-01-21 16:50:30 +07:00
David Steele 9fb9f73066 Documentation no longer builds on PostgreSQL < 10.
pgBackRest still supports PostgreSQL 9.6 but documentation is not built for EOL versions.

This will simplify the migration of the documentation to C.
2026-01-20 12:30:05 +07:00
David Steele 9ea54af67c Enhance StringId with optional sequence information.
It is convenient that a StringId can be used as an integer and also be rendered as a string. However, in many cases it is simpler and more efficient to have a sequence that can be used for lookup into an array or in a switch statement. This is particularly useful for StringIds generated by the config module.

Sequences cannot be used everywhere, though. In some cases StringIds are generated from text stored in files (e.g. compress type) in which case it is not possible to add sequence info without additional complexity.
2026-01-20 12:17:52 +07:00
David Steele 2a4fcf4b58 Update LICENSE.txt and PostgreSQL copyright for 2026. 2026-01-19 17:36:38 +07:00
David Steele d9f778ee32 Begin v2.59.0 development. 2026-01-19 17:17:07 +07:00
David Steele d50cfa9ee0 v2.58.0: Object Storage Improvements
IMPORTANT NOTE: The minimum values for the repo-storage-upload-chunk-size option have increased. They now represent the minimum allowed by the vendors.

Bug Fixes:

* Fix deadlock due to logging in signal handler. (Fixed by Maxim Michkov. Reviewed by David Steele.)

Features:

* HTTP support for S3, GCS, and Azure. (Contributed by Will Morland. Reviewed by David Steele.)
* Allow expiration of oldest full backup regardless of current retention. (Contributed by Stefan Fercot. Reviewed by David Steele. Suggested by Ron Johnson.)
* Support for Azure managed identities. (Contributed by Moiz Ibrar, Matthew Mols. Reviewed by David Steele.)
* Experimental support for S3 EKS pod identity. (Contributed by Pierre BOUTELOUP. Reviewed by David Steele.)
* Allow configuration of TLS cipher suites. (Contributed by Gunnar "Nick" Bluth. Reviewed by David Steele.)
* Allow process priority to be set. (Reviewed by Douglas J Hunley.)

Improvements:

* Allow dots in S3 bucket names when using path-style URIs. (Contributed by Joakim Hindersson. Reviewed by David Steele.)
* Require TLS >= 1.2 unless verification is disabled. (Reviewed by Douglas J Hunley, Gunnar "Nick" Bluth.)
* Dynamically size S3/GCS/Azure chunks for large uploads. (Reviewed by Douglas J Hunley. Suggested by Timothée Peignier.)
* Optimize S3/GCS/Azure chunk size for small files. (Reviewed by Douglas J Hunley.)
* Remove support for PostgreSQL 9.5. (Reviewed by Douglas J Hunley.)
* Improve logging of default for options with an unresolved dependency. (Reviewed by Stefan Fercot.)

Documentation Improvements:

* Remove explicit max_wal_senders/wal_level configuration from user guide. (Suggested by Jamie Nguyen.)
* Clarify that bundling is useful for filesystems with large block sizes. (Suggested by Ron Johnson.)
release/2.58.0
2026-01-19 17:03:44 +07:00
David Steele d206d89d5f New CI container builds. 2026-01-19 16:29:57 +07:00
David Steele b52ebe1fd8 Suppress Azurite API version checking in documentation builds.
The az tool used to create the bucket now requires an API version greater than what Azurite supports. This may be a mistake on their part (but has not resolved after a day) or may indicate that Azurite is no longer actively supported.

Either way, for now it is easiest to suppress the version check so CI builds can proceed. Other corrective action can be taken later as needed.
2026-01-15 12:01:51 +07:00
David Steele 6904cdf5a8 Simplify log-level options in config.yaml.
These were overly verbose -- inheritance is the way to do this.
2026-01-11 21:00:39 +07:00
David Steele d76da852ee Remove unused error parameter from strIdFromZN().
This parameter was made obsolete in 85caeda4.
2026-01-11 18:42:27 +07:00
David Steele d12aa6fcda Update strIdFromZN() comment missed in 6e11d650. 2026-01-11 15:02:22 +07:00
David Steele 35505d63fd Use more generic expression to fetch container IP addresses.
The IP address has been moved in newer versions of Docker but this expression will fetch the IP address from the old or new location.
2026-01-10 19:13:55 +07:00
David Steele 85caeda4e5 Throw errors on invalid StringIds in config/parse.c.
Now that the StringIds are not stored in parse.auto.c.inc it may not be obvious if an invalid StringId is generated. By moving the encoding to after the value has been validated we can error if the StringId is invalid rather than throwing an error that the value does not exist in the allow list.
2026-01-10 15:52:06 +07:00
David Steele 5898806473 Add PARSE_RULE_VAL_STR_IDX() to simplify logic in config/parse.c.
Mostly this just makes the code cleaner but there are also a few function calls that were replaced with the macro.

Also tighten up the logic in cfgParseOptionValuePack() a bit even though is not related to this macro change.
2026-01-10 15:35:37 +07:00
David Steele 31d4aaa19f Remove generated StringIds from parse.auto.c.inc.
These StringIds use space and increase churn when new ids are added. It is easy and efficient to use strings for comparison and convert to StringId in code.
2026-01-10 15:08:05 +07:00
wolrajhti 79544f64a3 Support for S3 EKS pod identity.
Fetch credentials automatically using EKS pod identity, which removes the need for static configuration. Credentials are automatically updated before they expire to support long-running commands.
2026-01-09 15:18:28 +07:00
David Steele 91ad65537f Fix flapping common/io-tls unit test added in fbc607a4.
Since the server exits on error in this test there is no need to shut it down when the script completes. This usually worked because the message would arrive before the server had shutdown completely but sometimes it would error on a broken pipe.
2026-01-08 11:45:14 +07:00
David Steele a7e5f28511 Clarify that bundling is useful for filesystems with large block sizes. 2026-01-08 10:53:51 +07:00
Gunnar "Nick" Bluth fbc607a48b Allow configuration of TLS cipher suites.
Configuration of specific cipher suites may be required for compliance or to use preferred ciphers for security.

Cipher suites are applied to the entire process and cannot be configured on a per-connection basis, except that for object store clients (e.g. S3) verification can be disabled.
2026-01-08 09:17:17 +07:00
David Steele 5b4b20a8d7 Require TLS >= 1.2 unless verification is disabled.
TLS 1.0 and 1.1 have been deprecated since 2021 (see RFC-8996) and TLS 1.2 has been available since 2008. As such it makes sense to require TLS >= 1.2 when verification is enabled. Verification is always enabled for TLS protocol sessions within pgBackRest but can be disabled for object stores (.e.g. S3) to support self-signed certificates on internal servers.

There is a slight change in behavior when verification is disabled. In prior versions SSL 2/3 would be disabled but now they are allowed (as well as TLS 1.0/1.2). With verification disabled it doesn't seem useful to be picky about protocol versions and disabling TLS 1.0/1.1 could easily cause breakage on older TLS servers.
2026-01-07 08:22:01 +07:00
Moiz Ibrar 38f14d73b6 Support for Azure managed identities.
Fetch credentials automatically using managed identities, which removes the need for static configuration. Credentials are automatically updated before they expire to support long-running commands.
2026-01-05 18:42:11 +07:00
David Steele 67c8b3462d Fix minor formatting issue. 2026-01-05 09:34:46 +07:00
David Steele 6e11d65074 Remove prefix functionality from StringId.
In practice StringIds that could not be output as the original string were not useful. Remove this functionality to simplify the code and reclaim the bit for other purposes.
2026-01-02 12:02:48 +07:00
David Steele d269d1d9bd Move object code out of StringId module.
Functions for creating String and StringZ objects should be in their respective modules so move them there. This simplifies the dependencies for StringId and is more modular.
2026-01-02 11:16:28 +07:00
David Steele 9118571196 Move constants required for debug logging.
Moving these constants to stringStatic.h reduces the dependency on stringZ.h for low-level debug logging. This makes it possible to add new capabilities to stringZ.c.
2026-01-02 10:47:45 +07:00
David Steele 84778658ac Use JsonRead for all info JSON parsing.
After JsonRead was introduced the performance-sensitive areas of info were migrated from Variant. However, other areas were left using Variant because they were not important enough to update at that time.

Migrate remaining Variant usage to JsonRead wherever possible for consistency. Also improve memory management to avoid some cruft that would end up in the object mem context and avoid switching to the object mem context when possible.
2025-12-30 17:40:18 +07:00
David Steele d88ae74282 Fix test comment. 2025-12-29 19:40:26 +07:00
Will Morland 2398dd4d43 HTTP support for S3, GCS, and Azure.
Allow users to specify HTTP in the endpoint but default to using HTTPS in all other scenarios to preserve the existing behavior.

Extend HttpUrl with a `defaultType` parameter to support either:
- Explicitly specifying a protocol via `.type` and enforcing that protocol is used in the URL.
- Allowing protocol to be parsed from URL, but providing default via `.defaultType` if no protocol is found in the URL.

Add partial write handling in fdWrite() to support non-blocking socket operations. The write loop now handles EAGAIN errors by waiting for the file descriptor to become writable, and continues writing the remaining bytes when write() returns fewer bytes than requested. This is required for HTTP, which may use non-blocking sockets, but doesn't have built in handling like the TLS client we are using for HTTPS. Also wrap the write() call and add a shim and additional logging for easier unit testing.
2025-12-29 10:39:21 +07:00
David Steele 1afaab1c1e Removed redundant documentation variables and references. 2025-12-23 17:24:49 +07:00
David Steele fdeb46be83 Remove PDF documentation output.
PDF output is not longer used by the project. Removal will make documentation maintenance and improvements simpler.
2025-12-23 16:59:08 +07:00
Maxim Michkov e13c462908 Fix deadlock due to logging in signal handler.
Previously it was possible to achieve a deadlock in a signal handler, for example when SIGTERM (i.e. sent by `pgbackrest stop --force`) arrives when a lock used in `gmtime_r` is taken. Then the next time logging is done, it will deadlock on `gmtime_r`.

In general, most stdlib functions are not safe to call in signal handlers, only so called async-signal safe functions are. In particular, `snprintf` isn't safe since it is allowed to internally call `malloc`. The `exitSafe` function isn't safe due to extensive use of allocations. Because of this, we need to use a simpler logging format in signal handlers, one that only uses async-signal safe functions.
2025-12-22 14:43:15 +07:00
David Steele cc7b9b7271 Fix missing parameter logging in storageS3New(). 2025-12-22 14:23:08 +07:00