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

2304 Commits

Author SHA1 Message Date
Cynthia Shang
6be7e6fde5 Fix misplaced String declarations. 2019-10-01 10:25:08 -04:00
David Steele
309ae66e2f Remove unneeded static declarations and use sizeof() where appropriate. 2019-10-01 08:47:56 -04:00
Cynthia Shang
f96c54c4ba Add info command set option for detailed text output.
The additional details include databases that can be used for selective restore and a list of tablespaces and symlinks with their default destinations.

This information is not included in the JSON output because it requires reading the manifest which is too IO intensive to do for all manifests.  We plan to include this information for JSON in a future release.
2019-09-30 12:39:38 -04:00
David Steele
33ec5a3aac Sort lists where it might help performance.
Most of these lists should be quite small with the exception of the list in get.c, but it doesn't cost much to sort them and may help in corner cases we have not thought of.
2019-09-29 09:05:55 -04:00
David Steele
a58635ac02 Move C performance tests out of unit tests.
Performance tests were being done in unit tests until there was a better place to put them.

Now there is, so move them there.
2019-09-28 14:24:27 -04:00
David Steele
f1ba428fb0 Add performance test capability in C with scaling.
Scaling allows the starting values to be increased from the command-line without code changes.

Also suppress valgrind and assertions when running performance testing.  Optimization is left at -O0 because we should not be depending on compiler optimizations to make our code performant, and it makes profiling more informative.
2019-09-28 14:02:12 -04:00
David Steele
004ff99a2d Identify Perl performance test by appending -perl.
This is intended to differentiate the upcoming C performance tests from the Perl performance tests that will eventually be migrated.
2019-09-28 13:17:21 -04:00
David Steele
cb62bebadf Use bsearch() on sorted lists rather than an iterative method.
bsearch() is far more efficient than an iterative approach except in the most trivial cases.

For now insert will reset the sort order to none and the list will need to be resorted before bsearch() can be used.  This is necessary because item pointers are not stable after a sort, i.e. they can move around.  Until lists are stable it's not a good idea to surprise the caller by mixing up their pointers on insert.
2019-09-28 10:08:20 -04:00
David Steele
d3d2a7cd86 Add line number and fix spacing in TEST_LOG*() macros. 2019-09-28 09:57:06 -04:00
David Steele
afc483ef86 Clarify which timeline should be used for timeline integration test. 2019-09-27 13:37:59 -04:00
David Steele
0a4122c77d Add reviewer. 2019-09-27 13:34:59 -04:00
Cynthia Shang
6355451870 Fix old option name in documentation. 2019-09-27 13:33:14 -04:00
David Steele
d82102d6ef Add explicit promotes to recovery integration tests.
PostgreSQL 12 will shutdown in these cases which seems to be the correct action (according to the documentation) when hot_standby = off, but older versions are promoting instead.  Set target_action explicitly so all versions will behave the same way.

This does beg the question of whether the PostgreSQL 12 behavior is wrong (though it matches the docs) or the previous versions are.
2019-09-27 13:04:36 -04:00
David Steele
833d0da0d9 Store recovery file name in integration when testing preserve recovery.
This makes the test a little more maintainable and is friendly with the changes needed for PostgreSQL 12.
2019-09-27 12:29:33 -04:00
David Steele
80eb561caf Add missing PostgreSQL 11 control/WAL versions in Perl tests.
These values don't seem to be used for testing but better to be tidy.
2019-09-27 09:45:11 -04:00
David Steele
d6a6d93a04 Add PostgreSQL 12 to u18 container.
This does not add PostgresQL 12 support; it simply adds PostgreSQL 12 to the u18 container for development and testing.
2019-09-27 09:35:59 -04:00
David Steele
03a7bda511 Refactor recovery file generation.
Separate the generation of recovery values and formatting them into recovery.conf format.  This is generally a good idea, but also makes the code ready to deal with a different recovery file in PostgreSQL 12.

Also move the recovery file logic out of cmdRestore() into restoreRecoveryWrite().
2019-09-27 09:19:12 -04:00
David Steele
cf1e96e827 Refactor handling of ignored files in restore delta cleanup.
Replace the boolean logic with a simple list that will be checked to see if the file should be ignored.
2019-09-27 08:50:33 -04:00
David Steele
c41fb575fb Add standby restore type.
This restore type automatically adds standby_mode=on to recovery.conf.

This could be accomplished previously by setting --recovery-option=standby_mode=on but PostgreSQL 12 requires standby mode to be enabled by a special file named standby.signal.

The new restore type allows us to maintain a common interface between PostgreSQL versions.
2019-09-26 17:39:45 -04:00
David Steele
8979336819 Comment out unprivileged user documentation.
We haven't had the time to complete this documentation and it has suffered bit rot.

This prevents us from building the docs on PostgreSQL >= 11 so just comment it all out until it can be updated.
2019-09-26 16:02:39 -04:00
David Steele
451ae397be The restore command is implemented entirely in C.
For the most part this is a direct migration of the Perl code into C.

There is one important behavioral change with regard to how file permissions are handled.  The Perl code tried to set ownership as it was in the manifest even when running as an unprivileged user.  This usually just led to errors and frustration.

The C code works like this:

If a restore is run as a non-root user (the typical scenario) then all files restored will belong to the user/group executing pgBackRest. If existing files are not owned by the executing user/group then an error will result if the ownership cannot be updated to the executing user/group. In that case the file ownership will need to be updated by a privileged user before the restore can be retried.

If a restore is run as the root user then pgBackRest will attempt to recreate the ownership recorded in the manifest when the backup was made. Only user/group names are stored in the manifest so the same names must exist on the restore host for this to work. If the user/group name cannot be found locally then the user/group of the PostgreSQL data directory will be used and finally root if the data directory user/group cannot be mapped to a name.

Reviewed by Cynthia Shang.
2019-09-26 07:52:02 -04:00
Cynthia Shang
92e48c856a Add missing asserts. 2019-09-26 07:27:07 -04:00
David Steele
f2781bdad4 Allow documentation to be built without encryption.
This is mainly useful for testing, where an encrypted repo is a real nuisance.
2019-09-25 16:38:13 -04:00
David Steele
e968acbdd7 Fix outdated comment.
This was probably missed when a new test was added and the timeline was updated.
2019-09-24 16:55:11 -04:00
David Steele
6af64df9b6 Thoughts on repository version 6. 2019-09-23 19:26:24 -04:00
David Steele
71349c89ae Add TEST_TITLE() macro.
This macro displays a title for each test.  A test frequently has multiple parts and it was hard to tell which subparts went together.  We used ad hoc indentation to do this.

Anything that is a not a title is automatically indented so manually indenting is not longer needed.  This should make the tests and the test output easier to read.
2019-09-23 17:56:17 -04:00
David Steele
2fd2fe509f Add TEST_RESULT_LOG*() and TEST_SYSTEM*() macros.
These macros encapsulate the functionality provided by direct calls to harnessLogResult() and system().  They both have _FMT() variants.

The primary advantage is that {[path]}, {[user]}, and {[group]} will be replaced with the test path, user, and group respectively.  This saves a log of strNewFmt() calls and makes the tests less noisy.
2019-09-23 17:20:47 -04:00
David Steele
d3a7055ee5 Only enable test.pl --debug-test-trace option when --debug also enabled.
The other way makes no sense and leads to compile errors since --debug-test-trace requires some code that is only enabled by --debug.
2019-09-23 15:15:04 -04:00
David Steele
072aeb8109 Add LFs to storage list tests.
This makes the diffs easier to read when testing.
2019-09-23 15:10:31 -04:00
David Steele
c969137021 Migrate backup manifest load/save to C.
The backup manifest stores a complete list of all files, links, and paths in a backup along with metadata such as checksums, sizes,
timestamps, etc.  A list of databases is also included for selective restore.

The purpose of the manifest is to allow the restore command to confidently reconstruct the PostgreSQL data directory and ensure that
nothing is missing or corrupt.  It is also useful for reporting, e.g. size of backup, backup time, etc.

For now, migrate enough functionality to implement the restore command.

Reviewed by Cynthia Shang.
2019-09-23 13:50:46 -04:00
David Steele
5b64c93e8b Add local option for cfgExecParam().
cfgExecParam() was originally written to provide options for remote processes.  Remotes processes do not have access to the local config so it was necessary to pass every non-default option.

Local processes on the other hand, e.g. archive-get, archive-get-async, archive-push-async, and local, do have access to the local config and therefore don't need every parameter to be passed on the command-line.  The previous way was not wrong, but it was overly verbose and did not align with the way Perl had worked.

Update cfgExecParam() to accept a local option which excludes options from the command line which can be read from local configs.
2019-09-20 17:50:49 -04:00
David Steele
3f18040aab Rename MANIFEST_FILE to BACKUP_MANIFEST_FILE.
This is a bit more descriptive and avoids a naming conflict in the new C manifest code.
2019-09-20 08:13:36 -04:00
David Steele
174cb7b3af Add strPathAbsolute() and strLstRemoveIdx().
strPathAbsolute() generates an absolute path from an absolute base path and an absolute/relative path.

strLstRemoveIdx() is a support function based on lstRemoveIdx().
2019-09-19 22:42:28 -04:00
David Steele
9421493d09 Allow resets when generating local/remote command options.
Somehow this was left out of the original implementation, but it is particularly important for certain types of restores.
2019-09-19 22:34:12 -04:00
David Steele
e24b2e3f4d Only test timestamps for files.
In general we don't care about path and link times since they are easily recreated when restoring.

So, outside of storageInfo() we don't need to bother testing them.
2019-09-18 22:23:04 -04:00
David Steele
54638e8704 Add strLstRemove().
Allow a string to be removed from a StringList using the underlying lstRemove().
2019-09-18 22:17:22 -04:00
David Steele
a6a42b18a9 Use switch instead of if else tree in jsonFromKvInternal().
This is more efficient but more importantly it is easier to read.
2019-09-18 22:09:49 -04:00
David Steele
60d93df503 Use a callback to feed jobs to ProtocolParallel.
Loading jobs in advance uses a lot of memory in the case that there are millions of jobs to be performed.  We haven't seen this yet, but with backup and restore on the horizon it will become the norm.

Instead, use a callback so that jobs are only created as they are needed and can be freed as soon as they are completed.
2019-09-18 07:15:16 -04:00
David Steele
ce1c7b0252 Ignore write errors when the ls command is writing to stdout.
It's possible (even likely) that the ls output is being piped to something like head which will exit when it gets what it needs and leave us writing to a broken pipe.

It would be better to just ignore the broken pipe error but currently we don't store system error codes.
2019-09-17 21:04:38 -04:00
Cynthia Shang
8675699d08 Add FAQ for time-based Point-in-Time Recovery. 2019-09-16 14:09:53 -04:00
Cynthia Shang
49b421d372 Add documentation clarifications regarding standby repositories.
Clarify that placing the repository on a standby is not a robust configuration and recommend against it.
2019-09-16 13:56:25 -04:00
Cynthia Shang
09ef03b7ef Add FAQ regarding backup-standby. 2019-09-15 08:27:38 -04:00
Luca Ferrari
f9c8bd31de Add required FreeBSD header. 2019-09-14 14:10:04 -04:00
Cynthia Shang
56bf9d0566 Update HINT messages to conform to new standard detailed in CODING.md. 2019-09-14 12:21:08 -04:00
Cynthia Shang
c5f496b903 Rename parameter processId to processIdx in harnessFork.h for clarity. 2019-09-14 11:56:29 -04:00
David Steele
f57e119b25 Document the relationship between db-timeout and protocol-timeout.
Contributed by Cynthia Shang.
Suggested by James Chanco Jr.
2019-09-13 12:28:39 -04:00
David Steele
15d04ca19c Add recursion and json output to the ls command.
These features finally make the ls command practical.

Currently the JSON contains only name, type, and size.  We may add more fields in the future, but these seem like the minimum needed to be useful.
2019-09-12 16:29:50 -04:00
David Steele
e45baa1830 Add sorting, filters, and recursion to storageInfoList().
These are needed for the ls command and are also useful for testing.
2019-09-12 16:03:05 -04:00
David Steele
92365fb801 Disable missing-field-initializers warnings in unit testing.
This warning gives very unpredictable results between compiler versions and seems unrealistic since most of our structs are zeroed for initialization.

This warning has been disabled in the Makefile for a long time.
2019-09-12 15:55:18 -04:00
David Steele
f809d2f008 Ignore apt-get update errors in Travis CI.
Broken vendor packages have been causing builds to break due to an error on apt-get update.

Ignore errors and proceed directory to apt-get install.  It's possible that we'll try to reference an expired package version and get an error anyway, but that seems better than a guaranteed hard error.
2019-09-12 15:16:42 -04:00