mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
eb4918d018
* Fixed an issue where read-only operations that used local worker processes (i.e. restore) were creating write locks that could interfere with parallel archive-push. (Reported by Jens Wilke.) * Simplify locking scheme. Now, only the master process will hold write locks (archive-push, backup) and not all the local and remote worker processes as before.
94 lines
3.1 KiB
Perl
94 lines
3.1 KiB
Perl
####################################################################################################################################
|
|
# PROTOCOL LOCAL MINION MODULE
|
|
####################################################################################################################################
|
|
package pgBackRest::Protocol::LocalMinion;
|
|
use parent 'pgBackRest::Protocol::CommandMinion';
|
|
|
|
use strict;
|
|
use warnings FATAL => qw(all);
|
|
use Carp qw(confess);
|
|
|
|
use pgBackRest::Archive::ArchivePushFile;
|
|
use pgBackRest::BackupFile;
|
|
use pgBackRest::Common::Log;
|
|
use pgBackRest::Config::Config;
|
|
use pgBackRest::File;
|
|
use pgBackRest::Protocol::CommandMinion;
|
|
use pgBackRest::Protocol::Common;
|
|
use pgBackRest::Protocol::Protocol;
|
|
use pgBackRest::RestoreFile;
|
|
|
|
####################################################################################################################################
|
|
# CONSTRUCTOR
|
|
####################################################################################################################################
|
|
sub new
|
|
{
|
|
my $class = shift; # Class name
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
my
|
|
(
|
|
$strOperation,
|
|
$strCommand,
|
|
) =
|
|
logDebugParam
|
|
(
|
|
__PACKAGE__ . '->new', \@_,
|
|
{name => 'strCommand'},
|
|
);
|
|
|
|
# Init object and store variables
|
|
my $self = $class->SUPER::new(
|
|
CMD_LOCAL, $strCommand, optionGet(OPTION_BUFFER_SIZE), optionGet(OPTION_COMPRESS_LEVEL),
|
|
optionGet(OPTION_COMPRESS_LEVEL_NETWORK), optionGet(OPTION_PROTOCOL_TIMEOUT));
|
|
bless $self, $class;
|
|
|
|
# Return from function and log return values if any
|
|
return logDebugReturn
|
|
(
|
|
$strOperation,
|
|
{name => 'self', value => $self}
|
|
);
|
|
}
|
|
|
|
####################################################################################################################################
|
|
# init
|
|
####################################################################################################################################
|
|
sub init
|
|
{
|
|
my $self = shift;
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
my ($strOperation) = logDebugParam(__PACKAGE__ . '->init');
|
|
|
|
# Create the file object
|
|
my $oFile = new pgBackRest::File
|
|
(
|
|
optionGet(OPTION_STANZA),
|
|
optionGet(OPTION_REPO_PATH),
|
|
protocolGet(
|
|
optionGet(OPTION_TYPE), optionGet(OPTION_HOST_ID),
|
|
{iProcessIdx => optionGet(OPTION_PROCESS), strCommand => optionGet(OPTION_COMMAND)})
|
|
);
|
|
|
|
# Create anonymous subs for each command
|
|
my $hCommandMap =
|
|
{
|
|
&OP_ARCHIVE_PUSH_FILE => sub {archivePushFile($oFile, @{shift()})},
|
|
&OP_BACKUP_FILE => sub {backupFile($oFile, @{shift()})},
|
|
&OP_RESTORE_FILE => sub {restoreFile($oFile, @{shift()})},
|
|
|
|
# To be run after each command to keep the remote alive
|
|
&OP_POST => sub {$oFile->{oProtocol}->keepAlive()},
|
|
};
|
|
|
|
# Return from function and log return values if any
|
|
return logDebugReturn
|
|
(
|
|
$strOperation,
|
|
{name => 'hCommandMap', value => $hCommandMap}
|
|
);
|
|
}
|
|
|
|
1;
|