Bug#42465 mysqlhotcopy fails with "Table '<y>' was locked with a READ lock" error message.
Since 5.5 FLUSH TABLES requires unlocked tables so the old LOCK TABLES/FLUSH TABLES model fails. Use atomic FLUSH TABLES WITH READ LOCK instead. per-file comments: scripts/mysqlhotcopy.sh Bug#42465 mysqlhotcopy fails with "Table '<y>' was locked with a READ lock" error message. Use FLUSH TABLES WITH READ LOCK instead of LOCK TABLES / FLUSH TABLES pair. Keep the old scheme for older servers.
This commit is contained in:
parent
48367a2155
commit
73c4dc3699
@ -56,6 +56,8 @@ Usage: $0 db_name[./table_regex/] [new_db_name | directory]
|
|||||||
-h, --host=# hostname for local server when connecting over TCP/IP
|
-h, --host=# hostname for local server when connecting over TCP/IP
|
||||||
-P, --port=# port to use when connecting to local server with TCP/IP
|
-P, --port=# port to use when connecting to local server with TCP/IP
|
||||||
-S, --socket=# socket to use when connecting to local server
|
-S, --socket=# socket to use when connecting to local server
|
||||||
|
--old_server connect to old MySQL-server (before v5.5) which
|
||||||
|
doesn't have FLUSH TABLES WITH READ LOCK fully implemented.
|
||||||
|
|
||||||
--allowold don\'t abort if target dir already exists (rename it _old)
|
--allowold don\'t abort if target dir already exists (rename it _old)
|
||||||
--addtodest don\'t rename target dir if it exists, just add files to it
|
--addtodest don\'t rename target dir if it exists, just add files to it
|
||||||
@ -103,6 +105,7 @@ GetOptions( \%opt,
|
|||||||
"password|p=s",
|
"password|p=s",
|
||||||
"port|P=s",
|
"port|P=s",
|
||||||
"socket|S=s",
|
"socket|S=s",
|
||||||
|
"old_server",
|
||||||
"allowold!",
|
"allowold!",
|
||||||
"keepold!",
|
"keepold!",
|
||||||
"addtodest!",
|
"addtodest!",
|
||||||
@ -441,14 +444,21 @@ if ( $opt{checkpoint} || $opt{record_log_pos} ) {
|
|||||||
my $hc_started = time; # count from time lock is granted
|
my $hc_started = time; # count from time lock is granted
|
||||||
|
|
||||||
if ( $opt{dryrun} ) {
|
if ( $opt{dryrun} ) {
|
||||||
|
if ( $opt{old_server} ) {
|
||||||
print "LOCK TABLES $hc_locks\n";
|
print "LOCK TABLES $hc_locks\n";
|
||||||
print "FLUSH TABLES /*!32323 $hc_tables */\n";
|
print "FLUSH TABLES /*!32323 $hc_tables */\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print "FLUSH TABLES $hc_tables WITH READ LOCK\n";
|
||||||
|
}
|
||||||
|
|
||||||
print "FLUSH LOGS\n" if ( $opt{flushlog} );
|
print "FLUSH LOGS\n" if ( $opt{flushlog} );
|
||||||
print "RESET MASTER\n" if ( $opt{resetmaster} );
|
print "RESET MASTER\n" if ( $opt{resetmaster} );
|
||||||
print "RESET SLAVE\n" if ( $opt{resetslave} );
|
print "RESET SLAVE\n" if ( $opt{resetslave} );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my $start = time;
|
my $start = time;
|
||||||
|
if ( $opt{old_server} ) {
|
||||||
$dbh->do("LOCK TABLES $hc_locks");
|
$dbh->do("LOCK TABLES $hc_locks");
|
||||||
printf "Locked $num_tables tables in %d seconds.\n", time-$start unless $opt{quiet};
|
printf "Locked $num_tables tables in %d seconds.\n", time-$start unless $opt{quiet};
|
||||||
$hc_started = time; # count from time lock is granted
|
$hc_started = time; # count from time lock is granted
|
||||||
@ -456,6 +466,15 @@ else {
|
|||||||
# flush tables to make on-disk copy up to date
|
# flush tables to make on-disk copy up to date
|
||||||
$start = time;
|
$start = time;
|
||||||
$dbh->do("FLUSH TABLES /*!32323 $hc_tables */");
|
$dbh->do("FLUSH TABLES /*!32323 $hc_tables */");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$dbh->do("FLUSH TABLES $hc_tables WITH READ LOCK");
|
||||||
|
printf "Locked $num_tables tables in %d seconds.\n", time-$start unless $opt{quiet};
|
||||||
|
$hc_started = time; # count from time lock is granted
|
||||||
|
|
||||||
|
# flush tables to make on-disk copy up to date
|
||||||
|
$start = time;
|
||||||
|
}
|
||||||
printf "Flushed tables ($hc_tables) in %d seconds.\n", time-$start unless $opt{quiet};
|
printf "Flushed tables ($hc_tables) in %d seconds.\n", time-$start unless $opt{quiet};
|
||||||
$dbh->do( "FLUSH LOGS" ) if ( $opt{flushlog} );
|
$dbh->do( "FLUSH LOGS" ) if ( $opt{flushlog} );
|
||||||
$dbh->do( "RESET MASTER" ) if ( $opt{resetmaster} );
|
$dbh->do( "RESET MASTER" ) if ( $opt{resetmaster} );
|
||||||
@ -975,6 +994,10 @@ when using the --host option.
|
|||||||
|
|
||||||
UNIX domain socket to use when connecting to local server.
|
UNIX domain socket to use when connecting to local server.
|
||||||
|
|
||||||
|
=item --old_server
|
||||||
|
|
||||||
|
Use old server (pre v5.5) commands.
|
||||||
|
|
||||||
=item --noindices
|
=item --noindices
|
||||||
|
|
||||||
Don\'t include index files in copy. Only up to the first 2048 bytes
|
Don\'t include index files in copy. Only up to the first 2048 bytes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user