| 1 | package Mojar::Mysql::Replication; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Mojo::Base -base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | our $VERSION = 0.034; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp 'croak'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Mojar::Util qw(as_bool dumper lc_keys); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Mojar::Log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # Time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | has stop_io_run_time => 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | has stop_sql_max_wait => 55; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # Behaviour | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | has safety => 'medium_safety'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # Accessors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | has 'connector'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | has log => sub { Mojar::Log->new(pattern => '%y%m%d %H%M%S') }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # Public methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub stop_io { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stop_io: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $self->connector->connection->do(q{STOP SLAVE IO_THREAD}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my $e = $@ // 'unknown failure'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ // "unknown failure"
MC/DC0%0/1
$@ // "unknown failure"
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if ($e =~ / failed: This operation requires a running slave/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $self->log->warn('stop_io: Was not a running slave') if $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | $self->log->error("stop_io: $e") if $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | croak "Failed to stop io_thread: $e"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub start_io { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_io: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $self->connector->connection->do(q{START SLAVE IO_THREAD}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | my $e = $@ // 'unknown failure'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ // "unknown failure"
MC/DC0%0/1
$@ // "unknown failure"
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($e =~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | / failed: This operation cannot be performed with a running slave/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | $self->log->warn('start_io: Was already a running slave') if $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | $self->log->error("start_io: $e") if $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | croak "Failed to start io_thread: $e"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub stop_sql { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stop_sql: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->connector->connection->do(q{STOP SLAVE SQL_THREAD}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my $e = $@ // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ // ""
MC/DC0%0/1
$@ // ""
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ($e =~ / failed: This operation requires a running slave/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $self->log->warn(q{stop_sql: Was not a running slave}) if $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $self->log->error("stop_sql: $e") if $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | croak "Failed to stop sql_thread: $e"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub start_sql { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_sql: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $self->connector->connection->do(q{START SLAVE SQL_THREAD}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my $e = $@ // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ // ""
MC/DC0%0/1
$@ // ""
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ($e =~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | / failed: This operation cannot be performed with a running slave/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | $self->log->warn(q{start_sql: Was already a running slave}) if $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | $self->log->error("start_sql: $e") if $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | croak "Failed to start sql_thread: $e"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub sql_thread_waiting { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sql_thread_waiting: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my ($is_waiting, $repl_found, $threads); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $threads = $self->connector->connection->threads; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | my $e = $@ // 'unknown failure'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ // "unknown failure"
MC/DC0%0/1
$@ // "unknown failure"
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | $self->log->error("sql_thread_waiting: $e") if $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | croak "Problem found trying to check sql_thread\n$e"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | for my $t (grep {$_->{user} eq 'system user'} @$threads) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ++$repl_found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | $is_waiting = 1 if $t->{state} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | and $t->{state} =~ /^(?:Slave has|Has) read all relay log/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$t->{"state"} and $t->{"state"} =~ /^(?:Slave has|Has) read all relay log/u
MC/DC0%0/2
$t->{"state"} and $t->{"state"} =~ /^(?:Slave has|Has) read all relay log/u
$t->{"state"}
$t->{"state"} =~ /^(?:Slave has|Has) read all relay log/u
Truth table0%0/3
A and B
A= $t->{"state"}B= $t->{"state"} =~ /^(?:Slave has|Has) read all relay log/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | croak 'Replication does not appear to be running' unless $repl_found; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return $is_waiting; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | sub sql_thread_aligned { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sql_thread_aligned: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $status = $self->status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | croak q{Not configured as a slave} unless $status->{master_host}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | return ($status->{master_log_file} eq $status->{relay_master_log_file} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | and $status->{read_master_log_pos} == $status->{exec_master_log_pos}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$status->{'master_log_file'} eq $status->{'relay_master_log_file'} && $status->{'read_master_log_pos'} == $status->{'exec_master_log_pos'}
MC/DC0%0/2
$status->{'master_log_file'} eq $status->{'relay_master_log_file'} && $status->{'read_master_log_pos'} == $status->{'exec_master_log_pos'}
$status->{'master_log_file'} eq $status->{'relay_master_log_file'}
$status->{'read_master_log_pos'} == $status->{'exec_master_log_pos'}
Truth table0%0/3
A && B
A= $status->{'master_log_file'} eq $status->{'relay_master_log_file'}B= $status->{'read_master_log_pos'} == $status->{'exec_master_log_pos'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | $status = lc_keys($self->connector->connection->selectrow_hashref( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->connector->connection->selectrow_hashref('SHOW SLAVE STATUS') || {}
MC/DC0%0/1
$self->connector->connection->selectrow_hashref('SHOW SLAVE STATUS') || {}
$self->connector->connection->selectrow_hashref('SHOW SLAVE STATUS')
Truth table0%0/2
A
A= $self->connector->connection->selectrow_hashref('SHOW SLAVE STATUS')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | q{SHOW SLAVE STATUS}) || {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | my $e = $@ // 'unknown failure'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ // "unknown failure"
MC/DC0%0/1
$@ // "unknown failure"
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | $self->log->error("status: $e") if $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | croak 'Failed to get replication status'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | return $status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub stop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stop: not called CC=19 SCAR=59.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my ($self, $safety) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | $safety //= $self->safety; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$safety //= $self->safety
MC/DC0%0/2
$safety //= $self->safety
$safety
$self->safety
Truth table0%0/3
A //= B
A= $safetyB= $self->safety
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | #TODO: Check whether has privs to see system_user threads | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # max_safety == outside_transaction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # medium_safety == trust_transaction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # low_safety == time_limited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # no_safety == emergency | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if ($safety eq 'no_safety' or $safety eq 'emergency') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/3
$safety eq "no_safety" or $safety eq "emergency"
MC/DC0%0/2
$safety eq "no_safety" or $safety eq "emergency"
$safety eq "no_safety"
$safety eq "emergency"
Truth table0%0/3
A or B
A= $safety eq "no_safety"B= $safety eq "emergency"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $self->stop_io; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $self->stop_sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ▶ | elsif ($safety eq 'max_safety' or $safety eq 'outside_transaction') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$safety eq "max_safety" or $safety eq "outside_transaction"
MC/DC0%0/2
$safety eq "max_safety" or $safety eq "outside_transaction"
$safety eq "max_safety"
$safety eq "outside_transaction"
Truth table0%0/3
A or B
A= $safety eq "max_safety"B= $safety eq "outside_transaction"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $self->stop_io; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if ($self->status->{slave_sql_running} =~ /^No/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $self->start_sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | sleep 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sleep 1 while not $self->sql_thread_waiting; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | while (not $self->sql_thread_aligned) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $self->start_io; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | sleep $self->stop_io_run_time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $self->stop_io; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sleep 1 while not $self->sql_thread_waiting; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $self->stop_sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | ▶ | elsif ($safety eq 'medium_safety' or $safety eq 'trust_transaction') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$safety eq "medium_safety" or $safety eq "trust_transaction"
MC/DC0%0/2
$safety eq "medium_safety" or $safety eq "trust_transaction"
$safety eq "medium_safety"
$safety eq "trust_transaction"
Truth table0%0/3
A or B
A= $safety eq "medium_safety"B= $safety eq "trust_transaction"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->stop_io; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | return $self unless $self->status->{slave_sql_running} =~ /^Yes/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sleep 1 while not $self->sql_thread_waiting; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $self->stop_sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | ▶ | elsif ($safety eq 'low_safety' or $safety eq 'time_limited') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$safety eq "low_safety" or $safety eq "time_limited"
MC/DC0%0/2
$safety eq "low_safety" or $safety eq "time_limited"
$safety eq "low_safety"
$safety eq "time_limited"
Truth table0%0/3
A or B
A= $safety eq "low_safety"B= $safety eq "time_limited"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $self->stop_io; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | return $self unless $self->status->{slave_sql_running} =~ /^Yes/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $waited = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | sleep 1 while not $self->sql_thread_waiting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $self->sql_thread_waiting and $waited++ < $self->stop_sql_max_wait
MC/DC0%0/2
not $self->sql_thread_waiting and $waited++ < $self->stop_sql_max_wait
not $self->sql_thread_waiting
$waited++ < $self->stop_sql_max_wait
Truth table0%0/3
not(A) and B
A= not $self->sql_thread_waitingB= $waited++ < $self->stop_sql_max_wait
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | and $waited++ < $self->stop_sql_max_wait; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $self->stop_sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | croak "Unrecognised safety level ($safety)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub io_run_time { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
io_run_time: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my ($thread, undef) = $self->system_threads; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | unless (defined $thread) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | sleep 5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ($thread, undef) = $self->system_threads; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | return undef unless defined $thread; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | return $thread->{time} < 4_000_000_000 ? $thread->{time} : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | sub sql_lag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sql_lag: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my (undef, $thread) = $self->system_threads; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | unless (defined $thread) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | sleep 5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | (undef, $thread) = $self->system_threads; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | return undef unless defined $thread; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | return $thread->{time} < 4_000_000_000 ? $thread->{time} : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | sub system_threads { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
system_threads: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my ($self, $threads) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my ($io_thread, $sql_thread, @candidates); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | $_->{user} eq 'system user' and push @candidates, $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | for @{$threads // $self->connector->connection->threads}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$threads // $self->connector->connection->threads
MC/DC0%0/2
$threads // $self->connector->connection->threads
$threads
$self->connector->connection->threads
Truth table0%0/3
A // B
A= $threadsB= $self->connector->connection->threads
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | return (undef, undef) unless @candidates; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # The following assumes there are at most two system threads | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # Examine first candidate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my $hint = $self->_system_thread_spotter($candidates[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | if ($hint == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $io_thread = $candidates[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | $sql_thread = $candidates[1] if @candidates > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | return ($io_thread, $sql_thread); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | elsif ($hint == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $sql_thread = $candidates[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | $io_thread = $candidates[1] if @candidates > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | return ($io_thread, $sql_thread); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | elsif (@candidates == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $self->log->error("Failed to identify thread\n". dumper $candidates[0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | if $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # Examine second candidate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $hint = $self->_system_thread_spotter($candidates[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | if ($hint == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | return ($io_thread, $sql_thread) = ($candidates[1], $candidates[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | elsif ($hint == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | return ($io_thread, $sql_thread) = @candidates; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | $self->log->error("Failed to identify thread\n". dumper $candidates[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | if $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | sub active_threads { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
active_threads: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my ($self, $threads) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | $threads //= $self->connector->connection->threads; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$threads //= $self->connector->connection->threads
MC/DC0%0/2
$threads //= $self->connector->connection->threads
$threads
$self->connector->connection->threads
Truth table0%0/3
A //= B
A= $threadsB= $self->connector->connection->threads
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my @candidates; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | $_->{user} and $_->{user} ne 'system user' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | and $_->{state} and $_->{state} ne 'Sleep' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | and push @candidates, $_ for @$threads; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$_->{"user"} and $_->{"user"} ne "system user" and $_->{"state"} and $_->{"state"} ne "Sleep"
$_->{"user"} and $_->{"user"} ne "system user" and $_->{"state"}
$_->{"user"} and $_->{"user"} ne "system user"
MC/DC0%0/4
$_->{"user"} and $_->{"user"} ne "system user" and $_->{"state"} and $_->{"state"} ne "Sleep"
$_->{"user"}
$_->{"user"} ne "system user"
$_->{"state"}
$_->{"state"} ne "Sleep"
Truth table0%0/5
A and B and C and D
A= $_->{"user"}B= $_->{"user"} ne "system user"C= $_->{"state"}D= $_->{"state"} ne "Sleep"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | return \@candidates; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | sub purge_binary_logs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
purge_binary_logs: not called CC=15 SCAR=54.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my ($self, $master, $slaves, $keep) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | for my $c ($master, @$slaves) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | croak 'Requires database connectors' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $c and ref $c and $c->can("connection")
defined $c and ref $c
MC/DC0%0/3
defined $c and ref $c and $c->can("connection")
defined $c
ref $c
$c->can("connection")
Truth table0%0/4
A and B and C
A= defined $cB= ref $cC= $c->can("connection")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | unless defined $c and ref $c and $c->can('connection'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # Check the master | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my $master_dbh = $master->connection; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $logs = $master_dbh->selectall_arrayref_hashrefs( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | q{SHOW MASTER LOGS} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | return 0 unless @$logs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # Check each of the slaves | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my $required = $logs->[-1]{log_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | for my $s (@$slaves) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my $r = $self->new(connector => $s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | my $referenced = $r->status->{master_log_file} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | or croak 'Failed to interpret slave status'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | $required = $referenced if $referenced lt $required; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # $required is the oldest bin log required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # Check it is still available | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $required_index = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | for (my $i = 0; $i < @$logs; ++$i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | $required_index = $i and last if $logs->[$i]{log_name} eq $required; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$logs->[$i]{'log_name'} eq $required && (($required_index = $i) && (last))
$required_index = $i and last
MC/DC0%0/2
$logs->[$i]{'log_name'} eq $required && (($required_index = $i) && (last))
$logs->[$i]{'log_name'} eq $required
$required_index = $i
Truth table0%0/3
A && B
A= $logs->[$i]{'log_name'} eq $requiredB= $required_index = $i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | die "Required binary log not available ($required)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | unless $required_index >= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $required_index = $#{$logs} - $keep | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if $keep and $#{$logs} - $keep < $required_index; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$keep and $#{$logs;} - $keep < $required_index
MC/DC0%0/2
$keep and $#{$logs;} - $keep < $required_index
$keep
$#{$logs;} - $keep < $required_index
Truth table0%0/3
A and B
A= $keepB= $#{$logs;} - $keep < $required_index
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | die sprintf 'Purging to %s', $logs->[$required_index]{log_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | sub incr_skip_counter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
incr_skip_counter: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my ($self, $count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | $count //= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$count //= 1
MC/DC0%0/1
$count //= 1
$count
Truth table0%0/2
A
A= $count
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | return $self->connector->connection->global_var( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | sql_slave_skip_counter => $count); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | sub incr_heartbeat { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
incr_heartbeat: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | my ($self, $schema, $table, $column, $where) = @_; $where //= '1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$where //= 1
MC/DC0%0/1
$where //= 1
$where
Truth table0%0/2
A
A= $where
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $self->connector->connection->do(sprintf | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | q{UPDATE `%s`.`%s` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | SET `%s` = `%s` + 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | WHERE %s}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | $schema, $table, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | $column, $column, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | $where | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | sub repair { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repair: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | my ($self, $error, $repair_map) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my $dbh = $self->connector->connection; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | return !! $self->start_sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | sub errored { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
errored: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my ($self, $status) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | $status //= $self->status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$status //= $self->status
MC/DC0%0/2
$status //= $self->status
$status
$self->status
Truth table0%0/3
A //= B
A= $statusB= $self->status
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | return ($status->{last_error} // sprintf 'Error: %u', $status->{last_errno}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | if not as_bool($status->{slave_sql_running}) and $status->{last_errno}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
not as_bool($status->{"slave_sql_running"}) and $status->{"last_errno"}
$status->{"last_error"} // sprintf("Error: %u", $status->{"last_errno"})
MC/DC0%0/2
not as_bool($status->{"slave_sql_running"}) and $status->{"last_errno"}
not as_bool($status->{"slave_sql_running"})
$status->{"last_errno"}
MC/DC0%0/1
$status->{"last_error"} // sprintf("Error: %u", $status->{"last_errno"})
$status->{"last_error"}
Truth table0%0/3
not(A) and B
A= not as_bool($status->{"slave_sql_running"})B= $status->{"last_errno"}
Truth table0%0/2
A
A= $status->{"last_error"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | sub _system_thread_spotter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_system_thread_spotter: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my ($self, $thread) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | # 1: $thread is the io_thread | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # 2: $thread is the sql_thread | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # 0: failed to determine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | return 0 unless ref $thread eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | return 2 if defined $thread->{db}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | return 1 if $thread->{state} =~ /^Waiting for master to send event/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | return 2 if $thread->{state} =~ m{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | ^Waiting\ for\ the\ next\ event | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | | ^Reading\ event\ from\ the\ relay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | | ^Making\ temp\ file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | | ^Has\ read\ all\ relay\ log;\ waiting\ for\ the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | | ^Slave\ has\ read\ all\ relay\ log;\ waiting\ for\ the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | | freeing\ items | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | }x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | return 0; # Don't know | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||