1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00
Commit Graph

2397 Commits

Author SHA1 Message Date
Stephen Frost
28b6b2d465
Improve performance of SFTP storage driver.
The initial implementation used simple waits when having to loop due to getting a LIBSSH2_ERROR_EAGAIN, but we don't want to just wait some amount of time, we want to wait until we're able to read or write on the fd that we would have blocked on.

This change removes all of the wait code from the SFTP driver and changes the loops to call the newly introduced storageSftpWaitFd(), which in turn checks with libssh2 to determine the appropriate direction to wait on (read, write, or both) and then calls fdReady() to perform the wait using the provided timeout.

This also removes the need to pass ioSession or timeout down into the SFTP read/write code.
2023-07-07 10:36:15 +02:00
David Steele
9efd5cd0bb
Add timezone offset to info command date/time output.
This makes it easier to use timestamps from the info command directly in PostgreSQL recovery settings, especially the --target option.
2023-07-06 18:46:31 +02:00
David Steele
762498f4cd
Fix time-based archive expiration when no backups are expired.
In the case that no backups were expired but time-based retention was met no archive expiration would occur and the following would be logged:

INFO: time-based archive retention not met - archive logs will not be expired

In most cases this was harmless, but when retention was first met or if retention was increased, it would require one additional backup to expire earlier WAL. After that expiration worked as normal.

Even once expiration was working normally the message would continue to be output, which was pretty misleading since retention had been met, even though there was nothing to do.

Bring this code in line with count-based retention, i.e. always log what should be expired at detail level (even if nothing will be expired) and then log info about what was expired (even if nothing is expired). For example:

DETAIL: repo1: 11-1 archive retention on backup 20181119-152138F, start = 000000010000000000000002
INFO: repo1: 11-1 no archive to remove
2023-07-06 11:27:00 +02:00
David Steele
e280ed9098 Make result code handling in storage/sftp more consistent.
Initializers are useless since rc is always set later. Make rc checks consistent with the rest of the module.
2023-07-06 08:58:16 +02:00
David Steele
1fd8845c7f Remove unresolved todo from 87087fac.
Seems easiest just to make the additional config required since it tests that custom ports are being used correctly. The test for synthetic was a noop since SFTP is not used in synthetic tests.
2023-06-29 11:08:58 +02:00
Andrey Sokolov
0ac09344dc
Fix unique label generation for diff/incr backup.
If there were at least two full backups and the last one was expired, it was impossible to make either a differential or incremental backup without first making a new full backup. The backupLabelCreate() function identified this situation as clock skew because the new backup label was compared with label of the expired full backup.

If the new backup is differential or incremental, then its label is now compared with the labels of differential or incremental backups related to the same full backup.

Also convert a hard-coded date length to a macro.
2023-06-28 18:19:20 +02:00
David Steele
5cbef3ade2 Fix missed memory auditing in FUNCTION_LOG_RETURN_VOID().
9ca492c missed adding auditing to this macro and as a result a few memory leaks have slipped through. Add auditing to the macro to close this hole.

Of the leaks found the only possibly serious one is in blockIncrProcess(), which would leak a PackRead of about eight bytes with every superblock. Since superblocks max out at a few thousand per file this was probably not too bad.

Also change the ordering of auditing in FUNCTION_TEST_RETURN_VOID(). Even though the order does not matter, having it different from the other macros is confusing and looks like an error.
2023-06-25 17:36:57 +02:00
David Steele
ecae001653 Add test for configuration hash type override behavior.
This behavior is different than regular options where a repeated value will result in an error. It appears to be a legacy of the original Perl implementation, which used a hash as the underlying data type in the built-in command-line parser, and the C command-line parser was written to match.
2023-06-24 10:18:29 +02:00
David Steele
434938e32b Update Fedora test image to Fedora 38.
This adds testing for the latest tool versions, e.g. gcc.
2023-06-22 18:23:06 +02:00
David Steele
5531e2662d Add --tz param missed in C unit test migration.
This was missed in the C unit test migration and since then a new test was added that was not setting its timezone correctly.

This feature exists to make sure the tests will run on systems with different timezones and has no impact on the core code.
2023-06-18 12:55:29 +03:00
David Steele
5d671c63d8 New CI container build for PostgreSQL 16 beta1. 2023-05-25 20:08:12 +03:00
David Steele
9cceed6ac4
Skip recovery.signal for PostgreSQL >= 12 when recovery type=none.
Bring PostgreSQL >= 12 behavior in line with other versions when recovery type=none.

We are fairly sure this did not work correctly when PostgreSQL 12 was released, but apparently the issue has been fixed since then. Either way, after testing we have determined that the behavior is now as expected.
2023-05-24 16:34:21 +03:00
David Steele
36ff81dc6f
Centralize error handling for unsupported features.
Some features are conditionally compiled into pgBackRest (e.g. lz4). Previously checking to see if the feature existed was the responsibility of the feature's module.

Centralize this logic in the config/parse module to make the errors more detailed and consistent.

This also fixes the assert that is thrown when SFTP storage is specified but SFTP support is not compiled into pgBackRest.
2023-05-24 14:17:07 +03:00
David Steele
c633b187db Remove user-facing documentation references to --vm=none.
This parameter is now optional and defaults to none so there is no reason to explicitly show it in user-facing documentation.

Also make the vm parameter in ci.pl optional to be consistent with how test.pl behaves.
2023-05-23 10:58:51 +03:00
David Steele
5bbe987589 Build u20 image to speed contributing document generation.
This image was left out of the last round of builds, which forced the contributing document to build it from scratch.
2023-05-23 10:14:00 +03:00
David Steele
c2c60350d3 Add missed --no-log-timestamp in unit tests and improved formatting.
The --no-log-timestamp option was missed when unit test building was migrated to C, which caused test timings to show up in the contributing guide. This caused no harm but did create churn in this file during releases.

Also improve the formatting when test timing is disabled.
2023-05-23 08:25:17 +03:00
David Steele
b461f7c6f8 v2.46: Block Incremental Backup and SFTP Storage
Features:

* Block incremental backup. (Reviewed by John Morris, Stephen Frost, Stefan Fercot.)
* SFTP support for repository storage. (Contributed by Reid Thompson. Reviewed by Stephen Frost, David Steele.)
* PostgreSQL 16 support. (Reviewed by Stefan Fercot.)

Improvements:

* Allow page header checks to be skipped. (Reviewed by David Christensen. Suggested by David Christensen.)
* Avoid chown() on recovery files during restore. (Reviewed by Stefan Fercot, Marcelo Henrique Neppel. Suggested by Marcelo Henrique Neppel.)
* Add error retry detail for HTTP retries.

Documentation Improvements:

* Add warning about using recovery type=none. (Reviewed by Stefan Fercot.)
* Add note about running stanza-create on already-created repositories.
2023-05-22 11:13:13 +03:00
Reid Thompson
87087fac23
SFTP support for repository storage. 2023-05-13 19:16:16 +03:00
David Steele
c7ac173304 Increase check timeouts in real/all integration tests.
The prior timeouts were a bit aggressive and were causing timeouts in the Azure tests. There have also been occasional timeouts in other storage drivers.

The performance of CI environments is pretty variable so increased timeouts should make the tests more stable.
2023-05-10 09:22:26 +03:00
David Steele
2fc6413837 Fix typos in test titles. 2023-05-06 12:16:58 +03:00
David Steele
d49907239e Remove double spaces missed in 1bd5530a. 2023-05-03 09:37:59 +03:00
David Steele
1bd5530a59 Remove double spaces from comments and documentation.
Double spaces have fallen out of favor in recent years because they no longer contribute to readability.

We have been using single spaces and editing related paragraphs for some time, but now it seems best to update the remaining instances to avoid churn in unrelated commits and to make it clearer what spacing contributors should use.
2023-05-02 12:57:12 +03:00
David Steele
5ea7b91bf9 Remove extraneous space from error messages. 2023-05-02 12:07:28 +03:00
David Steele
9637d94490 Use boolean variant constants where possible instead of redeclaring. 2023-05-02 09:37:42 +03:00
David Steele
dd4e52679e
Removing chunking and block numbers from incremental block list.
These were intended to allow the block list to be scanned without reading the map but were never utilized. They were left in "just in case" and because they did not seem to be doing any harm.

In fact, it is better not to have the block numbers because this allows us set the block size at a future time as long as it is a factor of the super block size. One way this could be useful is to store older files without super blocks or a map in the full backup and then build a map for them if the file gets modified in a diff/incr backup. This would require reading the file from the full backup to build the map but it would be more space efficient and we could make more intelligent decisions about block size. It would also be possible to change the block size even if one had already been selected in a prior backup.

Omitting the block numbers makes the chunking unnecessary since there is now no way to make sense of the block list without the map. Also, we might want to build maps for unchunked block lists, i.e. files that were copied normally.
2023-04-27 23:29:12 +03:00
David Steele
3fc3690dd7
PostgreSQL 16 Support.
Add catalog version and WAL magic for PostgreSQL 16.

The GUC to force parallel mode has be renamed so update that in the tests.
2023-04-27 10:30:50 +03:00
David Steele
3ff88ffbb4
Avoid chown() on recovery files during restore.
The chown() was already skipped on the files restored from the repository but the same logic was not applied to the generated recovery files, probably because chown'ing a few recovery files does not have performance implications. Use the same logic for recovery files to determined if they need to be chown'd.

Ultimately this behavior is pretty hard to test, so add a fail safe into the Posix driver that will skip chown if the permissions are already as required.
2023-04-25 11:52:28 +03:00
David Steele
f5e6bc2698
Allow page header checks to be skipped.
These checks cause false negatives for page checksum verification when the page is encrypted because pd_upper might end up as 0 in the encrypted data. This issue is rare but reproducible given a large enough cluster.

Make these checks optional, but leave them enabled by default.
2023-04-20 13:24:12 +03:00
David Steele
8240eb5da5 Autogenerate PostgreSQL versions.
This will make adding/removing versions of PostgreSQL more reliable.
2023-04-16 17:41:27 +03:00
David Steele
a05bf6bb15 Rename PG_VERSION_*_STR constants to PG_VERSION_*_Z.
This is more consistent with other zero-terminated string constants and also has the benefit of being shorter.
2023-04-16 17:32:24 +03:00
David Steele
75254c9285 Parameterize configLoad() as cfgLoadP().
There is one existing optional parameter and there are more to come.
2023-04-11 16:28:29 +04:00
David Steele
f33e1cfb16 Add error retry detail for HTTP retries.
This should make it clearer when retries have happened and for how long.
2023-04-06 11:38:18 +04:00
David Steele
df419b34b5 Improve retry error messages.
Centralize the code to allow it to be used in more places and update the protocol/server module to use the new code.

Since the time measurements make testing difficult, also add time and errorRetry harnesses to allow specific data to be used for testing. In the case of errorRetry, the production behavior is turned off by default during testing and only enabled for the errorRetry test module.
2023-04-06 11:03:46 +04:00
David Steele
801e396dac Move error modules to common/error directory.
There are already enough files to warrant a separate directory and more are coming.

Also remove extraneous includes.
2023-04-06 10:38:49 +04:00
David Steele
ff98636e41 Update 32-bit CI host to Debian 10 from Ubuntu 18.04.
Ubuntu 18.04 will be EOL before the next release, so update to the oldest available Debian version.

Also fix one incorrect return value type, a test cast, and adjust some test timeouts.
2023-04-06 08:22:14 +04:00
David Steele
a9f39857cf Remove unused strOS parameter in Common::HostTest. 2023-04-05 11:24:53 +04:00
David Steele
047472144b Remove allocations from common crypto module.
The allocations are better done with a struct and Buffer object.
2023-03-30 14:42:20 +05:00
David Steele
84ca7b9b27 Cleanup for objects that do not require allocations.
A lot of these are left over from when object interfaces required allocations (changed in f6e30736 and 9ca9c8e4). Others are likely copy/paste errors.

This saves some space in the mem context and makes it clear that no allocations will be made.
2023-03-30 11:42:22 +05:00
David Steele
fe0fd71be2 Convert the result of zNewFmt() into an object.
The result is not intended to be freed directly so this makes memory tracking more accurate. Fix a few places where memory was leaking after a call to zNewFmt().

Also update an assert to make it clearer.
2023-03-30 10:00:58 +05:00
David Steele
b111599bad Simplify object creation with OBJ_NEW_BEGIN() macro.
Eliminate the boilerplate of declaring this and assigning memory to it, which is the same for the vast majority of object creations.

Keep the old version of the macro as OBJ_NEW_BASE_BEGIN() for a few exceptions in the core code and (mostly) in the tests.
2023-03-28 15:05:18 +06:00
David Steele
91f9301b9d Fix command/manifest unit test title. 2023-03-27 16:42:35 +06:00
David Steele
9ca9c8e4c9 Improve interface handling in remaining modules.
As in f6e30736, make the interface object the parent of the driver object rather than the interface being allocated directly in the driver object. Allow exceptions to this general rule for objects that need to retain ownership of their interfaces.
2023-03-27 14:32:37 +06:00
David Steele
8ff956ad7e Add lock module initialization.
Each call to lockAcquireP() passed enough information to initialize the lock system. This was somewhat inefficient and as locks become more complicated it will lead to more code duplication. Since a process can only take one type of lock it makes sense to do most of the initialization up front.

Also reduce the log level of lockRelease() since it is only called at exit and the lock will be released in any case.
2023-03-25 14:07:31 +07:00
David Steele
f1caecc4ff Convert lockAcquire() to lockAcquireP().
This makes a few current parameters optional and allows for more optional parameters with less code churn.
2023-03-24 10:34:42 +08:00
David Steele
c8ec114c8c Add reference filter and output to manifest command.
This allows the file list to be filtered by reference. The reference is output when it is not the default reference for the backup.
2023-03-21 12:29:45 +08:00
David Steele
1807bfcff5 Clear buffer limit when buffer is limited to allocated size.
This minor optimization automatically clears the limit flag when limit is set to allocated size. This has no impact on the current code but will simplify a future commit where a conditional bufLimitClear() is being used.
2023-03-21 12:22:47 +08:00
David Steele
6ad79d16ca v2.45: Block Incremental Backup (BETA)
Bug Fixes:

* Skip writing recovery.signal by default for restores of offline backups. (Reviewed by Stefan Fercot. Reported by Marcel Borger.)

Features:

* Block incremental backup (BETA). (Reviewed by John Morris, Stephen Frost, Stefan Fercot.)

Improvements:

* Keep only one all-default group index. (Reviewed by Stefan Fercot.)

Documentation Improvements:

* Add explicit instructions for upgrading between 2.x versions. (Contributed by Christophe Courtois. Reviewed by David Steele.)
* Remove references to SSH made obsolete when TLS was introduced.
2023-03-20 09:37:23 +08:00
David Steele
78c036efb7 Updates required for new manifest command to work remotely.
Additional options are required and the BlockChecksum must work remotely.
2023-03-16 17:46:32 +07:00
David Steele
505a639f1e Prototype manifest command.
Output a manifest in text or JSON format. Neither format is complete but they cover the basics.

In particular the manifest command outputs the complete block restore when the filter option is specified and the block delta when the pg option is also specified. This is non-destructive so it is safe to execute against a running cluster.
2023-03-14 21:56:05 +07:00
David Steele
c30d3e439b
Block incremental map fixes and improvements.
Bug Fixes:

* Remove the distinction between maps where super block size is equal to block size and maps where they are not. In practice, maps with equal blocks are now rare and most of the optimizations can be applied directly to super blocks where the blocks are equal. This fixes a bug where a map that was created with equal size blocks and then converted to differing block sizes would generate an invalid map.

* Free reads during restore to avoid running out of file handles.

Improvements:

* Store super block sizes in the block map. This allows the final block size to be removed from the block list and provides a more optimal restore and better potential for analysis.

* Always round the super block size up to the next block size. This makes the number of blocks per super block more predictable.

* Allow super block sizes to be changed at will in the map. The first case for this is to store the reduced super block size required when the last super block is short but it could be used to dynamically change the super block size to optimize compression.

* Store a block count rather than a list of blocks in a super block. Blocks must always be sequential, though there may be an offset to the first block in a super block. This saves 11-14% on space for checksum sizes 6-7.

* In the case that all the blocks for a super block are present, and there is no offset, the block size is omitted.
2023-03-14 17:48:25 +07:00