mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 05:29:30 +00:00
Adding --read-only-interval flag, and read-only check on wake-up
This commit is contained in:
@@ -5802,11 +5802,12 @@ sub main {
|
|||||||
if ( server_is_readonly($dbh) && PTDEBUG ) {
|
if ( server_is_readonly($dbh) && PTDEBUG ) {
|
||||||
_d('Server is read-only, waiting')
|
_d('Server is read-only, waiting')
|
||||||
}
|
}
|
||||||
my $start_time = time;
|
my $start_time = time;
|
||||||
my $run_time = $o->get('run-time');
|
my $run_time = $o->get('run-time');
|
||||||
my $interval = $o->get('interval') || 5;
|
my $interval = $o->get('interval') || 5;
|
||||||
|
my $read_only_interval = $o->get('read-only-interval') || $interval;
|
||||||
while (server_is_readonly($dbh)) {
|
while (server_is_readonly($dbh)) {
|
||||||
sleep($interval);
|
sleep($read_only_interval);
|
||||||
if (
|
if (
|
||||||
($run_time && $run_time < time - $start_time)
|
($run_time && $run_time < time - $start_time)
|
||||||
|| -f $sentinel
|
|| -f $sentinel
|
||||||
@@ -6223,6 +6224,18 @@ sub main {
|
|||||||
sleep $next_interval - $time;
|
sleep $next_interval - $time;
|
||||||
PTDEBUG && _d('Woke up at', ts(time));
|
PTDEBUG && _d('Woke up at', ts(time));
|
||||||
|
|
||||||
|
if ( $o->get('check-read-only') && $o->get('update') ) {
|
||||||
|
my $read_only_interval = $o->get('read-only-interval') || $interval;
|
||||||
|
while (server_is_readonly($dbh)) {
|
||||||
|
sleep($read_only_interval);
|
||||||
|
if (
|
||||||
|
-f $sentinel
|
||||||
|
) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Connect or reconnect if necessary.
|
# Connect or reconnect if necessary.
|
||||||
if ( !$dbh->ping() ) {
|
if ( !$dbh->ping() ) {
|
||||||
$dbh = $dp->get_dbh($dp->get_cxn_params($dsn), { AutoCommit => 1 });
|
$dbh = $dp->get_dbh($dp->get_cxn_params($dsn), { AutoCommit => 1 });
|
||||||
@@ -6619,7 +6632,7 @@ before its delay. L<"--recurse"> only works with MySQL.
|
|||||||
=item --check-read-only
|
=item --check-read-only
|
||||||
|
|
||||||
Check if the server has read_only enabled; If it does, the tool skips doing
|
Check if the server has read_only enabled; If it does, the tool skips doing
|
||||||
any inserts.
|
any inserts. See also L<"--read-only-interval">
|
||||||
|
|
||||||
=item --config
|
=item --config
|
||||||
|
|
||||||
@@ -6835,6 +6848,13 @@ Print the auto-detected or given L<"--master-server-id">. If L<"--check">
|
|||||||
or L<"--monitor"> is specified, specifying this option will print the
|
or L<"--monitor"> is specified, specifying this option will print the
|
||||||
auto-detected or given L<"--master-server-id"> at the end of each line.
|
auto-detected or given L<"--master-server-id"> at the end of each line.
|
||||||
|
|
||||||
|
=item --read-only-interval
|
||||||
|
|
||||||
|
type: int
|
||||||
|
|
||||||
|
When L<"--check-read-only"> is specified, the interval to sleep while the
|
||||||
|
server is found to be read-only. If unspecified, L<"--interval"> is used.
|
||||||
|
|
||||||
=item --recurse
|
=item --recurse
|
||||||
|
|
||||||
type: int
|
type: int
|
||||||
|
Reference in New Issue
Block a user