mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-06 20:38:22 +00:00
Merge pull request #144 from percona/bug-1636068
Added pause to NibbleIterator
This commit is contained in:
@@ -5529,6 +5529,8 @@ sub new {
|
||||
$self->{have_rows} = 0;
|
||||
$self->{rowno} = 0;
|
||||
$self->{oktonibble} = 1;
|
||||
$self->{pause_file} = $nibble_params->{pause_file};
|
||||
$self->{sleep} = $args{sleep} || 60;
|
||||
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -5567,6 +5569,24 @@ sub next {
|
||||
|
||||
NIBBLE:
|
||||
while ( $self->{have_rows} || $self->_next_boundaries() ) {
|
||||
|
||||
if ($self->{pause_file}) {
|
||||
while(-f $self->{pause_file}) {
|
||||
print "Sleeping $self->{sleep} seconds because $self->{pause_file} exists\n";
|
||||
my $dbh = $self->{Cxn}->dbh();
|
||||
if ( !$dbh || !$dbh->ping() ) {
|
||||
eval { $dbh = $self->{Cxn}->connect() }; # connect or die trying
|
||||
if ( $EVAL_ERROR ) {
|
||||
chomp $EVAL_ERROR;
|
||||
die "Lost connection to " . $self->{Cxn}->name() . " while waiting for "
|
||||
. "replica lag ($EVAL_ERROR)\n";
|
||||
}
|
||||
}
|
||||
$dbh->do("SELECT 'nibble iterator keepalive'");
|
||||
sleep($self->{sleep});
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$self->{have_rows} ) {
|
||||
$self->{nibbleno}++;
|
||||
PTDEBUG && _d('Nibble:', $self->{nibble_sth}->{Statement}, 'params:',
|
||||
@@ -5596,6 +5616,7 @@ sub next {
|
||||
}
|
||||
$self->{rowno} = 0;
|
||||
$self->{have_rows} = 0;
|
||||
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Done nibbling');
|
||||
@@ -5731,10 +5752,13 @@ sub can_nibble {
|
||||
die "There is no good index and the table is oversized.";
|
||||
}
|
||||
|
||||
my $pause_file = ($o->has('pause-file') && $o->get('pause-file')) || undef;
|
||||
|
||||
return {
|
||||
row_est => $row_est, # nibble about this many rows
|
||||
index => $index, # using this index
|
||||
one_nibble => $one_nibble, # if the table fits in one nibble/chunk
|
||||
pause_file => $pause_file,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11732,6 +11756,12 @@ short form: -p; type: string
|
||||
Password to use when connecting.
|
||||
If password contains commas they must be escaped with a backslash: "exam\,ple"
|
||||
|
||||
=item --pause-file
|
||||
|
||||
type: string
|
||||
|
||||
Execution will be paused while the file specified by this param exists.
|
||||
|
||||
=item --pid
|
||||
|
||||
type: string
|
||||
|
@@ -6336,6 +6336,8 @@ sub new {
|
||||
$self->{have_rows} = 0;
|
||||
$self->{rowno} = 0;
|
||||
$self->{oktonibble} = 1;
|
||||
$self->{pause_file} = $nibble_params->{pause_file};
|
||||
$self->{sleep} = $args{sleep} || 60;
|
||||
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -6374,6 +6376,24 @@ sub next {
|
||||
|
||||
NIBBLE:
|
||||
while ( $self->{have_rows} || $self->_next_boundaries() ) {
|
||||
|
||||
if ($self->{pause_file}) {
|
||||
while(-f $self->{pause_file}) {
|
||||
print "Sleeping $self->{sleep} seconds because $self->{pause_file} exists\n";
|
||||
my $dbh = $self->{Cxn}->dbh();
|
||||
if ( !$dbh || !$dbh->ping() ) {
|
||||
eval { $dbh = $self->{Cxn}->connect() }; # connect or die trying
|
||||
if ( $EVAL_ERROR ) {
|
||||
chomp $EVAL_ERROR;
|
||||
die "Lost connection to " . $self->{Cxn}->name() . " while waiting for "
|
||||
. "replica lag ($EVAL_ERROR)\n";
|
||||
}
|
||||
}
|
||||
$dbh->do("SELECT 'nibble iterator keepalive'");
|
||||
sleep($self->{sleep});
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$self->{have_rows} ) {
|
||||
$self->{nibbleno}++;
|
||||
PTDEBUG && _d('Nibble:', $self->{nibble_sth}->{Statement}, 'params:',
|
||||
@@ -6403,6 +6423,7 @@ sub next {
|
||||
}
|
||||
$self->{rowno} = 0;
|
||||
$self->{have_rows} = 0;
|
||||
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Done nibbling');
|
||||
@@ -6538,10 +6559,13 @@ sub can_nibble {
|
||||
die "There is no good index and the table is oversized.";
|
||||
}
|
||||
|
||||
my $pause_file = ($o->has('pause-file') && $o->get('pause-file')) || undef;
|
||||
|
||||
return {
|
||||
row_est => $row_est, # nibble about this many rows
|
||||
index => $index, # using this index
|
||||
one_nibble => $one_nibble, # if the table fits in one nibble/chunk
|
||||
pause_file => $pause_file,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12397,6 +12421,12 @@ short form: -p; type: string; group: Connection
|
||||
Password to use when connecting.
|
||||
If password contains commas they must be escaped with a backslash: "exam\,ple"
|
||||
|
||||
=item --pause-file
|
||||
|
||||
type: string
|
||||
|
||||
Execution will be paused while the file specified by this param exists.
|
||||
|
||||
=item --pid
|
||||
|
||||
type: string
|
||||
|
Reference in New Issue
Block a user