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

3150 Commits

Author SHA1 Message Date
David Steele
fdf1c299f9 Remove unused VerifyFileResult struct. 2021-01-22 11:51:36 -05:00
David Steele
b23a2a0baf Use uintptr_t in ASSERT_ALLOC_VALID() to avoid pointer arithmetic.
Clang justifiably complains about pointer arithmetic on a known NULL value during testing. We know this is fine but use uintptr_t to silence the warnings.

Found on MacOS M1.
2021-01-22 10:48:22 -05:00
David Steele
185a508f44 Add format attribute to stackTraceFmt().
Let the compiler know this is a printf-style function so a non-literal format is allowed.

Found on MacOS M1.
2021-01-22 09:50:29 -05:00
David Steele
a5ebaab249 Use enum for signalType in exitSignalName().
This should have been an enum all along but was somehow missed.

Found on MacOS M1.
2021-01-22 09:16:36 -05:00
David Steele
547b297387 Use uint variant to store enum in verifyProtocol().
Avoid the need for a cast by using a matching type.

Found on MacOS M1.
2021-01-22 09:04:28 -05:00
David Steele
8d883ea76b Fix return type for PQresultStatus().
Found on MacOS M1.
2021-01-21 18:30:24 -05:00
David Steele
bc25e9bf05 Change variant to uint when building option lists.
Enums are uints on most platforms so this works without casting.

Found on MacOS M1.
2021-01-21 17:36:33 -05:00
David Steele
0869b8afff Cast result of cfgParseOptionId() to int.
It would probably make more sense to add an "invalid" enum value, but at least fix the cast for now. The function was originally designed to interface with Perl which required -1 in this case.

Found on MacOS M1.
2021-01-21 17:29:24 -05:00
David Steele
3f72eca909 Remove useless casts of vsnprintf() return value.
The return value is not checked because we are happy with a truncated result in this case, which is guaranteed by passing the buffer size.

Found on MacOS M1.
2021-01-21 17:26:12 -05:00
David Steele
6a992a5884 Add missing mode_t casts.
Found on MacOS M1 where mode_t is short.
2021-01-21 17:23:24 -05:00
David Steele
4b3200961e Fix cast for timeval.tv_usec.
Found testing on MacOS M1.
2021-01-21 17:20:13 -05:00
David Steele
6f529155b6 Remove useless assignment. 2021-01-21 17:17:03 -05:00
Cynthia Shang
f32eb9b94e
Partial multi-repository implementation.
Multi-repository implementations for the archive-push, check, info, stanza-create, stanza-upgrade, and stanza-delete commands.

Multi-repo configuration is disabled so there should be no behavioral changes between these commands and their current single-repo implementations.

Multi-repo documentation and integration tests are still in the multi-repo development branch. All unit tests work as multi-repo since they are able to bypass the configuration restrictions.
2021-01-21 15:21:50 -05:00
Cynthia Shang
1333748550 Fix incorrect variable in parameter logging. 2021-01-21 14:20:39 -05:00
David Steele
d3d484b27c Use standard environment variable format in hrnCfgEnv*().
The option portion was not being capitalized or replacing - with _.

The parser does not care, but in cases where we have mixed hrnCfgEnv*()/setenv() calls the env variable might not get cleared, which can lead to funny test results.
2021-01-21 11:59:19 -05:00
David Steele
4e56948128 Compensate for numeric auto conversion in newer Perls. 2021-01-19 12:07:05 -05:00
David Steele
d9fae09848 Remove errant todo comment.
The test is not a duplicate of the one above because it adds the archive-async option.
2021-01-19 11:59:47 -05:00
David Steele
a1365b26d4 Remove duplicate mkdir for /tmp/pgbackrest in Vagrantfile. 2021-01-18 23:41:09 -05:00
David Steele
8322dfd7af Add pkg-config package to Vagrantfile.
Newer Ubuntu versions do not install this package by default.
2021-01-18 23:39:14 -05:00
David Steele
49582c13cf Use test lock path in archive-get test.
The default lock path should fail since the test VM gives ownership of /tmp to root.

For some reason this was not working as expected under u18 but it fails under u20.
2021-01-18 23:05:55 -05:00
David Steele
065b5f93ae Improve test coverage list handling.
All unit tests now require full coverage so the "full" keyword is obsolete and has been removed.

The covered code modules are simply listed, with only "no code" modules annotated.
2021-01-15 10:56:51 -05:00
David Steele
a8fb285756
Improve archive-get performance.
Check that archive files exist in the main process instead of the local process. This means that the archive.info file only needs to be loaded once per execution rather than once per file to get.

Stop looking when a file is missing or in error. PostgreSQL will never request anything past the missing file so there is no point in getting them. This also reduces "unable to find" logging in the async process.

Cache results of storageList() when looking for multiple files to reduce storage I/O.

Look for all requested archive files in the archive-id where the first file is found. They may not all be there, but this reduces the number of list calls. If subsequent files are in another archive id they will be found on the next archive-get call.
2021-01-15 10:15:52 -05:00
David Steele
38583b6414 Add cfgOptionValid() check to assert in cfgOptionIdxTest().
Skip the rest of the assert if the option is not valid since this function is intended to work with invalid options.
2021-01-15 08:59:16 -05:00
David Steele
7f263dceb7 Fix inverted cfgOption*() calls.
These currently work because repoIdx is always 0.
2021-01-15 08:30:56 -05:00
David Steele
298cc4d5e5 Remove non-conforming periods and reformat some comments. 2021-01-14 10:39:25 -05:00
David Steele
c2c702c09d Add co7 package to support llvm.
This is required for new package versions.

Also remove the obsolete 9.2 package and update the supported versions list.
2021-01-13 17:32:42 -05:00
David Steele
a57e0be395 Add duplicate WAL test to synchronous archive-get. 2021-01-13 13:01:40 -05:00
David Steele
22fd223fc3 Improve logging in archive-get command.
Append "asynchronously" to messages when the async process fetched the file (not in the actual async process log, though).

Add "repo1" to make it clear what archive we are talking about. This is not very useful by itself but soon we'll be able to add the archive id, which is very useful.

Add constants for messages that are used multiple times to ensure they stay consistent.
2021-01-13 10:24:47 -05:00
David Steele
c6aaf66e9d Add FUNCTION_LOG_RETURN_STRUCT() and update where appropriate.
The FUNCTION_LOG_RETURN() macro requires logging macros (e.g. FUNCTION_LOG_*_TYPE and FUNCTION_LOG_*_FORMAT) when returning a struct but these macros don't deliver much value since they only output the name of the struct rather than the contents. A copy of the struct is also made during this operation, which is wasteful.

FUNCTION_LOG_RETURN_STRUCT() does not make a copy of the struct and does not require any logging macros. Returned structures are logged as "struct" but this could be made more accurate using __typeof in the future.

Structures as parameters are not addressed here and work as before, i.e. they require logging macros.
2021-01-13 07:49:47 -05:00
David Steele
b21ed97982 Check for missing files in queueNeed().
Missing files would indicate that another process is running on the same spool path, which would be a very bad thing.

This check doesn't cost any additional I/O so it seems like a good idea.
2021-01-12 18:47:19 -05:00
David Steele
aae6f06bcf Add tests for the archive-get command.
Provide additional coverage for less common use cases.
2021-01-12 18:20:28 -05:00
David Steele
aeee83044d
Fix resume after partial delete of backup by prior resume.
If files other than backup.manifest.copy were left in a backup path by a prior resume then the next resume would skip the backup rather than removing it. Since the backup path still existed, it would be found during backup label generation and cause an error if it appeared to be later than the new backup label. This occurred if the skipped backup was full.

The error was only likely on object stores such as S3 because of the order of file deletion. Posix file systems delete from the bottom up because directories containing files cannot be deleted. Object stores do not have directories so files are deleted in whatever order they are provided by the list command. However, the issue can be reproduced on a Posix file system by manually deleting backup.manifest.copy from a resumable backup path.

Fix the issue by removing the resumable backup if it has no manifest files. Also add a new warning message for this condition.

Note that this issue could be resolved by running expire or a new full backup.
2021-01-12 12:38:32 -05:00
David Steele
96fd678662
Add job-retry and job-retry-interval options.
These options specify the number of local worker job retries and the retry interval after one immediate retry.

There is some value in allowing retries to be specified by the user but for the most part these options are for suppressing retries during testing, which can save a lot of time. The bug introduced in d1d25c7 and fixed in 8b86d5e also suggests it is better not to use retries in tests.

Remove the default delayed retries for archive-get/archive-push, leaving only the immediate retry. These commands are retried by PostgreSQL so it doesn't make sense to do too many retries internally.

These options are currently internal.
2021-01-11 15:15:25 -05:00
David Steele
8b86d5ea7a Restore storageRepo() call in archiveGetProtocol().
This call was removed by d1d25c71, which worked for archivePushProtocol() and verifyProtocol() since the encryption options are passed from the main process.

archiveGetProtocol() still retrieves these options in the local process so the repo storage must be loaded first.
2021-01-11 11:34:03 -05:00
David Steele
f35d69c1c7 Refactor common/archiveGet unit test.
The test was pretty old and written in stages during the migration, so storage use was a bit archaic and the organization was poor.

Update using the new storage macros and reorganize the tests to provide better coverage.
2021-01-08 16:48:32 -05:00
David Steele
8567b7f733 Make archive-get locality error generate a global.error file.
Moving this error into the try block ensures that a global.error file is generated, which will be seen by archive-get.
2021-01-08 16:29:56 -05:00
David Steele
7d3d6ecbe1 Add storage test macros for common operations.
The macros should make it much easier to write complex tests, especially when compression and encryption are involved.

Update the command/archiveGet test to show how the new macros are used.
2021-01-08 16:14:26 -05:00
David Steele
97c260bb56 Add TEST_RESULT_STRLST_*() unit test macros.
This avoids the need for strLstJoin() when testing lists.

Lists are \n delimited (rather than command or pipe) so that non-trivial lists can be more easily diff'd.
2021-01-08 12:49:33 -05:00
David Steele
1ef36b4032 Add clarifications to unit test string diff messages. 2021-01-08 10:54:17 -05:00
David Steele
17e29eb1bd Improve formatting of unit test titles.
Add separation and some visual cues to help identify the start of a test.

Also add a counter which can be used to search for a specific test, which is useful if there is a lot of debug output to search through.
2021-01-08 10:45:26 -05:00
David Steele
dc0284412b Add test paths for pg, repo, and spool.
These may be used as standard locations for these paths in tests.
2021-01-08 10:35:26 -05:00
David Steele
6bdbcdc7fe Create TEST_PATH define in test.c.
This allows paths to be constructed without using sprintf(), which makes the tests simpler and faster.
2021-01-08 10:32:57 -05:00
David Steele
ca9c1707f0 Remove forks from command/archive-get test.
These were required to deal with the legacy Perl code being unable to load new options between tests.

The C code does not have this issue so remove the forks and update process ids in the log tests.
2021-01-06 11:36:42 -05:00
David Steele
6e7a3eb383 Remove archive-timeout from test in mock/archive.
No timeout is expected here but the small timeout prevents errors from being thrown.

This is not a bug since the error would be thrown on the next archive-get call but it does make the tests harder to debug when there is an error.

It is not clear why there was a timeout here at all. It is likely cruft from a prior test or a copy/paste error.
2021-01-05 18:11:28 -05:00
Cynthia Shang
656e711296
Remove duplicate tests from command/infoTest.
Tests that are duplicated are being removed from the info command unit tests. Specifically tests where the only thing different was whether a lock was held or not which affects only the status display. Removing these tests will reduce churn in the upcoming multi-repo support.
2021-01-05 15:14:16 -05:00
David Steele
a7491182dc Set build-max to 2 for Github actions.
Github runners only provide 2 virtual CPUs so the default build-max of 4 is not ideal.
2021-01-04 09:18:17 -05:00
David Steele
9345fe4cb2 Update LICENSE.txt and PostgreSQL copyright for 2020. 2021-01-03 13:56:37 -05:00
David Steele
af17bc4b6d Update test to work with different collations.
The data returned by the protocol has not been sorted yet so it is vulnerable to differences in collation.

Multiple records are not needed for this test so limit it to one path to solve this issue.
2020-12-31 15:34:07 -05:00
David Steele
0e1612cda1 Remove explicit command lists where they equal the default.
This reduces noise in the file and new commands will automatically get these options.
2020-12-31 12:29:11 -05:00
David Steele
108038292c Audit options valid for expire command. 2020-12-31 12:13:20 -05:00