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

4358 Commits

Author SHA1 Message Date
Reid Thompson
8a8cfba62b Remove resolved comment. 2023-12-27 12:53:53 -03:00
David Steele
f4a4af299b
Fix short read in block incremental restore.
During restore it is possible to read all the blocks out of a compressed super block without reading all the input. This is because the compression format may have some trailing bytes that are not required for decompression but are required to indicate that data has ended. If a buffer aligned with the compressed data in a certain way, these last bytes might not be read.

Explicitly read out any final bytes at the end of each super block to handle this case. This should always result in no additional data out and we check for that, but it does move the read position to the beginning of the next compressed super block so decompression can begin without error.
2023-12-27 12:49:47 -03:00
David Steele
c47b39acf6 Fix incorrect test comment.
Left over from an older implementation.
2023-12-27 12:39:45 -03:00
David Steele
4324b568a9 Move block testBlockDelta() to harness module.
This makes the function available to other test modules.

Also rename to hrnBlockDeltaRender().
2023-12-26 21:07:56 -03:00
David Steele
9049fec2c0 Refactor skip files truncated during backup when bundling.
Refactor 02eea555 to always close the file immediately on EOF and use backupCopyResultCopy to continue processing. Closing the file immediately saves a later EOF check and is friendlier to added logic in this area. Using backupCopyResultCopy to continue is clearer also makes it easier to add new logic.

Also store zero checksum so the bulk of results collection can be moved within the copy block.
2023-12-22 13:16:45 -03:00
David Steele
c8795094d4 Allow const checksum buffers to be returned from backupFile().
This allows less duplication of buffers.

For delta check return file->pgFileSize/file->pgFileChecksum instead of pgTestSize/pgTestChecksum since this saves one buffer duplication and we know these values are equal since we just checked them.

Also add an assert to ensure copyChecksum is valid relative to size.
2023-12-22 12:48:01 -03:00
David Steele
4f760df417
Do not preserve block incremental if file is less than prior block size.
If a file stored with block incremental shrinks below the prior block size then the map is useless and the entire file needs to be stored again.

In this case use the new block incremental values (even if none) rather than preserving the old ones.
2023-12-22 00:59:12 -03:00
David Steele
3cd8249dba Update warning for backup resume invalid repo file.
This warning has had a note since the C migration that it should be moved below the backup file log message, so do that.

Also update the warning message a bit to correct for tense. This message was likely in a different place originally.
2023-12-21 15:28:37 -03:00
David Steele
701865eca1 Refactor backupFile() to remove backupCopyResultReCopy.
Having two enum values for file copy makes things a bit more complicated than they need to be (especially in an upcoming commit).

Instead add a flag to indicate that the repository file was invalid since the only purpose is to trigger a warning message.
2023-12-21 15:20:03 -03:00
David Steele
a42614e8f3
Preserve partial files during block incremental delta restore.
Previously files that were smaller than the expected size were not preserved for block incremental, even though it is possible that block incremental could make use of a partial file.

One example is when a restore encounters an error. On retry the partial file can be used as a starting point rather than copying again from the beginning. Another example is restoring a backup where a file is larger than what already exists in the data directory.

Preserve any size file when block incremental will be used for the delta in order to reuse partial files when possible. If the file is smaller than expected then disable the whole-file checksum to reduce overhead.
2023-12-21 15:08:07 -03:00
David Steele
ad8febec08
Refactor backup incremental manifest generation.
This refactor should provide more clarity on what factors affect an incremental, rather that just having one big expression do it all. Overall this may be slightly more efficient since some values are reused that before were recalculated.

No behavioral changes are introduced.
2023-12-21 13:32:10 -03:00
David Steele
f3584e2143 Add tests to command/backup and info/manifest modules.
These tests exercise various interesting cases and provide coverage for proposed improvements.
2023-12-21 11:20:10 -03:00
Robert Donovan
25f14898ba
Fix overflow suppressing backup status in info output.
Writing the sz and szCplt parameters in the lock file used jsonWriteUInt64() but reading these parameters used jsonReadUInt(). This caused a silent exception for any backups larger than MAX_UINT and prevented the info command from reporting progress.

Correct this so the reads are symmetric and verified before/after with a test.
2023-12-21 10:16:13 -03:00
David Steele
8af3c1c9ac Use original file size to log size changes during backup.
c9703b35 added logging for file size changes during backup. Later 5ed6f8df added the sizeOriginal member to ManifestFile, which arguably is better to use for logging rather than size before backup since it will always contain the original size. Size could in theory be modified for deduplication purposes.

Update logging to use sizeOriginal.
2023-12-17 13:15:03 -03:00
David Steele
bb6e5164ee Add block incremental test where timestamp changes but file is the same.
If delta is not enabled, then the timestamp is used to determine if a file has changed. If the timestamp changes but the file is the same then the prior map will be stored unchanged in the new backup. This is not quite as bad as storing the entire file but it is obviously not ideal.

This will be fixed in a future commit, but add the test now to show the current behavior.
2023-12-16 11:42:27 -03:00
Georgy Shelkovy
02eea555c7
Skip files truncated during backup when bundling.
In bundle mode pgBackRest skips files of zero size, that is, it does not queue them for copying.

After splitting the files into bundles, pgBackRest launches one or more processes that directly perform the backup, namely, read the files and, if necessary, write them to the bundles.

If during the time between the distribution of all files among bundles and the direct copying of a file to a bundle, this file of non-zero size was truncated to zero size (for example, when the table was truncated), then pgBackRest still unconditionally places such a zero-size file in the bundle, taking up space in it equal to the size of the headings, and additionally writes the original file size to the manifest.

In debug build an assertion was added, that does not allow zero-size files to be written to bundles, which leads to an error.

To solve the problem, this patch, when reading the next file, loads one buffer from the file to detect if it is zero-size. If so it marks the file as truncated and continues on to the next file.

The advantages of the solution are that, firstly, the assert will not fire on debug builds, and secondly, we will not place zero-size files in bundles, which exactly corresponds to the specification.

The patch adds the backupCopyResultTruncate value to the BackupCopyResult enumeration to use it to indicate the result when a non-zero size file is truncated to zero size during the backup process.
2023-12-14 14:21:06 -03:00
Viktor Kurilko
89d5278b74
Add support for alternate compile-time page sizes.
Alternate pages sizes can be selected at compile-time, .e.g. 4096. While compile-time settings are generally not well tested by core, some established forks such as Greenplum use them.
2023-12-14 13:28:52 -03:00
David Steele
d205a61949 Fix flapping test on older ninja versions in test unit.
Older versions of ninja may fail to rebuild correctly when changes are made to the configuration. In this case there is an automatic retry but the unexpected log output would cause the test to fail.

For tests that are expected to succeed, check that the log is empty but also accept a retry message as long as the test does eventually succeed.

Add a new harness function, harnessLogResultEmptyOrContains(), to make this work and also clean up some adjacent code.
2023-12-01 11:54:30 -03:00
David Steele
7ce0f5a94c Use unique port for each server unit test.
If the same port is reused too quickly bind may fail with this error:

FileOpenError: unable to bind socket: [98] Address already in use

We specify SO_REUSEADDR when creating the socket but apparently this is not always enough if the port is reused very rapidly.

Fix this (hopefully) by using a unique port for each test that needs one. This does in theory limit the number of tests that can use ports, but we allow 768 per test, whereas the test that uses the most ports is common/io-tls with 4.
2023-11-30 16:43:09 -03:00
David Steele
a14732789b Output coverage report on test failure in CI.
This allows analysis of coverage failures that only happen in CI. It is not ideal since the report needs to be copied from the log output into an HTML file where it can be viewed, but better than nothing.
2023-11-29 09:31:57 -03:00
David Steele
cb6bceb9f1 Improve comments in socket test harness. 2023-11-28 16:38:42 -03:00
David Steele
70e15dacc7 Allow custom type/message for errRetryAdd().
It may be useful to customize the message or add a message that was never thrown. The latter case will be used in an upcoming commit.
2023-11-28 16:35:37 -03:00
David Steele
85bc9f27d8 Begin v2.50 development. 2023-11-27 09:06:53 -03:00
David Steele
3cb891e3ca v2.49: Remove PostgreSQL 9.3 Support
Bug Fixes:

* Fix regression in retries. (Reviewed by Stephen Frost. Reported by Norman Adkins, Tanel Suurhans, Jordan English, Timothée Peignier.)
* Fix recursive path remove in SFTP storage driver. (Fixed by Reid Thompson. Reviewed by Stephen Frost. Reported by Luc.)

Improvements:

* Remove support for PostgreSQL 9.3. (Reviewed by Stephen Frost.)

Documentation Features:

* Document maintainer options. (Reviewed by Stefan Fercot.)
* Update point-in-time recovery documentation for PostgreSQL >= 13.

Test Suite Improvements:

* Allow config/load unit test to run without libssh2 installed. (Contributed by Reid Thompson. Reviewed by David Steele. Suggested by Wu Ning.)
2023-11-27 08:55:56 -03:00
David Steele
7d51228bf5 Migrate backupFile() tests in command/backup module.
The backupFile() tests were written before the bulk of the backup command had been migrated to C. Some of them have been migrated to the complete backup tests, but others were left because there was no way to make changes to files during a backup.

Now that we have the backup script harness introduced in 337da35a it is now possible to migrate all the tests. The new tests are better because they not only test backupFile() but all the functions upstream and downstream of it.
2023-11-24 17:07:49 -03:00
David Steele
337da35ab2 Add test to show behavior of bundled files truncated during backup.
This behavior violates an assertion but is completely possible with the current implementation. This behavior will be fixed in a future commit, but for now at least test how it works correctly and remove the assertion so the test runs without error.

Also add a new harness that allows changes during the backup to be scripted.
2023-11-24 12:25:40 -03:00
David Steele
ac78b96583 Remove unused fields from backupJobResult() test in command/backup unit.
These fields were not used because of the noop so it was hard to keep them up to date. Rather than attempt to do so, just remove them and add a comment to explain why they are missing.
2023-11-18 11:12:41 -03:00
Reid Thompson
c4dc4665f8
Fix recursive path remove in SFTP storage driver.
storageSftpPathRemove() used LIBSSH2_FX_FAILURE to determine when it was attempting to unlink a directory, but it appears that LIBSSH2_FX_PERMISSION_DENIED is also valid for this case.

Update storageSftpPathRemove() to accept either error and adjust tests.
2023-11-18 10:47:58 -03:00
Reid Thompson
e2b734eff9
Allow config/load unit test to run without libssh2 installed.
Add additional #ifdef HAVE_LIBSSH2 wrapping around tests requiring libssh2 in loadTest.c.
2023-11-16 12:50:09 -03:00
Georgy Shelkovy
05207bb8e4
Fix storageReadRemote() to return actual read bytes.
All storage interface read methods should return actual read bytes. This patch refactors storageReadRemote() to eliminate duplicated code and return actual read bytes. The return value is calculated as the number of bytes written to the passed buffer.

This is technically a bug but does not express as an issue currently because this return value is not being used. It will be used in the future, though, so it needs to be fixed.
2023-11-15 09:41:40 -03:00
David Steele
ea317df5d9 Remove old version conditionals from user guide.
The user guide does not need to build for EOL versions of PostgreSQL, so remove some conditionals used to support versions older than 12.
2023-11-11 10:33:09 -03:00
David Steele
eb69e2ee63 Update point-in-time recovery documentation for PostgreSQL >= 13.
PITR changed in PostgreSQL 13 to error when the recovery target is not reached. Update the documentation to work with PostgreSQL >= 13 as well as < 13.

Also update the versions built for RHEL and Debian since PostgreSQL 11 is now EOL.
2023-11-10 17:00:57 -03:00
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