Skip to content

Commit c0e48fc

Browse files
committed
WIP MDEV-39092, and back up non-InnoDB files
1 parent 7f207a2 commit c0e48fc

7 files changed

Lines changed: 502 additions & 5 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Prepare database
2+
CREATE TABLE tinno (i INTEGER) ENGINE=InnoDB;
3+
INSERT INTO tinno VALUES (1), (2), (3), (4);
4+
CREATE TABLE tariatr (i INTEGER) ENGINE=Aria TRANSACTIONAL=1;
5+
INSERT INTO tariatr VALUES (2), (3), (5), (7);
6+
CREATE TABLE tariant (i INTEGER) ENGINE=Aria TRANSACTIONAL=0;
7+
INSERT INTO tariant VALUES (1), (1), (2), (3), (5);
8+
Back up the database
9+
BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
10+
Restore the database
11+
# restart: --datadir=MYSQLTEST_VARDIR/some_directory
12+
Check contents after restore
13+
SELECT * FROM tinno;
14+
i
15+
1
16+
2
17+
3
18+
4
19+
SELECT * FROM tariatr;
20+
i
21+
2
22+
3
23+
5
24+
7
25+
SELECT * FROM tariant;
26+
i
27+
1
28+
1
29+
2
30+
3
31+
5
32+
Warnings:
33+
Error 145 Got error '145 "Table was marked as crashed and should be repaired"' for './test/tariant'
34+
Warning 1034 1 client is using or hasn't closed the table properly
35+
Note 1034 Table is fixed
36+
Restart database in original data directory
37+
# restart
38+
Clean up
39+
DROP TABLE tinno;
40+
DROP TABLE tariatr;
41+
DROP TABLE tariant;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--source include/not_windows.inc
2+
--source include/have_innodb.inc
3+
4+
--echo Prepare database
5+
CREATE TABLE tinno (i INTEGER) ENGINE=InnoDB;
6+
INSERT INTO tinno VALUES (1), (2), (3), (4);
7+
CREATE TABLE tariatr (i INTEGER) ENGINE=Aria TRANSACTIONAL=1;
8+
INSERT INTO tariatr VALUES (2), (3), (5), (7);
9+
CREATE TABLE tariant (i INTEGER) ENGINE=Aria TRANSACTIONAL=0;
10+
INSERT INTO tariant VALUES (1), (1), (2), (3), (5);
11+
12+
--echo Back up the database
13+
evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
14+
15+
--echo Restore the database
16+
--disable_query_log
17+
call mtr.add_suppression("InnoDB: Did not find any checkpoint after LSN=");
18+
call mtr.add_suppression("InnoDB: Renaming ib_[0-9]+.log to ib_logfile0");
19+
call mtr.add_suppression("mariadbd: Got error '145 \"Table was marked as crashed and should be repaired\"' for ");
20+
call mtr.add_suppression("Checking table: ");
21+
--enable_query_log
22+
--let $restart_parameters=--datadir=$MYSQLTEST_VARDIR/some_directory
23+
--source include/restart_mysqld.inc
24+
25+
--echo Check contents after restore
26+
SELECT * FROM tinno;
27+
SELECT * FROM tariatr;
28+
SELECT * FROM tariant;
29+
30+
--echo Restart database in original data directory
31+
--let $restart_parameters=
32+
--source include/restart_mysqld.inc
33+
34+
--echo Clean up
35+
DROP TABLE tinno;
36+
DROP TABLE tariatr;
37+
DROP TABLE tariant;
38+
--rmdir $MYSQLTEST_VARDIR/some_directory

mysql-test/suite/backup/backup_innodb.test

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ SET DEBUG_SYNC='now WAIT_FOR start';
2626
INSERT INTO t(a) SELECT * FROM seq_1_to_30000;
2727
SET DEBUG_SYNC='now SIGNAL resume';
2828
--connection backup
29+
# FIXME: outside PMEM we may get ER_ERROR_ON_RENAME
2930
--reap
3031
}
3132
if (!$have_debug) {
@@ -37,13 +38,16 @@ eval BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
3738
--connection default
3839
ROLLBACK;
3940
SELECT * FROM t;
41+
DELETE FROM t;
4042

4143
let $datadir=`SELECT @@datadir`;
42-
--source include/shutdown_mysqld.inc
43-
#--rmdir $datadir
44-
#--move_file $MYSQLTEST_VARDIR/some_directory $datadir
45-
--rmdir $MYSQLTEST_VARDIR/some_directory
46-
--source include/start_mysqld.inc
44+
--let $restart_parameters=--datadir=$MYSQLTEST_VARDIR/some_directory
45+
--source include/restart_mysqld.inc
4746

47+
SELECT * FROM t;
48+
--let $restart_parameters=
49+
--source include/restart_mysqld.inc
4850
SELECT * FROM t;
4951
DROP TABLE t;
52+
53+
--rmdir $MYSQLTEST_VARDIR/some_directory

storage/maria/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ SET(ARIA_SOURCES ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c
4545
ha_maria.h maria_def.h ma_recovery_util.c ma_servicethread.c
4646
ma_norec.c
4747
ma_crypt.c ma_backup.c
48+
ma_backup.cc ma_backup.h
4849
)
4950

5051
IF(APPLE)

storage/maria/ha_maria.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <myisampack.h>
2424
#include <my_bit.h>
2525
#include "ha_maria.h"
26+
#include "ma_backup.h"
2627
#include "trnman_public.h"
2728
#include "trnman.h"
2829

@@ -3942,6 +3943,9 @@ static int ha_maria_init(void *p)
39423943
maria_hton->prepare_for_backup= maria_prepare_for_backup;
39433944
maria_hton->end_backup= maria_end_backup;
39443945
maria_hton->update_optimizer_costs= aria_update_optimizer_costs;
3946+
maria_hton->backup_start= aria_backup_start;
3947+
maria_hton->backup_step= aria_backup_step;
3948+
maria_hton->backup_end= aria_backup_end;
39453949

39463950
/* TODO: decide if we support Maria being used for log tables */
39473951
maria_hton->flags= (HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES |

0 commit comments

Comments
 (0)