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

4489 Commits

Author SHA1 Message Date
David Steele
5766353649 Use Posix driver to complete dummy storage driver.
Instead of stub functions, use the Posix driver to make the dummy storage driver interface more functional.
2024-08-02 15:47:30 +07:00
Stefan Fercot
b306f83493
Summarize backup reference list for info command text output.
The backup reference list can be very long so it seems better to summarize the list by default for text output and keep the full list when --set is specified.
2024-07-31 18:53:02 +07:00
Aleksey Tsalolikhin
c42d484c9d
Fix typo in user guide. 2024-07-30 12:48:32 +07:00
David Steele
8d6bceb541 Refactor config parse to remove none command, add version/help options.
The none command was a bit confusing since it was only valid when parsing failed but still needed to be added to various switches and logic. Replace with cfgInited() which should make it clearer what state configuration is in.

Make the default command help and convert --version and --help to real options.

Combine version and help output into a single function to simplify processing in main.

Additional reformatting and a bit of refactoring.
2024-07-23 16:39:02 +07:00
David Steele
6c757366c2 Simplify main() functions in core, doc, and test.
This refactor simplifies the main() functions and puts the more commonly run commands first.

For core main() also remove code duplication in local/remote role handling.
2024-07-23 11:50:12 +07:00
David Steele
faee892067 Do not allow help for command roles other than main.
Previously requesting help for roles other than main would result in a segfault since help.auto.c.inc does not include such help.

Prevent this by erroring when a user requests help for roles other than main.

This is a bug but it is unlikely to have ever been seen in the field and in any case it has a very low severity since it only impacts a corner-case for the help command.
2024-07-23 11:10:54 +07:00
David Steele
ee70c2e26e Remove internal repo-create command.
This command was used by the Perl integration tests to create buckets for storage types that required it. Now that the integration tests are written in C they can simply use the same code to create buckets.

The command was also used in the documentation but there it seems more appropriate to use the corresponding vendor CLI.
2024-07-22 14:17:47 +07:00
David Steele
55ca41e137 Update protocol and storage/remote modules to recent coding standards.
Add const as appropriate.
2024-07-22 12:43:54 +07:00
David Steele
df8cbc91c3
Protocol command multiplexing.
Previously it was not possible to read or write two files at the same time on the same remote because the protocol was entirely taken over by the read or write command. Multiple reads are required to make restores efficient when a list of bundled files is being read but blocks need to be retrieved from a separate file or a different part of the same file.

Improve that situation with sessions that allow related commands to be run with shared state. Also break read/write into separate requests (rather than pushing all data at once) so they can be multiplexed.

The disadvantage for read/write is that they now require more back and forth to transfer a file. This is mitigated by sending asynchronous read/write requests to keep both server and client as busy as possible. Reads that can fit into a single buffer are optimized to transfer in a single command. Reads that transfer the entire file can also skip the close command since it is implicit on end-of-file.

These changes allow the protocol to be simplified to provide one response per request, which makes the data end message obsolete. Any data sent for the request is now added to the parameters so no data needs to be sent separately to the server outside the request parameters.

Also update the Db protocol to use the new sessions. Previously this code had tracked its own sessions.
2024-07-22 11:48:32 +07:00
David Steele
e7f4e8d800 Begin v2.54 development. 2024-07-22 09:42:33 +07:00
David Steele
6e8a45f650 v2.53: Concurrent Backups
IMPORTANT NOTE: The log-level-stderr option default has been changed from warn to off. This makes it easier to capture errors when only redirecting stdout. To preserve the prior behavior set log-level-stderr=warn.

NOTE TO PACKAGERS: The lz4 library is now required by the meson build.

NOTE TO PACKAGERS: Compiler support for __builtin_clzl() and __builtin_bswap64() is now required by the meson build.

Bug Fixes:

* Fix SFTP renaming failure when file already exists. (Fixed by Reid Thompson. Reviewed by David Steele. Reported by ahmed112212.)

Features:

* Allow backups to run concurrently on different repositories. (Reviewed by Reid Thompson, Stefan Fercot.)
* Support IP-based SANs for TLS certificate validation. (Contributed by David Christensen. Reviewed by David Steele.)

Improvements:

* Default log-level-stderr option to off. (Reviewed by Greg Sabino Mullane, Stefan Fercot.)
* Allow alternative WAL segment sizes for PostgreSQL ≤ 10. (Contributed by Viktor Kurilko. Reviewed by David Steele.)
* Add hint to check SFTP authorization log. (Contributed by Vitalii Zurian. Reviewed by Reid Thompson, David Steele.)

Documentation Improvements:

* Clarify archive-push multi-repo behavior. (Reviewed by Stefan Fercot.)
2024-07-22 09:33:31 +07:00
David Steele
dea48be06d Fix incorrect examples in doc/test help.
The help for help was copied from core but the examples were not updated.

Update the examples to be appropriate for doc/help.
2024-07-21 17:01:23 +07:00
David Steele
32a6dd6c3d Improve config file handling in doc/test config load.
Since 1141dc20 it has been possible to request that cfgParse() skip loading the config file. Use this logic to replace the code used to ignore config files in doc/test config load.
2024-07-21 16:57:35 +07:00
David Steele
ec3e387bb7
Clarify archive-push multi-repo behavior.
Clarify that archive-push will not be able to push ahead in other repositories if one is failing unless archive-async in enabled.
2024-07-18 11:19:25 +07:00
David Steele
c85191e024 Update Minio test/documentation container version. 2024-07-16 09:45:22 +07:00
David Steele
d8ff89ae75 Update EOL Debian 10 to Debian 11/Ubuntu 20.04 in CI.
Typically we use the oldest Debian/Ubuntu to run 32-bit unit and integration tests. However, 32-bit is no longer fully supported by Ubuntu (multiple packages we need are missing) and apt.postgresql.org no longer packages for any 32-bit version.

To address these changes, do 64-bit integration testing on the oldest Debian/Ubuntu (currently Ubuntu 20.04) and 32-bit unit/integration testing on the oldest Debian (currently 11) using the included version for integration testing.
2024-07-15 11:53:57 +07:00
David Steele
ce2493c3f6 Remove obsolete vm constants.
The VM[2-4] constants do not serve a purpose anymore (removed in 794c5771) and just make the mappings more complicated, so remove them.
2024-07-15 11:22:13 +07:00
David Steele
c84ab4914f Remove references to mock integration tests.
Mock integration tests were removed in d41b21c8 but CI was still trying to run them, so remove from CI.

Also rename mock to integration in test unit tests to avoid confusion in the future.
2024-07-15 11:12:53 +07:00
David Christensen
dfb620b0b8
Support IP-based SANs for TLS certificate validation.
The prior SAN code only recognized DNS-based SANs, which meant that it would not properly validate if using an IP-based SAN. 

Add support for IPv4 and IPv6 SANs with exact matching only.

This simplifies testing when certificate generation tools have trouble generating a DNS:1.2.3.4-style SAN, preferring to include the SAN as IP:1.2.3.4.
2024-07-11 10:54:20 +07:00
David Steele
d295156dd3 Improve command/role parsing.
Reduce redundancy by improving cfgParseCommandId() to work when a command role is present. This way the function does not need to be called twice.

Also, remove the use of StringList in cfgParse() since checking for a colon is faster and saves memory allocations. Modify cfgParseCommandRoleEnum() to accept char * since a String is no longer produced for the role name.
2024-07-09 16:07:40 +07:00
Vitalii Zurian
ccae609402
Add hint to check SFTP authorization log.
In the case of authorization failures there many be valuable information in the log.
2024-07-09 11:34:13 +07:00
David Steele
cf8625d24b Require OpenSSL >= 1.1.1.
Versions below 1.1.1 are quite old and no longer need to be supported.

Also add a missing const in tlsAsn1ToStr().
2024-07-09 11:17:25 +07:00
David Steele
b71d4b53d6 Auto-generate code before building test binary.
Errors in code generation can cause the test binary build to fail and then it is not possible to see the generated code.

Instead, generate code first so any errors can be seen and analyzed.
2024-07-09 10:48:27 +07:00
David Steele
66d3cd42b5 Improve error messages for allow range and allow list options.
Create mappings between integer, size, time, and stringid option values and their string equivalents. This allows for better error messages and means that the mappings do not need to be stored with defaults, allow lists, etc.
2024-07-09 10:45:47 +07:00
David Steele
aadfb54046 Add units to all option sizes.
Some sizes were missing units. Add units to make it clear that they are sizes in messages.
2024-07-09 10:09:55 +07:00
David Steele
6f5066b0b6 Fix overly long lines. 2024-07-07 17:06:44 +07:00
Reid Thompson
d6f0bf88af
Fix SFTP renaming failure when file already exists.
Update error handling for libssh2_sftp_rename_ex() in storageWriteSftpClose() when a file already exists. 

The SFTP servers used during development and testing never returned LIBSSH2_FX_FILE_ALREADY_EXISTS, rather they returned LIBSSH2_FX_FAILURE when a file already existed. However, it is clear that some SFTP servers use LIBSSH2_FX_FILE_ALREADY_EXISTS so add support.
2024-07-04 16:53:07 +07:00
David Steele
edd61636a9
Allow backups to run concurrently on different repositories.
The prior locking only allowed one backup per stanza, which was required by PostgreSQL <= 9.5 and didn't present a problem when only one stanza could be created.

Now that multiple stanzas are allowed relax this restriction so that backups can run concurrently for PostgreSQL > 9.5. To do this, update the locking to be per stanza and repo rather than per stanza. Remotes are not aware of the repos that require locking so send an explicit list of files to be locked to the remote. Also remove the advisory lock for PostgreSQL > 9.5.

For info output the running backups are combined for progress output in order to avoid changing the JSON format. It definitely makes sense to have per repo progress as well but that will be left for a future commit.
2024-07-04 16:22:17 +07:00
David Steele
3a2266f327 Display time option defaults and allowed values with appropriate units.
Similar to size options in 038abaa7, time option defaults and allowed values were displayed in seconds, which could be confusing when the values were large.

The time options were not updated in 038abaa7 because it required removing the ability to do fractional seconds, e.g. 0.5 seconds. In theory this could cause breakage for users but it seems really unlikely. Fractional seconds are used in tests, however, so the tests have been changed to use milliseconds where required, e.g. 500ms.
2024-07-04 15:42:09 +07:00
David Steele
df469471e3 Fix invalid default inherited in job-retry-interval.
This default was being mistakenly inherited from job-retry and would set job-retry-interval to 1 second for archive get and push. In practice this did not matter since archive get and push default to one retry and the first retry interval is always 0, but it still makes sense to fix it to correct the behavior when the value of job-retry is changed.
2024-07-04 09:28:57 +07:00
David Steele
8b82641d87 Shorten enums used in parse.auto.c.inc.
Rather than using the full enum just use the part of the enum that is unique. This makes the output a bit more readable by removing the repetitive elements. The prefix for each enum is built into its macro.
2024-07-01 11:15:14 +08:00
David Steele
cfd4fb2c7d Remove PARSE_RULE_OPTION_GROUP_MEMBER() macro from parse.auto.c.inc.
It is simpler to just set group = true in the PARSE_RULE_OPTION_GROUP_ID(), so do that.
2024-06-30 16:11:11 +08:00
David Steele
7d54073094
Default log-level-stderr option to off.
Writing warnings and errors to stderr by default leads to error messages being lost when the user does not correctly redirect stderr while generating logs for analysis. This happens so often that it seems worth changing the default to increase the quality of the logs we receive.

If the user has explicitly set log-level-stderr then there is no change in behavior.
2024-06-25 16:45:47 +08:00
David Steele
1094aecab5 Require compiler support for __builtin_clzl() and __builtin_bswap64().
These functions will be useful for optimizing varint-128 functions.

Require them in the meson build before adding new code in case there are problems with packaging.
2024-06-25 16:16:55 +08:00
David Steele
0c32757fd9 Require the lz4 library in the meson build.
We would like to use lz4 for protocol compression instead of gz but first we need to make sure this is not going to cause a problem for packaging.

To do this make lz4 required in meson but make no changes to the code so this is an easy revert for packagers if there is an issue.
2024-06-25 16:04:02 +08:00
David Steele
acb9b6ccbe Increase width of unsigned integration in performance/type module.
The prior int was too small to scale up as much as we need for performance testing.
2024-06-25 15:54:57 +08:00
David Steele
6495a46ca3 Fix --run and --scale options for unit tests.
These were broken while code was being migrated to C and went unnoticed because the options are generally only used when doing performance testing.

The C code can only take one --run param so add a check for that in test.pl.
2024-06-25 15:46:07 +08:00
David Steele
cfb8aa202e Add remote locks for stanza commands missed in 31c7824a.
31c7824a should have added remote locks when the commands were modified to run remotely. This is unlikely to have caused issues since these commands are generally not run concurrently with backup/expire but having the locks is safer.
2024-06-21 13:29:17 +08:00
David Steele
b9a9ef2d5f Clarify when code generation is run when modifying config.yaml.
The contributing guide indicated that this happened at compile time but in fact it happens when test.pl is run.
2024-06-21 11:17:42 +08:00
David Steele
bcda7f8c7e Optimize assignment of command/option rules.
Assign the rule to a local variable to make subsequent assignments more efficient.

Also fix a missing const.
2024-06-20 13:06:04 +08:00
David Steele
a0a5f2300c Replace strftime() with cvtTimeToZP() and strNew/CatTimeP().
These functions produce cleaner code and hide implementation details.
2024-06-19 10:33:46 +08:00
David Steele
cec486b6dd Refactor backup to use flag for backup standby state rather than option.
Using the option adds a bit of complexity -- it is simpler just to use the state of the standby object to determine if backup from standby is enabled.
2024-06-18 11:42:59 +08:00
David Steele
270dce41b6
Refactor lock module.
Refactor the lock module to split command-specific logic from the basic file locking functionality. Command specific logic is now in command/lock.c. This will make it easier to implement new features such as repository locking and updating lock file contents on remotes.

This implementation is essentially a drop-in replacement but there are a few differences. First, the lock names no longer require a path (the path is added in the lock module). Second, the timeout functionality has been removed since it was not being used.
2024-06-18 10:43:54 +08:00
David Steele
ad7377c75b
Fix issue with files larger on the replica than on the primary.
If a file on the primary was larger than on the replica then the next diff/incr backup would store the primary size instead of the replica size when block incremental was enabled. On the next diff/incr backup this would lead to a repo size must be > 0 for file error when validating the manifest.

Fix this by limiting copy based on sizeOriginal rather than size so size can be set to the value expected to be stored in the manifest. As a bonus sizePrior is no longer needed since size can be used for the same purpose.
2024-06-16 11:55:04 +08:00
David Steele
2ec99ca4d9 Specify test images that get valgrind installed.
This means valgrind is no longer built from source, which caused image builds to run for a very long time.

Valgrind is only required in a few images for testing.
2024-06-12 16:08:17 +10:00
David Steele
886bb281f6 Migrate CentOS 7 integration tests to Rocky 8.
CentOS 7 will be EOL on June 30 and since there is no CentOS 8 migrate instead to Rocky 8.
2024-06-11 15:20:04 +10:00
Viktor Kurilko
4ac3b82c99 Allow alternative WAL segment sizes for PostgreSQL <= 10.
Alternative WAL segment sizes can be configured in PostgreSQL <= 10 with compile-time options. We have not allowed these before since it was not a well-tested feature of PostgreSQL.

However, forks such as Greenplum allow alternative WAL segment sizes at initdb time (which are presumably well-tested) so it makes sense to allow it.

Since the PostgreSQL versions in question are all EOL it is not important to have this restriction in place anymore.
2024-06-11 12:08:52 +10:00
David Steele
e8b965756c Add unit tests for backup from standby with block incremental.
These tests are important for an upcoming bug fix related to differing sizes of a file on a primary vs standby.

The test that demonstrates the bug cannot be included here since it causes a test failure, but this commit introduces the infrastructure and one test to guard against a regression in the bug fix.
2024-06-09 11:39:58 +10:00
David Steele
cf478bc753 Improve efficiency of incremental manifest build.
Move the file.copy check before the manifest lookup to save a lookup and (probably) find for zero-length files when bundling.

This also removes a layer of indentation which helps with readability.
2024-06-08 13:00:53 +10:00
David Steele
48823b6cd3 Simplify lock file scanning in stop command.
This simpler implementation only requires that a lock file begin with the stanza (followed by a dash) and end in .lock.

This will make the implementation more resilient to planned changes in lock file naming.
2024-06-07 14:24:08 +10:00