Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bin/pt-archiver
Original file line number Diff line number Diff line change
Expand Up @@ -4742,6 +4742,7 @@ sub new {
DSNParser => $dp,
is_cluster_node => undef,
parent => $args{parent},
preserve_dbh => $args{preserve_dbh},
};

return bless $self, $class;
Expand Down Expand Up @@ -4800,7 +4801,7 @@ sub set_dbh {
$self->{hostname} = $hostname;
}

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($dbh, 'Setting InactiveDestroy=1 in parent');
$dbh->{InactiveDestroy} = 1;
}
Expand Down Expand Up @@ -4923,7 +4924,7 @@ sub DESTROY {

PTDEBUG && _d('Destroying cxn');

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($self->{dbh}, 'Not disconnecting dbh in parent');
}
elsif ( $self->{dbh}
Expand Down
5 changes: 3 additions & 2 deletions bin/pt-config-diff
Original file line number Diff line number Diff line change
Expand Up @@ -2368,6 +2368,7 @@ sub new {
DSNParser => $dp,
is_cluster_node => undef,
parent => $args{parent},
preserve_dbh => $args{preserve_dbh},
};

return bless $self, $class;
Expand Down Expand Up @@ -2426,7 +2427,7 @@ sub set_dbh {
$self->{hostname} = $hostname;
}

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($dbh, 'Setting InactiveDestroy=1 in parent');
$dbh->{InactiveDestroy} = 1;
}
Expand Down Expand Up @@ -2549,7 +2550,7 @@ sub DESTROY {

PTDEBUG && _d('Destroying cxn');

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($self->{dbh}, 'Not disconnecting dbh in parent');
}
elsif ( $self->{dbh}
Expand Down
15 changes: 8 additions & 7 deletions bin/pt-deadlock-logger
Original file line number Diff line number Diff line change
Expand Up @@ -2715,6 +2715,7 @@ sub new {
DSNParser => $dp,
is_cluster_node => undef,
parent => $args{parent},
preserve_dbh => $args{preserve_dbh},
};

return bless $self, $class;
Expand Down Expand Up @@ -2773,7 +2774,7 @@ sub set_dbh {
$self->{hostname} = $hostname;
}

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($dbh, 'Setting InactiveDestroy=1 in parent');
$dbh->{InactiveDestroy} = 1;
}
Expand Down Expand Up @@ -2896,7 +2897,7 @@ sub DESTROY {

PTDEBUG && _d('Destroying cxn');

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($self->{dbh}, 'Not disconnecting dbh in parent');
}
elsif ( $self->{dbh}
Expand Down Expand Up @@ -4711,7 +4712,7 @@ sub main {

my $src = Cxn->new(
dsn_string => shift @ARGV,
parent => $o->get('daemonize'),
preserve_dbh => $o->get('daemonize'),
DSNParser => $dp,
OptionParser => $o,
);
Expand All @@ -4735,7 +4736,7 @@ sub main {
$dst = Cxn->new(
dsn => $dst_dsn,
prev_dsn => ($src ? $src->dsn : undef),
parent => $o->get('daemonize'),
preserve_dbh => $o->get('daemonize'),
DSNParser => $dp,
OptionParser => $o,
set => $set_tz,
Expand Down Expand Up @@ -4806,13 +4807,13 @@ sub main {

# If we daemonized, the parent has already exited and we're the child.
# We shared a copy of every Cxn with the parent, and the parent's copies
# were destroyed but the dbhs were not disconnected because the parent
# were destroyed but the dbhs were not disconnected because the preserve_dbh
# attrib was true. Now, as the child, set it false so the dbhs will be
# disconnected when our Cxn copies are destroyed. If we didn't daemonize,
# then we're not really a parent (since we have no children), so set it
# false to auto-disconnect the dbhs when our Cxns are destroyed.
$src->{parent} = 0;
$dst->{parent} = 0 if $dst;
$src->{preserve_dbh} = 0;
$dst->{preserve_dbh} = 0 if $dst;

# ########################################################################
# Do the version-check
Expand Down
15 changes: 8 additions & 7 deletions bin/pt-fk-error-logger
Original file line number Diff line number Diff line change
Expand Up @@ -1869,6 +1869,7 @@ sub new {
DSNParser => $dp,
is_cluster_node => undef,
parent => $args{parent},
preserve_dbh => $args{preserve_dbh},
};

return bless $self, $class;
Expand Down Expand Up @@ -1927,7 +1928,7 @@ sub set_dbh {
$self->{hostname} = $hostname;
}

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($dbh, 'Setting InactiveDestroy=1 in parent');
$dbh->{InactiveDestroy} = 1;
}
Expand Down Expand Up @@ -2050,7 +2051,7 @@ sub DESTROY {

PTDEBUG && _d('Destroying cxn');

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($self->{dbh}, 'Not disconnecting dbh in parent');
}
elsif ( $self->{dbh}
Expand Down Expand Up @@ -4177,7 +4178,7 @@ sub main {
if ( my $src_dsn_string = shift @ARGV ) {
$src = Cxn->new(
dsn_string => $src_dsn_string,
parent => $o->get('daemonize'),
preserve_dbh => $o->get('daemonize'),
DSNParser => $dp,
OptionParser => $o,
);
Expand All @@ -4188,7 +4189,7 @@ sub main {
$dst = Cxn->new(
dsn => $dst_dsn,
prev_dsn => ($src ? $src->dsn : undef),
parent => $o->get('daemonize'),
preserve_dbh => $o->get('daemonize'),
DSNParser => $dp,
OptionParser => $o,
);
Expand Down Expand Up @@ -4244,13 +4245,13 @@ sub main {

# If we daemonized, the parent has already exited and we're the child.
# We shared a copy of every Cxn with the parent, and the parent's copies
# were destroyed but the dbhs were not disconnected because the parent
# were destroyed but the dbhs were not disconnected because the preserve_dbh
# attrib was true. Now, as the child, set it false so the dbhs will be
# disconnected when our Cxn copies are destroyed. If we didn't daemonize,
# then we're not really a parent (since we have no children), so set it
# false to auto-disconnect the dbhs when our Cxns are destroyed.
$src->{parent} = 0;
$dst->{parent} = 0 if $dst;
$src->{preserve_dbh} = 0;
$dst->{preserve_dbh} = 0 if $dst;

# ########################################################################
# Do the version-check
Expand Down
11 changes: 6 additions & 5 deletions bin/pt-kill
Original file line number Diff line number Diff line change
Expand Up @@ -5557,6 +5557,7 @@ sub new {
DSNParser => $dp,
is_cluster_node => undef,
parent => $args{parent},
preserve_dbh => $args{preserve_dbh},
};

return bless $self, $class;
Expand Down Expand Up @@ -5615,7 +5616,7 @@ sub set_dbh {
$self->{hostname} = $hostname;
}

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($dbh, 'Setting InactiveDestroy=1 in parent');
$dbh->{InactiveDestroy} = 1;
}
Expand Down Expand Up @@ -5738,7 +5739,7 @@ sub DESTROY {

PTDEBUG && _d('Destroying cxn');

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($self->{dbh}, 'Not disconnecting dbh in parent');
}
elsif ( $self->{dbh}
Expand Down Expand Up @@ -7245,7 +7246,7 @@ sub main {
$cxn = Cxn->new(
dsn_string => shift @ARGV,
NAME_lc => 0,
parent => $o->get('daemonize'),
preserve_dbh => $o->get('daemonize'),
DSNParser => $dp,
OptionParser => $o,
);
Expand Down Expand Up @@ -7444,12 +7445,12 @@ sub main {

# If we daemonized, the parent has already exited and we're the child.
# We shared a copy of every Cxn with the parent, and the parent's copies
# were destroyed but the dbhs were not disconnected because the parent
# were destroyed but the dbhs were not disconnected because the preserve_dbh
# attrib was true. Now, as the child, set it false so the dbhs will be
# disconnected when our Cxn copies are destroyed. If we didn't daemonize,
# then we're not really a parent (since we have no children), so set it
# false to auto-disconnect the dbhs when our Cxns are destroyed.
$cxn->{parent} = 0 if $cxn;
$cxn->{preserve_dbh} = 0 if $cxn;

# ########################################################################
# Do the version-check
Expand Down
5 changes: 3 additions & 2 deletions bin/pt-online-schema-change
Original file line number Diff line number Diff line change
Expand Up @@ -3984,6 +3984,7 @@ sub new {
DSNParser => $dp,
is_cluster_node => undef,
parent => $args{parent},
preserve_dbh => $args{preserve_dbh},
};

return bless $self, $class;
Expand Down Expand Up @@ -4042,7 +4043,7 @@ sub set_dbh {
$self->{hostname} = $hostname;
}

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($dbh, 'Setting InactiveDestroy=1 in parent');
$dbh->{InactiveDestroy} = 1;
}
Expand Down Expand Up @@ -4165,7 +4166,7 @@ sub DESTROY {

PTDEBUG && _d('Destroying cxn');

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($self->{dbh}, 'Not disconnecting dbh in parent');
}
elsif ( $self->{dbh}
Expand Down
5 changes: 3 additions & 2 deletions bin/pt-table-checksum
Original file line number Diff line number Diff line change
Expand Up @@ -3676,6 +3676,7 @@ sub new {
DSNParser => $dp,
is_cluster_node => undef,
parent => $args{parent},
preserve_dbh => $args{preserve_dbh},
};

return bless $self, $class;
Expand Down Expand Up @@ -3734,7 +3735,7 @@ sub set_dbh {
$self->{hostname} = $hostname;
}

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($dbh, 'Setting InactiveDestroy=1 in parent');
$dbh->{InactiveDestroy} = 1;
}
Expand Down Expand Up @@ -3857,7 +3858,7 @@ sub DESTROY {

PTDEBUG && _d('Destroying cxn');

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($self->{dbh}, 'Not disconnecting dbh in parent');
}
elsif ( $self->{dbh}
Expand Down
5 changes: 3 additions & 2 deletions bin/pt-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -2542,6 +2542,7 @@ sub new {
DSNParser => $dp,
is_cluster_node => undef,
parent => $args{parent},
preserve_dbh => $args{preserve_dbh},
};

return bless $self, $class;
Expand Down Expand Up @@ -2600,7 +2601,7 @@ sub set_dbh {
$self->{hostname} = $hostname;
}

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($dbh, 'Setting InactiveDestroy=1 in parent');
$dbh->{InactiveDestroy} = 1;
}
Expand Down Expand Up @@ -2723,7 +2724,7 @@ sub DESTROY {

PTDEBUG && _d('Destroying cxn');

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($self->{dbh}, 'Not disconnecting dbh in parent');
}
elsif ( $self->{dbh}
Expand Down
5 changes: 3 additions & 2 deletions lib/Cxn.pm
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ sub new {
DSNParser => $dp,
is_cluster_node => undef,
parent => $args{parent},
preserve_dbh => $args{preserve_dbh},
};

return bless $self, $class;
Expand Down Expand Up @@ -184,7 +185,7 @@ sub set_dbh {
$self->{hostname} = $hostname;
}

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($dbh, 'Setting InactiveDestroy=1 in parent');
$dbh->{InactiveDestroy} = 1;
}
Expand Down Expand Up @@ -334,7 +335,7 @@ sub DESTROY {

PTDEBUG && _d('Destroying cxn');

if ( $self->{parent} ) {
if ( $self->{preserve_dbh} ) {
PTDEBUG && _d($self->{dbh}, 'Not disconnecting dbh in parent');
}
elsif ( $self->{dbh}
Expand Down
8 changes: 8 additions & 0 deletions lib/PerconaTest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ our @EXPORT = qw(
load_file
slurp_file
parse_file
touch_file
wait_until
wait_for
wait_until_replica_running
Expand Down Expand Up @@ -261,6 +262,13 @@ sub parse_file {
return \@e;
}

# Create empty file
sub touch_file {
my ($file) = @_;
open(my $t, '>', $file) or die "Cannot create $file: $!";
close($t) or die "Cannot close $file: $!";
}

# Wait until code returns true.
sub wait_until {
my ( $code, $t, $max_t ) = @_;
Expand Down
Loading
Loading