Skip to content

Commit 8df5b24

Browse files
MDEV-39092 BACKUP SERVER of ENGINE=Aria to the local file system
Add MTR test. Copy MyISAM files in Aria plugin so that the MTR works. Perform the end step under maximum level of backup MDL to safely copy non-transactional Aria and MyISAM files.
1 parent 8a4c004 commit 8df5b24

4 files changed

Lines changed: 92 additions & 7 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

sql/sql_backup.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,15 @@ bool Sql_cmd_backup::execute(THD *thd)
274274
MYSQL_STORAGE_ENGINE_PLUGIN,
275275
PLUGIN_IS_DELETED|PLUGIN_IS_READY, nullptr);
276276

277-
/* FIXME: Escalate to MDL_BACKUP_BLOCK_DDL or similar */
278-
fail=
279-
plugin_foreach_with_mask(thd, backup_end, MYSQL_STORAGE_ENGINE_PLUGIN,
280-
PLUGIN_IS_DELETED|PLUGIN_IS_READY,
281-
reinterpret_cast<void*>(fail)) || fail;
277+
if(!thd->mdl_context.upgrade_shared_lock(mdl_request.ticket,
278+
MDL_BACKUP_WAIT_COMMIT,
279+
thd->variables.lock_wait_timeout))
280+
fail=
281+
plugin_foreach_with_mask(thd, backup_end, MYSQL_STORAGE_ENGINE_PLUGIN,
282+
PLUGIN_IS_DELETED|PLUGIN_IS_READY,
283+
reinterpret_cast<void*>(fail)) || fail;
284+
else
285+
fail= true;
282286

283287
/* The final part must not interfere with the use of the server datadir.
284288
Release the locks. */

storage/maria/ma_backup.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,10 @@ namespace
332332
#endif
333333
};
334334

335-
/* TODO: .frm failes are nto Aria-specific, they are copied here as a stop-gap */
336-
const std::vector<std::string> Aria_backup::data_exts {".MAD"s, ".MAI"s, ".frm"s};
335+
/* TODO: .frm failes are not Aria-specific, .MYD and .MYI are MyISAM files;
336+
they are copied here as a stop-gap */
337+
const std::vector<std::string>
338+
Aria_backup::data_exts {".MAD"s, ".MAI"s, "MYD"s, "MYI"s, "frm"s};
337339
const std::string Aria_backup::log_file_prefix {"aria_log."};
338340

339341
std::unique_ptr<Aria_backup> aria_backup;

0 commit comments

Comments
 (0)