#At file:///home/hf/work/mysql_common/42465/ based on revid:matthias.leich@stripped
3351 Alexey Botchkov 2009-06-11
Bug#42465 mysqlhotcopy fails with "Table '<y>' was locked with a READ lock" error message.
the problem is that this stopped working with 6.0:
LOCK TABLE t1 READ;
FLUSH TABLES;
So mysqlhotcopy was fixed so if the server version is 5.4 and above it does
FLUSH TABLES READ LOCK
instead.
Kostja was planning to implement the
FLUSH TABLES t1 READ LOCK
that will be better option as it only will block the copyed table.
per-file comments:
scripts/mysqlhotcopy.sh
Bug#42465 mysqlhotcopy fails with "Table '<y>' was locked with a READ lock" error message.
use FLUSH TABLES READ LOCK instead of LOCK TABLE t1 READ for the 5.4 and above server
modified:
scripts/mysqlhotcopy.sh
=== modified file 'scripts/mysqlhotcopy.sh'
--- a/scripts/mysqlhotcopy.sh 2009-04-28 16:16:17 +0000
+++ b/scripts/mysqlhotcopy.sh 2009-06-11 09:30:04 +0000
@@ -440,30 +440,55 @@ if ( $opt{checkpoint} || $opt{record_log
my $hc_started = time; # count from time lock is granted
-if ( $opt{dryrun} ) {
- print "LOCK TABLES $hc_locks\n";
- print "FLUSH TABLES /*!32323 $hc_tables */\n";
- print "FLUSH LOGS\n" if ( $opt{flushlog} );
- print "RESET MASTER\n" if ( $opt{resetmaster} );
- print "RESET SLAVE\n" if ( $opt{resetslave} );
-}
-else {
- my $start = time;
- $dbh->do("LOCK TABLES $hc_locks");
- 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;
- $dbh->do("FLUSH TABLES /*!32323 $hc_tables */");
- printf "Flushed tables ($hc_tables) in %d seconds.\n", time-$start unless $opt{quiet};
- $dbh->do( "FLUSH LOGS" ) if ( $opt{flushlog} );
- $dbh->do( "RESET MASTER" ) if ( $opt{resetmaster} );
- $dbh->do( "RESET SLAVE" ) if ( $opt{resetslave} );
-
- if ( $opt{record_log_pos} ) {
- record_log_pos( $dbh, $opt{record_log_pos} );
- $dbh->do("FLUSH TABLES /*!32323 $hc_tables */");
+if ( $dbh->{mysql_serverinfo} =~ /^5\.4/ ) {
+ if ( $opt{dryrun} ) {
+ print "FLUSH TABLES WITH READ LOCK\n";
+ print "FLUSH LOGS\n" if ( $opt{flushlog} );
+ print "RESET MASTER\n" if ( $opt{resetmaster} );
+ print "RESET SLAVE\n" if ( $opt{resetslave} );
+ }
+ else {
+ my $start = time;
+ $hc_started = time; # count from time lock is granted
+
+ # flush tables to make on-disk copy up to date
+ $start = time;
+ $dbh->do("FLUSH TABLES WITH READ LOCK");
+ printf "Flushed tables ($hc_tables) in %d seconds.\n", time-$start unless $opt{quiet};
+ $dbh->do( "FLUSH LOGS" ) if ( $opt{flushlog} );
+ $dbh->do( "RESET MASTER" ) if ( $opt{resetmaster} );
+ $dbh->do( "RESET SLAVE" ) if ( $opt{resetslave} );
+
+ if ( $opt{record_log_pos} ) {
+ warn "--record_log_pos option isn't working in 6.0 yet\n";
+ }
+ }
+} else {
+ if ( $opt{dryrun} ) {
+ print "LOCK TABLES $hc_locks\n";
+ print "FLUSH TABLES /*!32323 $hc_tables */\n";
+ print "FLUSH LOGS\n" if ( $opt{flushlog} );
+ print "RESET MASTER\n" if ( $opt{resetmaster} );
+ print "RESET SLAVE\n" if ( $opt{resetslave} );
+ }
+ else {
+ my $start = time;
+ $dbh->do("LOCK TABLES $hc_locks");
+ 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;
+ $dbh->do("FLUSH TABLES /*!32323 $hc_tables */");
+ printf "Flushed tables ($hc_tables) in %d seconds.\n", time-$start unless $opt{quiet};
+ $dbh->do( "FLUSH LOGS" ) if ( $opt{flushlog} );
+ $dbh->do( "RESET MASTER" ) if ( $opt{resetmaster} );
+ $dbh->do( "RESET SLAVE" ) if ( $opt{resetslave} );
+
+ if ( $opt{record_log_pos} ) {
+ record_log_pos( $dbh, $opt{record_log_pos} );
+ $dbh->do("FLUSH TABLES /*!32323 $hc_tables */");
+ }
}
}
Attachment: [text/bzr-bundle] bzr/holyfoot@mysql.com-20090611093004-36fh9rd61fz93cnc.bundle