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

4376 Commits

Author SHA1 Message Date
David Steele
dcf0781987
Remove support for PostgreSQL 9.3.
Per our policy to support five EOL versions of PostgreSQL, 9.3 is no longer supported by pgBackRest.

Remove all logic associated with 9.3 and update the tests.
2023-11-09 12:59:12 -03:00
David Steele
fa5b2d44ad
Fix regression in retries.
5314dbf aimed to make nested Wait objects more accurate with regard to wait time but it also got rid of the "bonus" retry that was implicit in the prior implementation. This meant that if an operation used up the entire allotted timeout, it would not be retried. Object stores especially are noisy places and some amount of retry should always be attempted. So even though removing the "bonus" retry was intended, it turned out not to be a good idea.

Instead of an implicit retry, formalize two retries in the Wait object even if the wait time has expired. Any number of retries are allowed during the wait period. Also remove waitRemaining() since it is no longer needed.

Adjust tests as needed to account for the extra timeouts.

Note that there may still be an underlying issue here that is simply being masked by retries. That is, the issue expressing was that waiting for a socket to be writable was timing out and without a retry that caused a hard error. This patch does nothing to address the source of the write timeout and perhaps there is nothing we can do about it. It does seem similar to the write issue we had with our blocking TLS implementation, but it was never clear if that was a problem with TLS, the kernel, or a bug in pgBackRest itself. It cropped up after a kernel update and we switched to non-blocking TLS to address the issue (c88684e).
2023-11-09 12:04:25 -03:00
David Steele
3c116e1829 Remove unused header. 2023-11-04 14:43:11 -03:00
David Steele
e0f5880b09 Refactor of pq shim to allow more flexible scripting.
The pq scripts were pretty static which had already led to a lot of code duplication in the backup test harness.

Instead allow the scripts to be built dynamically, which allows for much more flexibility and reduces duplication. For now just make these changes in the backup harness, but they may be useful elsewhere.

While we are making big changes, also update the macro/function names to hew closer to our current harness naming conventions.
2023-10-22 13:55:56 -04:00
David Steele
306fdff93a Remove unused parameter in backupProcess().
Also fix a comment in the same function.
2023-10-19 10:11:27 -04:00
David Steele
04d92cca7e Tidy and align site introduction and description.
Make the description more concise and use it for both the site description and introduction.
2023-10-19 09:54:34 -04:00
David Steele
459d59615a More efficient/compact calculations for encoded sizes.
encodeToStrSizeBase64() is definitely more efficient (pulled from the PostgreSQL implementation).

encodeToStrSizeBase64Url() is probably about as efficient as the prior implementation but is certainly more compact.

Also add tests for zero byte encoding sizes.
2023-10-18 18:14:32 -04:00
David Steele
21c8c8a66c
Document maintainer options.
Document maintainer options in a separate section with appropriate explanation and caveats.

Also make the pg-version-force option user visible now that maintainer caveats have been documented.
2023-10-14 16:22:09 -04:00
David Steele
81536cd486 Simplify description rendering in command and configuration reference.
The reference documentation was still using a very old version of rendering from before the user guide was introduced. This was preserved in the initial C migration to reduce the diff between Perl and C for testing purposes. The old version used hard linefeeds to simulate paragraphs and reduce the amount of markup that needed to be used. In retrospect this was not a great idea.

Instead use more natural rendering that does not depend on using hard linefeeds between paragraphs.
2023-10-10 16:49:05 -04:00
David Steele
45abea471e Simplify section titles in configuration reference.
For some reason the internal section id was included in the title. This was probably copied from another section title where it made more sense, e.g. including the option name after the title.

Also add release note missed in 1eb01622.
2023-10-10 13:02:50 -04:00
David Steele
1eb0162208 Build command and configuration reference in C.
Migrate generation of these files from help.xml to the intermediate documentation format. This allows us to share a lot of code that is already in C and remove duplicated code in Perl. More duplicate code can be removed in Perl once man generation is migrated.

Also update the unit test harness to allow testing of modules in the doc directory.
2023-10-09 14:03:43 -04:00
David Steele
983cc1a9e3 Adjust timeouts in the common/io/tls test to fix flapping coverage.
This test was failing coverage pretty regularly because the retry in tlsClientOpen() was not always being reached. Make the TLS timeouts longer to ensure reliable coverage.
2023-10-01 16:32:27 -04:00
Reid Thompson
af4621894a
Fix common/lock test failing with -Werror=unused-result.
Wrap ftruncate() in TEST_RESULT_INT() to prevent this error.
2023-09-30 12:47:15 -04:00
David Steele
eccd9eed19 Update Minio test/documentation container version. 2023-09-30 12:45:24 -04:00
David Steele
33ba4db9cb Use CSS to number sections in documentation.
This reduces churn in the HTML when sections are added or removed from the documentation.
2023-09-30 09:40:44 -04:00
David Steele
1d5563288c Parse defaults and text sections in help.xml.
These will be required to build documentation in C.
2023-09-29 17:28:00 -04:00
David Steele
088026e6ff Allow documentation source file to be specified in manifest.
The help source file had previously been hardcoded and now that is no longer needed.

A future commit will introduce more sources outside of the xml path.
2023-09-29 17:06:37 -04:00
David Steele
55fda01733 Remove unused references to DocConfig and DocConfigData Perl modules. 2023-09-29 16:57:01 -04:00
David Steele
217584a2c4 Add new XML functions required for building documentation. 2023-09-29 16:52:08 -04:00
David Steele
8f319b6fd3 Update config.guess and config.sub to latest versions. 2023-09-25 09:43:30 -04:00
David Steele
084c8e1691 Begin v2.49 development. 2023-09-25 09:40:45 -04:00
David Steele
a7ab686d0e v2.48: Repository Storage Tags
Bug Fixes:

* Fix issue restoring block incremental without a block list. (Reviewed by Stephen Frost, Burak Yurdakul. Reported by Burak Yurdakul.)

Features:

* Add --repo-storage-tag option to create object tags. (Reviewed by Stephen Frost, Stefan Fercot, Timothée Peignier.)
* Add known hosts checking for SFTP storage driver. (Contributed by Reid Thompson. Reviewed by Stephen Frost, David Steele.)
* Support for dual stack connections. (Reviewed by Stephen Frost.)
* Add backup size completed/total to info command JSON output. (Contributed by Stefan Fercot. Reviewed by David Steele.)

Improvements:

* Multi-stanza check command. (Reviewed by Stephen Frost.)
* Retry reads of pg_control until checksum is valid. (Reviewed by Stefan Fercot, Stephen Frost.)
* Optimize WAL segment check after successful backup. (Reviewed by Stephen Frost.)
* Improve GCS multi-part performance. (Reviewed by Reid Thompson.)
* Allow archive-get command to run when stanza is stopped. (Reviewed by Tom Swartz, David Christensen, Reid Thompson.)
* Accept leading tilde in paths for SFTP public/private keys. (Contributed by Reid Thompson. Reviewed by David Steele.)
* Reload GCS credentials before renewing authentication token. (Reviewed by Stephen Frost. Suggested by Daniel Farina.)

Documentation Bug Fixes:

* Fix configuration reference example for the tls-server-address option. (Fixed by Hartmut Goebel. Reviewed by David Steele.)
* Fix command reference example for the filter option.

Test Suite Improvements:

* Allow storage/sftp unit test to run without libssh2 installed. (Contributed by Reid Thompson. Reviewed by David Steele. Suggested by Wu Ning.)
2023-09-25 09:32:15 -04:00
David Steele
cb3ff6ed43 Fix command reference example for the filter option.
This example was broken by 24f7252. Revert to (almost) the prior code to fix this example until something better can be committed. The something better is in progress but it adds new build requirements so it is too late to include it for the release.

Technically this breaks some other examples, but they are all internal and not visible in the user-facing documentation.
2023-09-23 13:41:03 -04:00
David Steele
6f0f2b371e Update help title for the --annotation option.
Fix capitalization and remove pluralization that is implied.
2023-09-19 19:01:16 -04:00
Reid Thompson
c3c0834e17
Allow storage/sftp unit test to run without libssh2 installed.
Add missing #ifdefs and update tests to prevent test compilation failure and test run issues when libssh2 is not present.
2023-09-19 16:26:13 -04:00
David Steele
bb752cd111 Remove duplicate tests from storage/sftp unit test module.
These tests are already run as part of storage/posix and do not need to be duplicated in storage/sftp.
2023-09-19 12:08:09 -04:00
David Steele
31de127cf4
Fix issue restoring block incremental without a block list.
It is currently possible for a block map to be written without any accompanying blocks. This happens when a file timestamp is updated but the file has not changed. On restore, this caused problems when encryption was enabled, the block map was bundled after a file that had been stored without block incremental, and both files were included in a single bundle read. In this case the block map would not be decrypted and the encrypted data was passed to blockMapNewRead() with unpredictable results. In many cases built-in retries would rectify this problem as long as delta was enabled since block maps would move to the beginning of the bundle read and be decrypted properly. If enough files were affected, however, it could overwhelm the retries and throw an error. Subsequent delta restores would eventually be able to produce a valid result.

Fix this by moving block map decryption so it works correctly no matter where the block map is located in the read. This has the additional benefit of limiting how far the block map can read so it will error earlier if corrupt. Though in this case there was no repository corruption involved, it appeared that way to blockMapNewRead() since it was reading encrypted data.

Arguably block maps without blocks should not be written at all, but it would be better to consider that as a separate change. This pattern clearly exists in the wild and needs to be handled, plus the new implementation has other benefits.
2023-09-19 11:30:29 -04:00
David Steele
88edea4571 Add block incremental info to restore detail logging.
Log that block incremental was used and the delta size if less than the entire file was updated.
2023-09-18 11:30:42 -04:00
David Steele
d27533b40f Fix manifest command filter for files in a tablespace.
pg_data/ was appended at the beginning of the filter, which meant that files in tablespaces could never be queried directly.

Update the filter to require the full path, including pg_data/ or pg_tblspc/.
2023-09-17 17:06:42 -04:00
David Steele
ed88f0483e Add missing comma in protocolParallelJobToLog(). 2023-09-16 09:35:27 -04:00
Reid Thompson
ce9ba0fade
Add known hosts checking for SFTP storage driver.
By default require a known hosts match as part of the SFTP storage driver's authentication process, i.e. repo-sftp-host-key-check-type=strict. The match is expected to be found in the default list or in a list of known hosts files provided by the user. An exception is made if a fingerprint has been manually configured with repo-sftp-host-fingerprint or repo-sftp-host-key-check-type=accept-new can be used to automatically add new hosts.

Also allow host key verification to be skipped, as before, but require the user to explicitly set this (repo-sftp-host-key-check-type=none) rather than it being the default.
2023-09-15 20:22:38 -04:00
David Steele
f5c730fd03 Add prefix to meson build target to avoid conflicts.
Older versions of meson fail when a build target in a subproject has the same name as another subproject.

This has been fixed in newer versions, but we still need to support older versions and in any case this seems cleaner and the help build target is already prefixed in this fashion.
2023-09-15 18:15:02 -04:00
David Steele
9039d20b5b
Add report option to check command.
This option is intended to eventually create a comprehensive report about the state of the pgBackRest configuration based on the results of the check command.

Implement a detailed report of the configuration options in the environment and configuration files. This should be useful information when debugging configuration errors, since invalid options and configurations are automatically noted. While custom config locations will not be found automatically, it will at least be clear that the config is not in a standard location.

For now keep this option internal since there is a lot of work to be done, but commit it so that it can be used when needed and tested in various environments.

Note that for now when --report is specified, the check command is not being run at all. Only the config report is generated. This behavior will be improved in the future.
2023-09-15 09:30:40 -04:00
David Steele
657c1a3e06 Finalize catalog number for PostgreSQL 16 release. 2023-09-14 18:41:36 -04:00
David Steele
1b4e0cce5f
Add --repo-storage-tag option to create object tags.
This new option allows tags to be added to objects in S3, GCS, and Azure repositories.

This was fairly straightforward for S3 and Azure, but GCS does not allow tags for a simple upload using the JSON interface. If tags are required then the resumable interface must be used even if the file falls below the limit that usually triggers a resumable upload (i.e. size < repo-storage-upload-chunk-size).

This option is structured so that tags must be specified per-repo rather than globally for all repos. This seems logical since the tag keys and values may vary by service, e.g. S3 vs GCS.

These storage tags are independent of backup annotations since they are likely to be used for different purposes, e.g. billing, while the backup annotations are primarily intended for monitoring.
2023-09-14 08:22:21 -04:00
Reid Thompson
3b9c31f6e3 Use PROJECT_NAME constant instead of string literal. 2023-09-13 16:59:52 -04:00
David Steele
39bb8a0d3a
Support for dual stack connections.
The prior code would only connect to the first address provided by getaddrinfo().

Instead try each address in the list. If all connections fail then wait and try them all again until timeout.

Currently a round robin approach is used where each connection attempt must fail before the next connection is attempted. This works fine, for example, when an ipv6 address has no route to the host, but will work less well when a host answers but doesn't respond in a timely fashion.

We may consider a Happy Eyeballs approach in the future, but since pgBackRest is primarily a background process, it is not clear that slightly improved response time (in the case of failed connections) is worth the extra complexity.
2023-09-12 18:09:58 -04:00
David Steele
9d3a605900
Optimize WAL segment check after successful backup.
The prior code did one list command against the storage for each WAL segment. This led to a lot of lists and was especially inefficient when the WAL (or the majority of it) was already present.

Optimize to keep the contents of a WAL directory and use them on a subsequent search. Leave the optimizations for a single WAL segment since other places still use that mode.
2023-09-10 12:45:58 -04:00
David Steele
edbd520c81
Refactor address list lookup to include all returned addresses.
sckHostLookup() only returned the first address record returned from getaddrinfo(). The new AddressInfo object provides a full list of values returned from getaddrinfo(). Freeing the list is also handled by the object so there is no longer a need for FINALLY blocks to ensure the list is freed.

Add the selected address to the client/server names for debugging purposes.

This code does not attempt to connect to multiple addresses. It just lays the groundwork for a future commit to do so.
2023-09-10 10:36:58 -04:00
David Steele
f42d927d2d
Retry reads of pg_control until checksum is valid.
On certain file systems (e.g. ext4) pg_control may appear torn if there is a concurrent write while reading the file. To prevent an invalid read, retry until the checksum matches the control data.

Special handling is required for the pg-version-force feature since the offset of the checksum is not known. In this case, scan from the default position to the end of the data looking for a checksum match. This is a bit imprecise, but better than nothing, and the chance of a random collision in the control data seems very remote considering the ratio of data size (< 512 bytes) to checksum size (4 bytes).

This was discovered and a possible solution proposed for PostgreSQL in [1]. The proposed solution may work for backup, but pgBackRest needs to be able to read pg_control reliably outside of backup. So no matter what fix is adopted for PostgreSQL, pgBackRest need retries. Further adjustment may be required as the PostgreSQL fix evolves.

[1] https://www.postgresql.org/message-id/20221123014224.xisi44byq3cf5psi%40awork3.anarazel.de
2023-09-10 09:47:49 -04:00
David Steele
c1805134b3 Aggregate error retries in ErrorRetry output.
If there are a lot of retries then the output might be very large and even be truncated by the error module. Either way, it is not good information for the user.

When a message is repeated, aggregate so that total retries and time range are output for the message. This provides helpful information about what happened without overwhelming the user with data.
2023-09-09 12:54:55 -04:00
David Steele
5314dbffc7 Adjust Wait object to be more accurate when nested.
The prior code gave a "free" extra iteration at the end of the wait, functionality that was copied directly from the equivalent code in Perl. This works and is mostly negligible except when wait loops are nested, in which case outer loops will always run twice even if an inner loop times out, which has a multiplying effect. For example, three nested wait loops with a timeout of three seconds will result in the inner loop being run four times (for a total of twelve seconds) even if it times out each time.

Instead make waitMore() stop exactly when time is up. This makes more sense because a complete failure and timeout of an inner loop means retrying an outer loop is probably a waste of time since that inner loop will likely continue to fail.

Also make waitRemaining() recalculate the remaining time rather than depending on the prior result.

Some tests needed to be adjusted to take into account there being one less loop. In general this led to a simplification of the tests.

Reinit a begin value in the wait unit tests. This is not related to the current change but it does make the time measurements more accurate and less likely to fail on an edge case, which has been observed from time to time.

This change appears to have a benefit for test runtime, which seems plausible especially for nested waits, but a larger sample of CI runs are needed to be sure.
2023-09-09 11:22:33 -04:00
David Steele
d57900839a Improve backup test harness to handle very large quantities of WAL.
The current tests only generate small quantities of WAL per backup but sometimes it is useful to generate large quantities for testing.

Fix the issues with generating large quantities of WAL and also improve memory management.
2023-09-04 18:51:44 -04:00
Hartmut Goebel
43524a47a4
Fix configuration reference example for the tls-server-address option.
The prior example (::*) was not valid and would result in the following error:

ERROR: [049]: unable to get address for '::*': [-2] Name or service not known

Correct values are either * for IPv4 or :: for IPv6. The IPv4 value is used as the example since only one example is allowed.
2023-09-04 13:39:11 -04:00
David Steele
c0935b7992 Split release notes into individual files.
The release.xml file was getting pretty unwieldy so break release notes into separate files. Also break contributors into a separate file.

In theory most of release.xml could now be generated automatically but adding a new release does not represent a serious maintenance burden, so for the time being it does not seem worth it.
2023-09-04 12:00:06 -04:00
David Steele
6cb9c40fb8
Improve GCS multi-part performance.
The prior code avoided uploading a chunk if it was not clear whether the write was complete or not. This was primarily due to the GCS documentation being very vague on what to do in the case of a zero-size chunk.

Now chunks are uploaded as they are available. This should improve performance and also reduces the diff against a future commit that absolutely requires zero-size chunks.
2023-09-04 10:39:19 -04:00
David Steele
fd9c6b0e9d Add missing const qualifier to errorTypeList. 2023-09-01 12:03:39 -04:00
David Steele
4f52015b14 New CI container build for PostgreSQL 16 rc1. 2023-08-31 20:22:01 -04:00
Stefan Fercot
e3fcd8cd9e
Add backup size completed/total to info command JSON output.
This allows for backup progress to be monitored by external processes, whereas before backup progress was only available via text output.
2023-08-31 16:36:52 -04:00
David Steele
fbd992adc7 Allow archive-get command to run when stanza is stopped.
The restore command can run while the stanza is stopped so it makes sense for the archive-get command to follow the same rule.

The important thing is to ensure that all commands that write to the repository are stopped when the stanza is stopped.
2023-08-29 13:49:49 -04:00