Browse Source
Fix for BUG#37876 "Importing Maria table from other server via binary copy does not work":
Fix for BUG#37876 "Importing Maria table from other server via binary copy does not work":
- after auto-zerofill (ha_maria::check_and_repair()) kepts its state's LSNs unchanged, which could be the same as the create_rename_lsn of another pre-existing table, which would break versioning as this LSN serves as unique identifier in the versioning code (in maria_open()). Even the state pieces which maria_zerofill() did change were lost (because they didn't go to disk). - after this fix, if two tables were auto-zerofilled at the same time (by _ma_mark_changed()) they could receive the same create_rename_lsn, which would break versioning again. Fix is to write a log record each time a table is imported. - Print state's LSNs (create_rename_lsn, is_of_horizon, skip_redo_lsn) and UUID in maria_chk -dvv. mysql-test/r/maria-autozerofill.result: result mysql-test/t/maria-autozerofill.test: Test for auto-zerofilling storage/maria/ha_maria.cc: The state changes done by auto-zerofilling never reached disk. storage/maria/ma_check.c: When zerofilling a table, including its pages' LSNs, new state LSNs are needed next time the table is imported into a Maria instance. storage/maria/ma_create.c: Write LOGREC_IMPORTED_TABLE when importing a table. This is informative and ensures that the table gets a unique create_rename_lsn even though multiple tables are imported by concurrent threads (it advances the log's end LSN). storage/maria/ma_key_recover.c: comment storage/maria/ma_locking.c: instead of using translog_get_horizon() for state's LSNs of imported table, use the LSN of to-be-written LOGREC_IMPORTED_TABLE. storage/maria/ma_loghandler.c: New type of log record storage/maria/ma_loghandler.h: New type of log record storage/maria/ma_loghandler_lsn.h: New name for constant as can be used not only by maria_chk but auto-zerofill now too. storage/maria/ma_open.c: instead of using translog_get_horizon() for state's LSNs of imported table, use the LSN of to-be-written LOGREC_IMPORTED_TABLE. storage/maria/ma_recovery.c: print content of LOGREC_IMPORTED_TABLE in maria_read_log. storage/maria/maria_chk.c: print info about LSNs of the table's state, and UUID, when maria_chk -dvv storage/maria/maria_pack.c: new name for constant storage/maria/unittest/ma_test_recovery.pl: Now that maria_chk -dvv shows state LSNs and UUID those need to be filtered out, as maria_read_log -a does not use the same as at original run.pull/843/head
15 changed files with 199 additions and 20 deletions
-
20mysql-test/r/maria-autozerofill.result
-
80mysql-test/t/maria-autozerofill.test
-
9storage/maria/ha_maria.cc
-
16storage/maria/ma_check.c
-
22storage/maria/ma_create.c
-
3storage/maria/ma_key_recover.c
-
4storage/maria/ma_locking.c
-
6storage/maria/ma_loghandler.c
-
1storage/maria/ma_loghandler.h
-
8storage/maria/ma_loghandler_lsn.h
-
6storage/maria/ma_open.c
-
20storage/maria/ma_recovery.c
-
14storage/maria/maria_chk.c
-
4storage/maria/maria_pack.c
-
6storage/maria/unittest/ma_test_recovery.pl
@ -0,0 +1,20 @@ |
|||
drop database if exists mysqltest; |
|||
create database mysqltest; |
|||
use mysqltest; |
|||
create table t1(a int) engine=maria; |
|||
insert into t1 values(1); |
|||
flush table t1; |
|||
create_rename_lsn has non-magic value |
|||
* shut down mysqld, removed logs, restarted it |
|||
select * from t1; |
|||
a |
|||
1 |
|||
Warnings: |
|||
Error 1194 t1' is marked as crashed and should be repaired |
|||
flush table t1; |
|||
Status: changed,sorted index pages,zerofilled,movable |
|||
create_rename_lsn has magic value |
|||
insert into t1 values(2); |
|||
flush table t1; |
|||
create_rename_lsn has non-magic value |
|||
drop database mysqltest; |
|||
@ -0,0 +1,80 @@ |
|||
# Test to verify that auto-zerofilling happens when a table is |
|||
# imported from a different Maria instance |
|||
|
|||
# can't restart in embedded |
|||
--source include/not_embedded.inc |
|||
--source include/have_maria.inc |
|||
|
|||
let $MARIA_LOG=.; |
|||
|
|||
--disable_warnings |
|||
drop database if exists mysqltest; |
|||
--enable_warnings |
|||
create database mysqltest; |
|||
let $mms_tname=t; |
|||
|
|||
connect (admin, localhost, root,,mysqltest,,); |
|||
--enable_reconnect |
|||
|
|||
connection default; |
|||
use mysqltest; |
|||
--enable_reconnect |
|||
|
|||
create table t1(a int) engine=maria; |
|||
insert into t1 values(1); |
|||
flush table t1; |
|||
# Check that table is not zerofilled, not movable |
|||
--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt |
|||
perl; |
|||
use strict; |
|||
use warnings; |
|||
my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt"; |
|||
open(FILE, "<", $fname) or die; |
|||
my @content= <FILE>; |
|||
print grep(/Status:.*(zerofilled|movable)/, @content); |
|||
print "create_rename_lsn has non-magic value\n" if grep(/create_rename \([0-9]+/, @content); |
|||
close FILE; |
|||
EOF |
|||
|
|||
# this will remove control file, so change the uuid of the Maria |
|||
# instance, thus t1 will appear as imported from elsewhere. |
|||
|
|||
-- source include/maria_empty_logs.inc |
|||
|
|||
disable_ps_protocol; # see maria-recover.test |
|||
replace_regex /Table.*t1/t1/ ; |
|||
select * from t1; |
|||
enable_ps_protocol; |
|||
flush table t1; |
|||
|
|||
# Check that table is auto-zerofilled, movable |
|||
--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt |
|||
perl; |
|||
use strict; |
|||
use warnings; |
|||
my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt"; |
|||
open(FILE, "<", $fname) or die; |
|||
my @content= <FILE>; |
|||
print grep(/Status:.*zerofilled/, @content); |
|||
print "create_rename_lsn has magic value\n" if grep(/create_rename \(0,0x2\)/, @content); |
|||
close FILE; |
|||
EOF |
|||
|
|||
# this will attach t1 to the current Maria instance |
|||
insert into t1 values(2); |
|||
flush table t1; |
|||
|
|||
# Check that table is not zerofilled, not movable |
|||
--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt |
|||
perl; |
|||
use strict; |
|||
use warnings; |
|||
my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt"; |
|||
open(FILE, "<", $fname) or die; |
|||
my @content= <FILE>; |
|||
print grep(/Status:.*(zerofilled|movable)/, @content); |
|||
print "create_rename_lsn has non-magic value\n" if grep(/create_rename \([0-9]+/, @content); |
|||
close FILE; |
|||
EOF |
|||
|
|||
drop database mysqltest; |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue