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

3537 Commits

Author SHA1 Message Date
David Steele
590e759968 Rename stringz.h to stringZ.h.
This is more consistent with our file naming conventions.
2021-08-19 11:57:37 -04:00
David Steele
0354144c90 Add instructions for dev builds to stress test in user guide. 2021-08-19 11:35:49 -04:00
David Steele
9b45df7057 Rearrange MemContext struct members to save space on 64-bit.
On 64-bit systems this saves a bit of space (10%) due to alignment. 32-bit systems see no benefit.

Also add tests for the individual struct sizes.
2021-08-19 11:12:56 -04:00
David Steele
bab7a01f99 Mark contextTop static.
This variable is not used outside of the memContext module so no need for it to be extern'd.
2021-08-19 11:00:17 -04:00
David Steele
bb1ca1d309 Change ASSERT() to CHECK() in infoLoad().
Coverity complains that "Argument loaded of ASSERT() has a side effect because the variable is volatile. The containing function might work differently in a non-debug build."

It does not look like this is a real issue, but a CHECK() here is not too expensive for production so change it to silence Coverity.

Also fix a typo in the comment.
2021-08-18 13:32:16 -04:00
David Steele
9ddfcd6a6d Remove dead loop in verifyArchive().
This loop has been dead since the code was initially committed in ad79932b. It looks like it was used at one point but became dead when the enclosing if-else was added during development.

Found by Coverity.
2021-08-18 13:23:24 -04:00
David Steele
56ad427653 Add variables for build paths in the user guide.
This eliminates repetition of the build path so it can be changed more easily.

Also create the build path explicitly rather than suggest that the user do it.
2021-08-18 10:52:35 -04:00
David Steele
944a9e8ff1 Reduce memory requirements of stress test section in the user guide.
The standby memory was set to 1024mb in 86a651f9 to compensate for a memory leak in restore. The leak has been fixed (or at least mitigated) in e1e6e475 and 4fb6384f so the memory can be reduced to 512mb, the same as the primary.
2021-08-18 10:17:10 -04:00
David Steele
d69a596358 Fix infinite loop in protocolServerProcess() on error.
The error was written to the client and then another command read. If the write did not fail then the loop would never exit.

Instead exit on any error that is not raised by the command handler as we can pretty safely assume this is an unrecoverable protocol error. The command handler might throw a protocol error itself, but this should be caught in the next read or write in the main loop.
2021-08-18 09:48:37 -04:00
David Steele
9a6afe3fc1 Fix EOF behavior of ioReadSmall() to match ioRead().
If the buffer was not full at EOF then ioReadSmall() would get stuck in an infinite loop. Instead, return on EOF even if the buffer is not full.

This is not an issue in released versions since ioReadSmall() is not being used.

Also fix a comment typo.
2021-08-18 09:32:20 -04:00
David Steele
4fb6384f10 Fix more memory leaks introduced by the binary protocol in 6a1c0337.
Either of these temp mem context blocks fixes the issue of command packs not being freed, but it seems like a good idea to have both in case the code changes.
2021-08-18 08:18:11 -04:00
David Steele
e1e6e47535 Add temp mem context reset blocks in job processing loops.
Restore definitely needed to be doing cleanup, just as backup does. The archive-get, archive-push, and verify loop did not seem to be a significant source of leaks but that could change in the future so add resets.

Add temp mem context blocks in the job callbacks where they were missing.

Also switch to the prior context when creating a job, if possible, to save a move.
2021-08-18 08:07:41 -04:00
Cynthia Shang
eca2fc6958
Update config/parse test to use standard patterns. 2021-08-12 12:38:07 -04:00
Cynthia Shang
e17865a03a
Update protocol/protocol test to use standard patterns. 2021-08-12 11:57:17 -04:00
David Steele
86a651f9b0 Add optional stress test section to the user guide.
This is intended to provide pre-release stress-testing. Include container memory limits to help check for memory leaks.

Also add parallelism to make for faster builds.
2021-08-12 07:49:59 -04:00
David Steele
a0bdfa436c
Log backup file total and restore size/file total.
The backup size was a bit off because it did not include any files (e.g. backup_label, WAL files) that were added to the manifest after the main copy. To fix this move the log message to the very end of the backup.

Add size/file total log message to restore since it did not exist before.
2021-08-11 13:39:36 -04:00
David Steele
6ab18dc0fa
Rearrange backup documentation in user guide.
Remove the "Automatic Stop Option" section since it only applies to PostgreSQL <= 9.6, which will soon be EOL. Since we no longer build the user guide for PostgreSQL < 10 this section was no longer being tested. The stop-auto option is still documented in the reference.

Move the "Fast Start Option" to "Quick Start - Perform Backup". This is a commonly-used option so it makes sense to mention it earlier. This also makes the backups run more quickly. In the worst case, backups in "Quick Start - Perform Backup" could take minutes to start

Move the "Archive Timeout" section to "Quick Start - Perform Backup" since it is the last section in "Backup".
2021-08-11 12:59:25 -04:00
David Steele
f716cb6f4f Fix use after free introduced by the binary protocol in 6a1c0337.
The user and group were stored in a temp reset mem context so they could get freed if there were enough files to trigger the reset in storageRemoteInfoList().

Allocate user and group in a mem context provided by the caller to prevent them being freed prematurely.
2021-08-10 14:22:38 -04:00
David Steele
6789ec420e Add additional checks to performance/storage test.
The storageInfoList() test was broken by 54c4eb0c when the remote was changed to use writeable storage. Since the test driver was being injected into the wrong location, new default storage was created and the test effectively did nothing but still "succeeded".

To prevent this type of regression, add checks to ensure the expected test driver is being used and the callback runs the expected number of times.
2021-08-10 10:37:37 -04:00
David Steele
0eae815ef4 Protect against mixed FUNCTION_TEST* and FUNCTION_LOG* macros.
If the macros are mixed then the debug stack may not be cleaned up correctly. Add variables to ensure that the macros cannot be mixed.

Fix cases where the macros were mixed and add one missing semicolon.
2021-08-09 17:29:09 -04:00
David Steele
c8492aac41 Cleanup inherited clients in protocol test harness.
Cleanup all clients inherited from the parent process so they cannot be accidentally used to send messages to servers that do not belong to this process.

We need to do this carefully so that exit commands are not sent and processes are not terminated, so clear the mem context callback on each object before freeing it.
2021-08-09 17:11:39 -04:00
Cynthia Shang
71b654fc29
Fix links and update child process example.
Removed colon from example titles to fix links, fixed test.yml link, and updated the example for the parent/child test process to use the latest macros instead of sleep().
2021-08-09 16:56:06 -04:00
Cynthia Shang
f653b59664
Update db/db test to use standard patterns. 2021-08-09 16:35:48 -04:00
David Steele
2d5cbfc731 Fix memory leaks introduced by the binary protocol in 6a1c0337.
Additional buffers were being allocated for the protocol messages but not being freed.

Most of the allocations were fairly harness, but storageRemoteOpenReadProtocol() and storageWriteRemote() were problematic because they were allocating (but not freeing) buffers equal to the transfer size of the file. Depending on compression, this could be a lot of memory. Though the memory was freed after each file transfer the aggregate of memory used during parallel processing could overwhelm systems with constrained memory.

Also allocate larger initial buffers in storageRemoteOpenReadProtocol() and storageWriteRemote() so a reallocation is not needed.
2021-08-09 09:28:17 -04:00
David Steele
33775e53c9 Fix test added for lstComparatorZ() in 9abf6a27.
strcmp() returns < 0 and > 0 but these are not guaranteed to be -1 and 1.
2021-08-06 11:26:12 -04:00
David Steele
0679128461 Add linefeeds around content even when not in pretty mode.
This makes the generated HTML much more readable in diffs because a single word change will not change a line with potentially many tags.

The output is now slightly larger because of the extra linefeeds.
2021-08-06 09:48:55 -04:00
David Steele
935de1e7a0
Only pass selected repo options to the remote.
Options for other repos can cause conflicts and should never be used. Each remote can address exactly one repo or pg cluster.

Also fix an outdated comment.
2021-08-05 14:29:26 -04:00
David Steele
155ef85013
Fix incorrect host names in user guide.
pg1 was incorrectly used instead of {[host-pg1]} which meant the wrong host name was displayed.

Also, the install block was installing packages to the build host no matter which host was specified.
2021-08-03 14:48:22 -04:00
Cynthia Shang
07f0a5901f Fix typo. 2021-08-03 11:48:58 -04:00
David Steele
74c0c44fc8 Migrate error code generation to C.
Parse src/build/error.yaml and write to src/config/error.auto.h and src/config/error.auto.c.
2021-08-02 18:32:11 -04:00
David Steele
aaa9136820 Update error.yaml comment to remove Perl reference. 2021-08-02 18:16:57 -04:00
David Steele
930fee3a0c Move bldStrId() into a C file.
This function was included in a header but not declared inline, so linker errors happened when the header was included into more than one file.

Because of the setjmp() in TRY_BEGIN() it can't be inlined so put it in a C file.

Also add some missing headers.
2021-08-02 17:49:05 -04:00
David Steele
13de361567 Improve comments. 2021-08-02 17:41:40 -04:00
David Steele
7542eadc9f Increase timeouts in storage/remote test.
There have been intermittent failures on f33 (with coverage) but not on u16 (without coverage).

Reproducing this reliably has been very difficult, so just try increasing the timeouts. This is based on the observation that tests with coverage take longer than tests without, which may lead the f33 tests to fail if CI is running slower than usual.

This will not increase the runtime of the test unless there is an error.
2021-08-02 14:48:31 -04:00
David Steele
4e71c077f1 Clean src path in test.pl before attempting vpath builds.
If configure/make has been run in the src path it can conflict with tests, which may require different build options.

Also add a comment when rebuilding for code generation.
2021-08-02 10:00:42 -04:00
David Steele
c192ec4561 Fix rsync include list removed from test.pl in 9ee9b1fa.
This caused the include list to be ignored and all files to be rsync'd, which worked but took a much longer.
2021-08-02 08:52:49 -04:00
David Steele
2dfca8a61f Remove unused struct member noted in f3f0c64a.
This variable is used to build the final command role lists, but is not needed after parsing completes.
2021-07-30 18:15:07 -04:00
David Steele
9abf6a2709 Add lstComparatorZ().
Works just like lstComparatorStr() but with zero-terminated strings.
2021-07-30 18:08:04 -04:00
David Steele
8bca6946b4 Add line and column to build yaml error messages.
This makes it much easier to debug errors in the yaml files.
2021-07-30 17:51:56 -04:00
David Steele
b47a07b8b9 Remove generated config.auto.c file.
This file duplicated the command list that already exists in parse.auto.c.

Combine the data from config.auto.c into parse.auto.c and adjust the interface functions as needed. Quite a few were able to be moved to parse.c as static.
2021-07-29 14:40:30 -04:00
David Steele
e32f9e146b
Add check for test path inside repo path.
If the test path is inside the repo path then it can cause strange issues during testing because the entire repo path is duplicated into the test path so that all tests see a consistent view of the repo.

Another solution might be to pick a better test path name and exclude it from the rsync, but this fix at least addresses the immediate issue.
2021-07-29 11:09:51 -04:00
David Steele
58cc470b3e Remove code made obsolete by f3f0c64a.
The code in DocExecute.pm appears to have been obsolete for a long time.
2021-07-29 08:14:17 -04:00
David Steele
f3f0c64a78 Complete migration of config code generation to C.
This was started in c5ae047e but did not include generation of parse.auto.c.

The parser has also been improved with better errors and multiple passes to reduce dependency on ordering and produce and cleaner output.

Option order resolution now includes cycle detection.
2021-07-28 19:59:23 -04:00
David Steele
7517c5fef8 Fix miscalculation in time option command defaults.
These defaults were not getting the multiplier so the timeouts were much lower than expected.

Since PostgreSQL retries get/push this was probably not a big deal, but it could be critical in the future for a different time value.
2021-07-28 18:53:10 -04:00
David Steele
9f3c949635 Updates to build/config/config.yaml.
Fix booleans that were set to y rather than true and defaults that were set to true instead of 1. Perl was tolerant of these but C is not.

Reorder repo-storage-verify-tls to satisfy inheritance ordering for the dependency.
2021-07-27 14:49:43 -04:00
David Steele
8ca89fb41f Use consistent separator comment spacing in parse.auto.c. 2021-07-26 14:38:55 -04:00
David Steele
52d4574460 Automatically generate option value StringIds in make build-config.
Remove strIdGenerate() since bldStrId() performs the same function without cluttering the core code. Since bldStrId() is intended to work in non-debug builds, move the validity checks for input strings out of the DEBUG block.

StringIds are generated as 5/6 bit, whichever is most efficient, for each option value. cfgOptionStrIdInternal() has been updated for this logic.
2021-07-26 12:02:31 -04:00
Cynthia Shang
eeaab6a3d1
Update config tests (except parse) to use standard patterns. 2021-07-23 16:18:50 -04:00
David Steele
947c7a84cb Refactor cmdLocal()/cmdRemote() to accept a ProtocolServer object.
This allows a local/remote to be started independently of server initialization, which will be useful for implementing new transport types, e.g. TLS.

Also remove some dead code in localTest.c.
2021-07-23 10:35:36 -04:00
David Steele
0999de0279 Move noop from protocolClientNew() to local/remote initialization.
protocolServerNew() does not automatically process a noop so this made the handshake in the constructors asymmetric. This made testing a bit confusing since an extra noop was needed when cmdLocal()/cmdRemote() were not called (since they processed the noop sent by protocolClientNew()).

The extra noops also make complex protocol negotiation (coming in a future commit) more complicated and slower because of the additional round trips.
2021-07-23 08:32:30 -04:00