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

1229 Commits

Author SHA1 Message Date
David Steele
6e809e578f Add tag to specify minio version to use for documentation build.
The new minio major release broke the build.  We'll need to figure that out but for now use the last major version, which is known to work.
2019-06-11 10:34:42 -04:00
David Steele
d7bd0c58cd Use wal_level=replica in the documentation for PostgreSQL >= 9.6.
The documentation was using wal_level=hot_standby which is a deprecated setting.

Also remove the reference to wal_level=archive since it is no longer supported and is not recommended for older versions.

Suggested by Patrick McLaughlin.
2019-06-05 07:27:24 -04:00
David Steele
64260b2e98 Build all docs with S3 using --var=s3-all=y
Force repo-type=s3 for all tests.  This is not currently the default for any OS builds.
2019-05-29 08:38:45 -04:00
David Steele
404284b90f Add internal flag for commands.
Allow commands to be skipped by default in the command help but still work if help is requested for the command directly.  There may be other uses for the flag in the future.

Update help for ls now that it is exposed.
2019-05-28 12:18:05 -04:00
David Steele
20e5b92f36 Add ls command.
Allows listing repo paths/files from the command-line, to be used primarily for testing and debugging.

This command is internal-only so the interface may change at any time without notice.
2019-05-28 10:03:48 -04:00
David Steele
3e1b06acaa Use minio as local S3 emulator in documentation.
The documentation was relying on a ScalityS3 container built for testing which wasn't very transparent.  Instead, use the stock minio container and configure it in the documentation.

Also, install certificates and CA so that TLS verification can be enabled.
2019-05-27 07:37:20 -04:00
David Steele
ec9622cde8 Use the git log to ease release note management.
The release notes are generally a direct reflection of the git log.  So, ease the burden of maintaining the release notes by using the git log to determine what needs to be added.

Currently only non-dev items are required to be matched to a git commit but the goal is to account for all commits.

The git history cache is generated from the git log but can be modified to correct typos and match the release notes as they evolve.  The commit hash is used to identify commits that have already been added to the cache.

There's plenty more to do here.  For instance, links to the commits for each release item should be added to the release notes.
2019-05-22 18:54:49 -04:00
David Steele
936b8a289c Allow separate paragraphs in release items.
The first paragraph should match the first line of the commit message as closely as possible.  The following paragraphs add more information.

Release items have been updated back to 2.01.
2019-05-21 10:37:30 -04:00
David Steele
e3fe3434b4 Rename repo-s3-verify-ssl option to repo-s3-verify-tls.
The new name is preferred because pgBackRest does not support any SSL protocol versions (they are all considered to be insecure).

The old name will continue to be accepted.
2019-05-21 10:14:41 -04:00
David Steele
1bc84c6474 The local command for restore is implemented entirely in C.
This is just the part of restore run by the local helper processes, not the entire command.

Even so, various optimizations in the code (like pipelining and optimizations for zero-length files) should make the restore command faster on object stores.
2019-05-20 17:07:37 -04:00
Cynthia Shang
a839830333 Add most unimplemented functions to the remote storage driver.
Add pathCreate(), pathRemove(), pathSync(), and remove() to the driver.

Contributed by Cynthia Shang.
2019-05-20 16:19:14 -04:00
David Steele
a9f589b87a Begin v2.15 development. 2019-05-20 12:23:40 -04:00
David Steele
0f685a33a0 v2.14: Bug Fix and Improvements
Bug Fixes:

* Fix segfault when process-max > 8 for archive-push/archive-get. (Reported by Jens Wilke.)

Improvements:

* Bypass database checks when stanza-delete issued with force. (Contributed by Cynthia Shang. Suggested by hatifnatt.)
* Add configure script for improved multi-platform support.

Documentation Features:

* Add user guides for CentOS/RHEL 6/7.
2019-05-20 11:51:58 -04:00
David Steele
51d67ce1ba Update contributor name. 2019-05-16 09:59:34 -04:00
Cynthia Shang
19d8358cba Update mock/expire module test matrix so expect tests output.
Also add an error message to prevent regression.

Contributed by Cynthia Shang.
2019-05-16 09:53:55 -04:00
David Steele
c51274d1b6 Add user guides for CentOS/RHEL 6/7.
It would be better if the documentation could be generated on multiple operating systems all in one go, but the doc system currently does not allow vars to be changed once they are set.

The solution is to run the docs for each required OS and stitch the documentation together.  It's not pretty but it works and the automation in release.pl should at least make it easy to use.
2019-05-16 08:32:02 -04:00
David Steele
bc7b42e718 Restore index menu url default lost in b85e51d6.
The url for the menu item referring to the index (i.e. site root page) should use {[project-url-root]}.

This allows the url to be set to different values depending on the location of the index.
2019-05-16 07:35:45 -04:00
David Steele
a4561dc087 Add --out-preserve to preserve contents of output path.
Useful for building a single set of documentation over multiple doc.pl runs.
2019-05-16 07:29:17 -04:00
Cynthia Shang
18d4cb5741 Bypass database checks when stanza-delete issued with force.
Previously it was not possible to delete a stanza if the PostgreSQL server could not be contacted.

Contributed by Cynthia Shang.
Suggested by Roman.
2019-05-15 13:14:58 -04:00
David Steele
5c1d4bcd0d Automate coverage summary report generation.
This report replaces the lcov report that was generated manually for each release.

The lcov report was overly verbose just to say that we have virtually 100% coverage.
2019-05-15 13:04:56 -04:00
David Steele
5bba72b874 Remove -Wswitch-enum compiler option.
The -Wswitch option included in -Wall provides the same level of coverage and allows enum options to be grouped into default.
2019-05-15 12:55:08 -04:00
David Steele
53f6232264 Improve coverage in config/parse module. 2019-05-14 10:35:39 -04:00
David Steele
1e5ab69cad Improve coverage in config/config module. 2019-05-13 19:10:24 -04:00
David Steele
15a33bf74b Error on multiple option alternate names and simplify help command.
There are currently no options with multiple alternate (deprecated) names so the code to render them in the help command could not be covered.

Remove the uncovered code and add an error when multiple alternate names are configured.  It's not clear that the current code was handling this correctly, so it will need to be reviewed if it comes up again.
2019-05-13 17:10:41 -04:00
David Steele
2d2bec842a Improve coverage in perl/exec module. 2019-05-13 13:36:24 -04:00
David Steele
431532574b Add testUser() and testGroup().
Retrieve the name of the current user/group used for testing.
2019-05-13 07:51:11 -04:00
David Steele
31d0fe5f50 Improve log performance, simplify macros, rename logWill() to logAny().
Pre-calculate the value used by logAny() to improve performance and make it more likely to be inlined.

Move IF_LOG_ANY() into LOG_INTERNAL() to simplify the macros and improve performance of LOG() and LOG_PID().  If the message has no chance of being logged there's no reason to call logInternal().

Rename logWill() to logAny() because it seems more intuitive.
2019-05-11 18:20:57 -04:00
David Steele
87f36e814e Improve macros and coverage rules that were hiding missing coverage.
The branch coverage exclusion rules were overly broad and included functions that ended in a capital letter, which disabled all coverage for the statement.  Improve matching so that all characters in the name must be upper-case for a match.

Some macros with internal branches accepted parameters that might contain conditionals.  This made it impossible to tell which branches belonged to which, and in any case an overzealous exclusion rule was ignoring all branches in such cases.  Add the DEBUG_COVERAGE flag to build a modified version of the macros without any internal branches to be used for coverage testing.  In most cases, the branches were optimizations (like checking logWill()) that improve production performance but are not needed for testing.  In other cases, a parameter needed to be added to the underlying function to handle the branch during coverage testing.

Also tweak the coverage rules so that macros without conditionals are automatically excluded from branch coverage as long as they are not themselves a parameter.

Finally, update tests and code where missing coverage was exposed by these changes.  Some code was updated to remove existing coverage exclusions when it was a simple change.
2019-05-11 14:51:51 -04:00
David Steele
f819a32cdf Improve efficiency of FUNCTION_LOG*() macros.
Call stackTraceTestStop()/stackTraceTestStart() once per block instead of with every param call.  This was done to be cautious but is not necessary and slows down development.

These functions were never built into production so had no impact there.
2019-05-11 07:57:49 -04:00
David Steele
f0f105ddec Improve filter's notion of "done" to optimize filter processing.
Filters had different ideas about what "done" meant and this added complication to the group filter processing.  For example, gzip decompression would detect end of stream and mark the filter as done before it had been flushed.

Improve the IoFilter interface to give a consistent definition of done across all filters, i.e. no filter can be done until it has started flushing no matter what the underlying driver reports.  This removes quite a bit of tricky logic in the processing loop which tried to determine when a filter was "really" done.

Also improve management of the input buffers by pointing directly to the prior output buffer (or the caller's input) to eliminate loops that set/cleared these buffers.
2019-05-09 12:10:46 -04:00
David Steele
d5fac35fe3 Improve zero-length content handling in HttpClient object.
If content was zero-length then the IO object was not created.  This put the burden on the caller to test that the IO object existed before checking eof.

Instead, create an IO object even if it will immediately return eof.  This has little cost and makes the calling code simpler.

Also add an explicit test for zero-length files in S3 and a few assertions.
2019-05-09 09:53:24 -04:00
David Steele
15531151d7 Add --c option to request a C remote.
The rules for when a C remote is required are getting complicated and will get worse when restoreFile() is migrated.

Instead, set the --c option when a C remote is required.  This option will be removed when the remote is entirely implemented in C.
2019-05-09 08:55:48 -04:00
David Steele
c99c7c458b Add pathExists() to Storage object.
The S3 driver did not get an implementation since S3 has a weak notion of paths, and it is not currently required.
2019-05-09 08:28:58 -04:00
David Steele
f1eea23121 Add macros for object free functions.
Most of the *Free() functions are pretty generic so add macros to make creating them as easy as possible.

Create a distinction between *Free() functions that the caller uses to free memory and callbacks that free third-party resources.  There are a number of cases where a driver needs to free resources but does not need a normal *Free() because it is handled by the interface.

Add common/object.h for macros that make object maintenance easier.  This pattern can also be used for many more object functions.
2019-05-03 18:52:54 -04:00
David Steele
7ae96949f1 Various MemContext callback improvements.
Rename memContextCallback() to memContextCallbackSet() to be more consistent with other parts of the code.

Free all context memory when an exception is thrown from a callback.  Previously only the child contexts would be freed and this resulted in some allocations being lost.  In practice this is probably not a big deal since the process will likely terminate shortly, but there may well be cases where that is not true.
2019-05-03 18:09:58 -04:00
David Steele
4a20d44c6b Add common/macro.h for general-purpose macros.
Add GLUE() macro which is useful for creating identifiers.

Move MACRO_TO_STR() here and rename it STRINGIFY().  This appears to be the standard name for this type of macro and it is also an awesome name.
2019-05-03 17:49:57 -04:00
David Steele
32ca27a20b Simplify storage object names.
Remove "File" and "Driver" from object names so they are shorter and easier to keep consistent.

Also remove the "driver" directory so storage implementations are visible directly under "storage".
2019-05-03 15:46:15 -04:00
David Steele
8c712d89eb Improve type safety of interfaces and drivers.
The function pointer casting used when creating drivers made changing interfaces difficult and led to slightly divergent driver implementations.  Unit testing caught production-level errors but there were a lot of small issues and the process was harder than it should have been.

Use void pointers instead so that no casts are required.  Introduce the THIS_VOID and THIS() macros to make dealing with void pointers a little safer.

Since we don't want to expose void pointers in header files, driver functions have been removed from the headers and the various driver objects return their interface type.  This cuts down on accessor methods and the vast majority of those functions were not being used.  Move functions that are still required to .intern.h.

Remove the special "C" crypto functions that were used in libc and instead use the standard interface.
2019-05-02 17:52:24 -04:00
David Steele
498017bcf0 Various Buffer improvements.
Add bufDup() and bufNewUsedC().

Arrange bufNewC() params to match bufNewUsedC() since they have always seemed backward.

Fix bufHex() to only render the used portion of the buffer and fix some places where used was not being set correctly.

Use a union to make macro assignments for all legal values without casting.  This is much more likely to catch bad assignments.
2019-05-02 12:43:09 -04:00
David Steele
59234f249e Use THROW_ON_SYS_ERROR*() to improve code coverage.
There is only one instance in the core code where this helps. It is mostly helpful in the tests.

There is an argument to be made that only THROW_SYS_ERROR*() variants should be used in the core code to improve test coverage.  If so, that will be the subject of a future commit.
2019-04-29 18:36:57 -04:00
David Steele
683b096e18 Don't append strerror() to error message when errno is 0.
Some functions (e.g. getpwnam()/getgrnam()) will return an error but not set errno.  In this case there's no use in appending strerror(), which will be "Success".  This is confusing since an error has just been reported.

At least in the examples above, an error with no errno set just means "missing" and our current error message already conveys that.
2019-04-29 18:03:32 -04:00
David Steele
6ad44db9a0 Merge duplicated contributor. 2019-04-29 17:30:06 -04:00
David Steele
af33126cb6 Allow StorageFileWrite to set user, group, and modification time.
The S3 driver will throw an error if these options are set since they are not supported.
2019-04-29 17:17:14 -04:00
David Steele
d0c296bd5b Fix segfault when process-max > 8 for archive-push/archive-get.
The remote list was at most 9 (based on pg[1-8]-* max index) so anything over 8 wrote into unallocated memory.

The remote for the main process is (currently) stored in position zero so do the same for remotes started from locals, since there should only be one.  The main process will need to start more remotes in the future which is why there is extra space.

Reported by Jens Wilke.
2019-04-29 16:10:27 -04:00
David Steele
c935b1c9e8 Add missing httpUriEncode() in S3 request.
This was not a live bug since the files currently handled by C can't have special characters in them.
2019-04-29 15:20:54 -04:00
David Steele
62b48d8a5a Allow storageInfo() to follow links.
This allows info to be retrieved from linked files/paths in a single step.
2019-04-29 15:14:10 -04:00
David Steele
60edadf71d Expose handle (file descriptor) from IoWrite when applicable.
This is a followup to dee90d3e which exposed file handles for IoRead.

Also expose handle for StorageDriverPosixFileRead missed in dee90d3e.
2019-04-29 14:54:49 -04:00
David Steele
027c263871 Add configure script for improved multi-platform support.
Use autoconf to provide a basic configure script. WITH_BACKTRACE is yet to be migrated to configure and the unit tests still use a custom Makefile.

Each C file must include "build.auto.conf" before all other includes and defines.  This is enforced by test.pl for includes, but it won't detect incorrect define ordering.

Update packages to call configure and use standard flags to pass options.
2019-04-26 08:08:23 -04:00
David Steele
3505559a80 Update test containers with PostgreSQL minor releases and liblz4.
Update RHEL repos that have changed upstream.  Remove PostgreSQL 9.3 since the RHEL6/7 packages have disappeared.

Remove PostgreSQL versions from U12 that are still getting minor updates so the container does not need to be rebuilt.

LZ4 is included for future development, but this seems like a good time to add it to the containers.
2019-04-24 13:23:32 -04:00
David Steele
1ae8a6a716 Add build-max option to set max build processes.
Currently this controls make processes via -j.
2019-04-23 20:52:03 -04:00
David Steele
c11c936366 Reduce ScalityS3 processes since only two are needed. 2019-04-23 20:19:31 -04:00
David Steele
52b0b81976 Add storageInfoList() to get detailed info about all entries in a path.
The function provides all the file/path/link information required to build a backup manifest.

Also update storageInfo() to provide the same information for a single file.
2019-04-23 19:33:55 -04:00
David Steele
f492f0571b Add *Save() functions to most Info objects.
At the same time change the way that load constructors work (and are named) so that Ini objects do not persist after the constructors complete.

infoArchiveSave() is excluded from this commit since it is just a trivial call to infoPgSave() and won't be required soon.
2019-04-23 17:08:34 -04:00
David Steele
f41112a463 Add harnessInfoChecksum/Z() to ease creation of test info files. 2019-04-23 14:02:30 -04:00
David Steele
aebac47cd5 Extern infoHash() so it can be used by other modules.
This is currently needed only for testing, but there's no reason not to expose the function to everyone.
2019-04-23 13:58:19 -04:00
David Steele
cddb0c05b4 Add iniSave() and iniMove() to Ini object.
iniSave() sorts alphabetically to maintain compatibility with the expect tests, but we plan to change this behavior when the migration is complete.
2019-04-23 13:03:22 -04:00
David Steele
c650134a04 Add ioWriteStr() and ioWriteStrLine().
These function names make it clearer what is being written.

The old ioWriteLine() has been repurposed to write buffers.
2019-04-22 18:46:29 -04:00
David Steele
81f652137c Add separate functions to encode/decode each JSON type.
In most cases the JSON type is known so this is more efficient than converting to Variant first, both in terms of memory and time.

Also rename some of the existing functions for consistency.
2019-04-22 18:41:01 -04:00
David Steele
f100ea0ff4 Add constant for maximum buffer sizes required by cvt*() functions.
Also update Variant to use cvt*() in all cases.  Variant was written before these functions were available and not all cases were updated.
2019-04-22 17:52:23 -04:00
David Steele
f5739051eb Add true and false String constants. 2019-04-22 17:17:56 -04:00
David Steele
47491e3c47 varNewKv() accepts a KeyValue object rather than creating one.
This allows for more flexibility about when the Variant is created.
2019-04-22 16:04:04 -04:00
David Steele
fdf19e5ab6 Refactor Ini interface to expose String values instead of Variant.
Variants were being used to expose String and StringList types but this can be done more simply with an additional method.

Using only strings also allows for a more efficient implementation down the road.
2019-04-22 09:00:50 -04:00
David Steele
cc39bddc15 Refactor main() as a switch() statement.
This makes it clearer what has been migrated and where the new C implementations should go.
2019-04-22 08:47:32 -04:00
David Steele
e7255be108 Only process next filter in IoFilterGroup when input buffer is full or flushing.
This greatly reduces calls to filter processing, which is a performance benefit, but also makes the trace logs smaller and easier to read.

However, this means that ioWriteFlush() will no longer work with filters since a full flush of IoFilterGroup would require an expensive reset.  Currently ioWriteFlush() is not used in this scenario so for now just add an assert to ensure it stays that way.
2019-04-20 11:25:04 -04:00
David Steele
e513c52c09 Add macros to create constant Buffer objects.
These are more efficient than creating buffers in place when needed.

After replacement discovered that bufNewStr() and BufNewZ() were not being used in the core code so removed them.  This required using the macros in tests which is not the usual pattern.
2019-04-20 08:16:17 -04:00
David Steele
c9168028c6 Improve performance of non-blocking reads by using maximum buffer size.
Since the introduction of blocking read drivers (e.g. IoHandleRead, TlsClient) the non-blocking drivers have used the same rules for determining maximum buffer size, i.e. read only as much as requested.  This is necessary so the blocking drivers don't get stuck waiting for data that might not be coming.

Instead mark blocking drivers so IoRead knows how much buffer to allow for the read.  The non-blocking drivers can now request the maximum number of bytes allowed by buffer-size.
2019-04-19 14:38:11 -04:00
David Steele
0c866f52c6 Update code to use new unsigned int Variant type and config methods. 2019-04-19 11:40:39 -04:00
David Steele
9f0829cbf2 Add cfgOptionUInt() and cfgOptionUInt64().
These are better than casting from cfgOptionInt() since bounds checking is performed.
2019-04-19 11:29:08 -04:00
David Steele
1adcbc5c91 Add unsigned int Variant type.
This is better than using (unsigned int)varUInt64() because bounds checking is performed.
2019-04-19 11:22:43 -04:00
David Steele
c45ae5f221 Begin v2.14 development. 2019-04-19 08:41:17 -04:00
David Steele
41f3874822 v2.13: Bug Fixes
Bug Fixes:

* Fix zero-length reads causing problems for IO filters that did not expect them. (Reported by brunre01, jwpit, Tomasz Kontusz, guruguruguru.)
* Fix reliability of error reporting from local/remote processes.
* Fix Posix/CIFS error messages reporting the wrong filename on write/sync/close.
2019-04-18 21:26:02 -04:00
David Steele
7390952d8e Harden IO filters against zero input and optimize zero output case.
Add production checks to ensure no filter gets a zero-size input buffer.

Also, optimize the case where a filter returns no output.  There's no sense in running downstream filters if they have no new input.
2019-04-18 21:24:10 -04:00
David Steele
2d73de1d36 Fix zero-length reads causing problems for IO filters that did not expect them.
The IoRead object was passing zero-length buffers into the filter processing code but not all the filters were happy about getting them.

In particular, the gzip compression filter failed if it was given no input directly after it had flushed all of its buffers.  This made the problem rather intermittent even though a zero-length buffer was being passed to the filter at the end of every file.  It also explains why tweaking compress-level or buffer-size allowed the file to go through.

Since this error was happening after all processing had completed, there does not appear to be any risk that successfully processed files were corrupted.

Reported by brunre01, jwpit, Tomasz Kontusz, guruguruguru.
2019-04-18 21:21:35 -04:00
David Steele
670fa88a98 Add CHECK() macro for production assertions.
CHECK() works just like ASSERT() but is kept in production builds.
2019-04-18 13:21:24 -04:00
David Steele
b258aec0ad Move lockRelease() to the end of exitSafe().
Releasing the lock too early was allowing other async processes to sneak in and start running before the current process was completely shut down.

The only symptom seems to have been mixed up log messages so not a very serious issue.
2019-04-18 13:19:05 -04:00
David Steele
b960919cf7 Fix reliability of error reporting from local/remote processes.
Asserts were only only reported on stderr rather than being returned through the protocol layer.  This did not appear to be very reliable.

Instead, report the assert through the protocol layer like any other error.  Add a stack trace if an assert error or debug logging is enabled.
2019-04-18 10:36:21 -04:00
David Steele
281d2848b9 Option to build documentation from current apt.postgres.org packages.
This is useful for testing any issue currently being seen in the field.

We'll also need to add a "yum" option at some point.
2019-04-17 18:39:35 -04:00
David Steele
0d4ba3a39f Fix Posix/CIFS error messages reporting the wrong filename on write/sync/close.
The reported file name was the destination file, not the temp file that is written to during atomic write operations.
2019-04-17 18:18:55 -04:00
David Steele
4c13955c05 Add macros to create constant Variant types.
These work almost exactly like the String constant macros. However, a struct per variant type was required which meant custom constructors and destructors for each type.

Propagate the variant constants out into the codebase wherever they are useful.
2019-04-17 08:04:22 -04:00
David Steele
2dac4b5986 Add STR() macro to create constant String objects from runtime strings.
The STRING_CONST() macro worked fine for constants but was not able to constify strings created at runtime.

Add the STR() macro to do this by using strlen() to get the size.

Also rename STRING_CONST() to STRDEF() for brevity and to match the other macro name.
2019-04-16 13:39:58 -04:00
David Steele
a029eba8d5 Use a macro instead of a nested struct to create common String variables.
This makes the code a bit less obfuscated while still ensuring that these variables will be common to both String structures.
2019-04-16 13:18:30 -04:00
Cynthia Shang
a7281878ac Migrate backupRegExp() to C.
Removed the "anchor" parameter because it was never used in any calls in the Perl code so it was just a dead parameter that always defaulted to true.

Contributed by Cynthia Shang.
2019-04-15 08:29:25 -04:00
David Steele
c5157c0334 Automatically generate constants for command and option names.
These constants are easier than using cfgOptionName() and cfgCommandName() and lead to cleaner code and simpler to construct messages.

String versions are provided. Eventually all the strings will be used in the config structures, but for now they are useful to avoid wrapping with strNew().
2019-04-12 09:03:34 -04:00
David Steele
867690c08d Begin v2.13 development.
Also update CentOS packages so documentation builds.
2019-04-12 08:33:10 -04:00
David Steele
4e57b68916 v2.12: C Implementation of Archive Push
IMPORTANT NOTE: The new TLS/SSL implementation forbids dots in S3 bucket names per RFC-2818. This security fix is required for compliant hostname verification.

Bug Fixes:

* Fix issues when a path option is / terminated. (Reported by Marc Cousin.)
* Fix issues when log-level-file=off is set for the archive-get command. (Reported by Brad Nicholson.)
* Fix C code to recognize host:port option format like Perl does. (Reported by Kyle Nevins.)
* Fix issues with remote/local command logging options.

Improvements:

* The archive-push command is implemented entirely in C.
* Increase process-max limit to 999. (Suggested by Rakshitha-BR.)
* Improve error message when an S3 bucket name contains dots.

Documentation Improvements:

* Clarify that S3-compatible object stores are supported. (Suggested by Magnus Hagander.)
2019-04-11 09:14:22 -04:00
David Steele
df12cbb162 Fix C code to recognize host:port format like Perl does.
This was not an intentional feature in Perl, but it works, so it makes sense to implement the same syntax in C.

This is a break from other places where a -port option is explicitly supplied, so it may make sense to support both styles going forward.  This commit does not address that, however.

Reported by Kyle Nevins.
2019-04-10 17:48:34 -04:00
David Steele
25cea0bd0a Add process id to C archive-get and archive-push logging.
This was missed in the original migration.  There was no functional issue, but logging the process ids is useful for debugging.
2019-04-09 11:08:27 -04:00
David Steele
8c202c77da Add process id to ProtocolParallelJob.
This exposes the process that performed to job to the caller for logging purposes.
2019-04-09 11:01:35 -04:00
David Steele
4ace7edbd9 Allow process id in C logging
The default process id in C logging has always been zero.  This should have been updated when multi-processing was introduced in C, but it was missed.
2019-04-09 10:54:36 -04:00
David Steele
6099729e92 Improve error message when an S3 bucket name contains dots.
The Perl lib we have been using for TLS allows dots in wildcards, but this is forbidden by RFC-2818.  The new TLS implementation in C forbids this pattern, just as PostgreSQL and curl do.

However, this does present a problem for users who have been using bucket names with dots in older versions of pgBackRest.  Since this limitation exists for security reasons there appears to be no option but to take a hard line and do our best to notify the user of the issue as clearly as possible.
2019-04-08 19:38:06 -04:00
David Steele
21c83eea59 Fix issue setting log-level-file=off for the archive-get command.
This problem was not specific to archive-get, but that was the only place it was expressing in the last release.  The new archive-push was also affected.

The issue was with daemon processes that had closed all their file descriptors.  When exec'ing and setting up pipes to communicate with a child process the dup2() function created file descriptors that overlapped with the first descriptor (stdout) that was being duped into.  This descriptor was subsequently closed and wackiness ensued.

If logging was enabled (the default) that increased all the file descriptors by one and everything worked.

Fix this by checking if the file descriptor to be closed is the same one being dup'd into.  This solution may not be generally applicable but it works fine in this case.

Reported by Brad Nicholson.
2019-04-08 17:21:20 -04:00
David Steele
8ac422dca9 Close log file before exec().
The log file should be closed before exec() so the child process does not retain a reference to it.
2019-04-07 21:09:29 -04:00
David Steele
9f3425f6dd Skip coverage for macros with numbers in their name.
This was an oversight in the old regular expression.
2019-04-07 18:47:04 -04:00
David Steele
c72a94cfec Increase process-max limit to 999.
Recent hardware has outstripped the old default so increase it to something that should last for a while.

Suggested by Rakshitha-BR.
2019-04-07 18:20:03 -04:00
David Steele
9a7eab9428 Allow three-digits process IDs in logging.
This is required to support process-max > 99 or else there will be formatting/alignment issues in the logs.
2019-04-07 18:12:07 -04:00
David Steele
e97b8241a5 Clarify that S3-compatible object stores are supported.
The documentation mentioned Amazon S3 frequently but failed to mention that other S3-compatible object stores are also supported.

Tone down the specific mentions of Amazon S3 and replace them with "S3-compatible object store" when appropriate.

Suggested by Magnus Hagander.
2019-04-03 11:40:12 +01:00
David Steele
4c63279a19 Add forkSafe() to handle fork errors.
fork() rarely fails but we should definitely detect when it does so.
2019-04-02 13:50:02 +01:00
David Steele
1b48684713 The archive-push command is implemented entirely in C.
This new implementation should behave exactly like the old Perl code with the exception of updated log messages.

Remove as much of the Perl code as possible without breaking other commands.
2019-03-29 13:26:33 +00:00
David Steele
251dbede8f Add locking capability to the remote command.
When a repository server is configured, commands that modify the repository acquire a remote lock as well as a local lock for extra protection against multiple writers.

Instead of the custom logic used in Perl, make remote locking part of the command configuration.

This also means that the C remote needs the stanza since it is used to construct the lock name.  We may need to revisit this at a later date.
2019-03-27 21:14:06 +00:00
David Steele
7db8cedd68 Add protocolKeepAlive() to send noops to all remotes.
While the local processes are doing their jobs the remote connection from the main process may timeout.

Send occasional noops to ensure that doesn't happen.
2019-03-27 20:59:28 +00:00