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

2140 Commits

Author SHA1 Message Date
David Steele
d441061168 Create test matrix for mock/all to increase coverage and reduce tests.
The same test configurations are run on all four test VMs, which seems a real waste of resources.

Vary the tests per VM to increase coverage while reducing the total number of tests. Be sure to include each major feature (remote, s3, encryption) in each VM at least once.
2019-03-02 15:01:02 +02:00
David Steele
f7d1d4400f Create test matrix for mock/expire to increase coverage and reduce tests.
The same test configurations are run on all four test VMs, which seems a real waste of resources.

Vary the tests per VM to increase coverage while reducing the total number of tests.
2019-03-01 19:04:26 +02:00
David Steele
91622942c2 Create test matrix for mock/archive-stop to increase coverage and reduce tests.
The same test configurations are run on all four test VMs, which seems a real waste of resources.

Vary the tests per VM to increase coverage while reducing the total number of tests. Be sure to include each major feature (remote, s3, encryption) in each VM at least once.
2019-03-01 17:12:41 +02:00
David Steele
c307d9fdf9 Don't make a copy of the context name in the MemContext module.
This is very inefficient in terms of memory and time and dynamic context names were never utilized.

Just require that context names be valid for the life of the context.

In practice they are all static strings.
2019-03-01 15:58:52 +02:00
David Steele
90709dfd21 Improve performance of context and memory allocations in MemContext module.
Allocations required a sequential scan through the allocation list for both contexts and memory.  This was very inefficient since for the most part individual memory allocations are seldom freed directly, rather they are freed when their context is freed.

For both types of allocations track an index for the lowest free position.  After an allocation of the free position, a sequential search will be required for the next allocation but this is still far better than doing a scan for every allocation.

With a moderately-sized dataset (500 history entries in backup.info), there is a 237X performance improvement when combined with the f74e88bb refactor.

Before:

  %   cumulative   self
 time   seconds   seconds name
 65.11    331.37   331.37 memContextAlloc
 16.19    413.78    82.40 memContextCurrent
 14.74    488.81    75.03 memContextTop
  2.65    502.29    13.48 memContextNewIndex
  1.18    508.31     6.02 memFind

After:

  %   cumulative   self
 time   seconds   seconds name
 94.69      2.14     2.14 memFind

Finding memory allocations in order to free or resize them is the next bottleneck, but this does not seem to be a major issue presently.
2019-03-01 14:57:01 +02:00
David Steele
f74e88bba9 Use contextTop/contextCurrent instead of memContextTop()/memContextCurrent() in MemContext module.
Using the functions internally is great for abstraction but not so great for performance on non-optimized builds.

Also, the functions end up prominent in any profiled build.
2019-03-01 13:33:58 +02:00
David Steele
6ce3310f8a Update default documentation version to PostgreSQL 10.
Also update CentOS 6 and 7 versions to PostgreSQL 9.5 and 9.6 respectively.
2019-03-01 09:10:14 +02:00
David Steele
4093609241 Documentation builds on PostgreSQL 9.4-10.
More than likely 9.2-11 will work as well, but this has not been tested.

However, 11 needs work on the group permissions introduced in that version.
2019-03-01 09:00:51 +02:00
Marc Cousin
cb3b4fa24b Enable socket keep-alive on older Perl versions.
The prior method depended on IO:Socket:SSL to push the keep-alive options down to the socket but it only worked for recent versions of the module.

Instead, create the socket directly using IO::Socket::IP if available or IO:Socket:INET as a fallback.  The keep-alive option is set directly on the socket before it is passed to IO:Socket:SSL.

Contributed by Marc Cousin.
2019-02-28 14:33:29 +02:00
David Steele
0913523096 Cleanup local/remote protocol interaction from 9367cc46.
The command option was not being set correctly when a remote was started from a local.  It was being set as 'local' rather than the command that the local was running as.

Also automatically select the remote protocol id based on whether it is started from a local (use the local protocol id) or from the main process (use 0).

These were not live issues but could cause strange behaviors as new features are added that might be hard to diagnose.
2019-02-28 09:51:19 +02:00
David Steele
db4b447be8 The archive-get command is implemented entirely in C.
This new implementation should behave exactly like the old Perl code with the exception of a few updated log messages.

Remove as much of the Perl code as possible without breaking other commands.
2019-02-27 23:03:02 +02:00
David Steele
9367cc461c Migrate local command to C.
The C local is only used for C commands in the main process.

Some tweaking of the existing protocolGet() command was required. Originally the idea was to share the function for local and remote requests but the differences (as in Perl) were too great to make that practical.
2019-02-27 22:34:21 +02:00
David Steele
35abd4cd95 Add ProtocolParallel* objects for parallelizing commands.
Allows commands to be easily parallelized if the jobs are broken up into discrete, non-overlapping chunks.
2019-02-27 21:10:52 +02:00
David Steele
35acfae7c2 Add ProtocolCommand object.
This formalizes the creation of protocol commands, which was previously done by creating KeyValue objects manually.
2019-02-27 19:48:30 +02:00
David Steele
dee90d3e60 Expose handle (file descriptor) from IoRead when applicable.
Some IO objects have file descriptors which can be useful for monitoring with select().

It might also be useful to expose handles for write objects but there is currently no use case.
2019-02-27 18:11:09 +02:00
David Steele
b1957b07f3 Improve null-handling of varToLog(). 2019-02-27 18:10:18 +02:00
David Steele
ea2aef1d0c Add lstRemove() to List object.
Because it is sometimes useful to remove items from a list.
2019-02-27 18:09:21 +02:00
David Steele
4be271ea2a Improve fork harness to allow multiple children and setup pipes automatically.
There was a lot of extra boilerplate involved in setting up pipes so that is now automated.

In some cases testing with multiple children is useful so allow that as well.
2019-02-27 18:07:16 +02:00
David Steele
18b62a4220 Only run test-level stack trace by default for unit-tested modules.
This amends 70c30dfb which disabled test tracing in general.

Instead, only enable test tracing by default for modules that are being unit tested. This saves lots of time but still ensures that test tracing is working and helps with debugging in unit tests.

Also rename the option to --debug-test-trace for a clarity.
2019-02-27 17:09:19 +02:00
David Steele
3a05359087 Create test matrix for mock/stanza to increase coverage and reduce tests.
The same test configurations are run on all four test VMs, which seems a real waste of resources.

Vary the tests per VM to increase coverage while reducing the total number of tests. Be sure to include each major feature (remote, s3, encryption) in each VM at least once.
2019-02-24 07:42:41 +02:00
David Steele
6d3e18b181 Reduce expect log level in mock/stanza tests.
The expect tests were originally a rough-and-ready type of unit test so monitoring changes in the expect log helped us detect changes in behavior.

Now the stanza code is heavily unit-tested so the detailed logs mainly cause churn and don't have any measurable benefit.

Reduce the log level to DETAIL to make the logs less verbose and volatile, yet still check user-facing log messages.
2019-02-24 06:55:59 +02:00
David Steele
2f081f3ec7 Rename test modules for consistency.
The conventions for command and info tests have shifted in the C modules, though not even all the C modules got the message.
2019-02-23 18:51:52 +02:00
David Steele
d489eb87f7 Create test matrix for mock/archive to increase coverage and reduce tests.
The same test configurations are run on all four test VMs, which seems a real waste of resources.

Vary the tests per VM to increase coverage while reducing the total number of tests.  Be sure to include each major feature (remote, s3, encryption) in each VM at least once.
2019-02-23 15:59:39 +02:00
David Steele
4a7588e604 Create aliases for test VMs ordered by age.
This will allow for smarter allocation of tests in the next commit.
2019-02-23 15:13:23 +02:00
David Steele
59d7958914 Reduce expect log level in mock/archive tests.
The expect tests were originally a rough-and-ready type of unit test so monitoring changes in the expect log helped us detect changes in behavior.

Now the archive code is heavily unit-tested so the detailed logs mainly cause churn and don't have any measurable benefit.

Reduce the log level to DETAIL to make the logs less verbose and volatile, yet still check user-facing log messages.
2019-02-23 15:05:06 +02:00
David Steele
a9cbf23f4c Improve error when hostname cannot be found in a certificate.
Update error message with the hostname and more detail about what went wrong.  Hopefully this will help in diagnosing certificate/hostname issues.

Suggested by James Badger.
2019-02-23 07:28:27 +02:00
David Steele
1f66bda02e Fix non-compliant JSON for options passed from C to Perl.
We have been using a hacked-up JSON generator to pass options from C to Perl since the C binary was introduced.  This generator was not very compliant which led to issues with \n, ", etc. inside strings.

We have a fully-compliant JSON generator now so use that instead.

Reported by Leo Khomenko.
2019-02-22 12:02:26 +02:00
David Steele
70c30dfb61 Disable test-level stack trace by default.
Detailed stack traces for low-level functions (e.g. strCat, bufMove) can be very useful for debugging but leaving them on for all tests has become quite burdensome in terms of time.  Complex operations like generating JSON on a large KevValue can lead to timeouts even with generous values.

Add a new param, --debug-trace, to enable test-level stack trace, but leave it off by default.
2019-02-22 11:40:30 +02:00
David Steele
ae86e6d5b2 Add missing ToLog() coverage to String, List, and PgControl.
Missing coverage is exposed in the next commit which disables test tracing by default.
2019-02-22 11:31:37 +02:00
David Steele
a7c8906581 Fix incorrect tags. 2019-02-21 18:49:02 +02:00
David Steele
e14c0eeb65 Use driver for remote protocol introduced in da628be8.
The remote protocol was calling into the Storage object but this required some translation which will get more awkward as time goes by.

Instead, call directly into the local driver so the communication is directly driver to driver.  This still requires resolving the path and may eventually have more duplication with the Storage object methods but it seems the right thing to do.
2019-02-21 16:20:46 +02:00
David Steele
b1eb8af7d5 Resolve storage path expressions before passing to remote.
Expressions such as <REPO:ARCHIVE> require a stanza name in order to be resolved correctly.  However, if the stanza name is passed to the remote then that remote will only work correctly for that one stanza.

Instead, resolved the expressions locally but still pass a relative path to the remote.  That way, a storage path that is only configured on the remote does not need to be known locally.
2019-02-21 15:40:21 +02:00
David Steele
b4d4680f8c Allow cfgExecParam() to exclude options.
It is useful to be able to exclude an option even if it is shared by both commands.
2019-02-21 14:40:35 +02:00
David Steele
be6a3f131e Improve null-handling of strToLog().
NULL was returning {"(null)"} which was comprehensible but not very pretty.  Instead return null on NULL.
2019-02-21 14:26:06 +02:00
David Steele
1fd89f05af Add kvKeyExists() to KeyValue object.
Check if a key exists even if the value is NULL, which is the same result for a missing key.
2019-02-21 14:16:17 +02:00
Stefan Fercot
80df1114bd Fix info command missing WAL min/max when stanza specified.
This issue was a result of STORAGE_REPO_PATH prepending an extra stanza when the stanza was specified on the command line.

The tests missed this because by some strange coincidence the WAL dirs were empty for each test that specified a stanza.  Add new tests to prevent a regression.

Fixed by Stefan Fercot.
2019-02-21 12:09:12 +02:00
David Steele
1519f5b045 Add storageHelperFree() to storage helper.
Free all cached objects in the storage helper, especially the stanza name.

This clears the storage environment for tests that switch stanza names or go from a stanza name to no stanza name or vice versa. This is only useful for testing right now, but may be used in the future for commands than act on multiple stanzas.
2019-02-21 11:40:30 +02:00
David Steele
b0b5989aca Migrate remote archive-get command to C.
All required protocol commands are implemented so this is mostly a matter of enabling the feature and updating expect logs.
2019-02-20 22:57:18 +02:00
David Steele
6866ff031a Add exists() to remote storage. 2019-02-20 22:43:02 +02:00
David Steele
71bc5697b1 Increase per-call stack trace size to 4096.
This was previously 256, which was too small to log protocol parameters.  Not only did this truncate important debug information but varying path lengths caused spurious differences in the expect logs.
2019-02-20 22:23:19 +02:00
David Steele
73be64ce49 Add separate archive-get-async command.
This command was previously forked off from the archive-get command which required a bit of artificial option and log manipulation.

A separate command is easier to test and will work on platforms that don't have fork(), e.g. Windows.
2019-02-20 15:52:07 +02:00
David Steele
e48b406cdc Add instructions for building the coverage report.
These are intended to be temporary until a fully automated report is developed.

Since we don't know when that will happen, at least make it easier to generate the current report.
2019-02-20 15:48:14 +02:00
David Steele
da628be8a8 Migrate remote command to C.
Prior to this the Perl remote was used to satisfy C requests. This worked fine but since the remote needed to be migrated to C anyway there was no reason to wait.

Add the ProtocolServer object and tweak ProtocolClient to work with it. It was also necessary to add a mechanism to get option values from the remote so that encryption settings could be read and used in the storage object.

Update the remote storage objects to comply with the protocol changes and add the storage protocol handler.

Ideally this commit would have been broken up into smaller chunks but there are cross-dependencies in the protocol layer and it didn't seem worth the extra effort.
2019-02-19 20:57:38 +02:00
David Steele
d211c2b8b5 Fix possible truncated WAL segments when an error occurs mid-write.
The file write object destructors called close() and finalized the file even if it was not completely written.  This was an issue in both the C and Perl code.

Rewrite the destructors to simply free resources (like file handles) rather than calling the close() method.  This leaves the temp file in place for filesystems that use temp files.

Add unit tests to prevent regression.

Reported by blogh.
2019-02-15 11:52:39 +02:00
Stephen Frost
2cd204f380 Change execRead() to return a size_t.
execRead() should be returning a size_t, not a void. Thankfully, this isn't actually used and therefore shouldn't be an issue, but we should fix it anyway.

Contributed by Stephen Frost.
2019-02-12 14:59:51 +02:00
David Steele
a5f6f801d7 Begin v2.11 development. 2019-02-12 14:11:16 +02:00
David Steele
35903b94d9 v2.10: Bug Fixes
Bug Fixes:

* Add unimplemented S3 driver method required for archive-get. (Reported by mibiio.)
* Fix check for improperly configured pg-path. (Reported by James Chanco Jr.)
2019-02-09 19:52:31 +02:00
David Steele
51971617a8 Fix year on 2.09 release.
Reported by Achilleas Mantzios.
2019-02-09 19:01:16 +02:00
David Steele
057e2e2782 Add unimplemented S3 driver method required for archive-get.
This was not being caught because the integration tests for S3 were running remotely and going through the Perl code rather than the new C code.

Implement the exists method for the S3 driver and add tests to prevent a regression.

Reported by mibiio.
2019-02-09 18:57:30 +02:00
David Steele
6e88f93991 Fix check for improperly configured pg-path.
The check to verify that pg-path and data_directory are equal was not working because pg-path was getting overwritten with data_directory before validation took place.

Reported by James Chanco Jr.
2019-02-05 18:55:07 +02:00