Skip to content

Commit 01a069c

Browse files
Close tables using tc_purge to fix the "table marked as crashed" warning
1 parent a1ac914 commit 01a069c

3 files changed

Lines changed: 13 additions & 23 deletions

File tree

mysql-test/main/backup_server_restore.result

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ i
2121
2
2222
3
2323
5
24-
Warnings:
25-
Error 145 Got error '145 "Table was marked as crashed and should be repaired"' for './test/tariant'
26-
Warning 1034 1 client is using or hasn't closed the table properly
27-
Note 1034 Table is fixed
2824
Restart database in original data directory
2925
# restart
3026
Clean up

sql/sql_backup.cc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,18 @@ bool Sql_cmd_backup::execute(THD *thd)
403403
if (!fail)
404404
{
405405
fail= run_backup_proc_phase(thd, BACKUP_PROC_PHASE_BACKUP_LOCKED) ||
406-
upgrade_and_process(thd, mdl_request, MDL_BACKUP_WAIT_DDL,
407-
BACKUP_PROC_PHASE_DDL_LOCKED) ||
406+
thd->mdl_context.upgrade_shared_lock(mdl_request.ticket,
407+
MDL_BACKUP_WAIT_DDL,
408+
thd->variables.lock_wait_timeout);
409+
}
410+
411+
if (!fail)
412+
{
413+
/* Note: this will need to be done on MDL_BACKUP_WAIT_FLUSH when we introduce
414+
that phase */
415+
tc_purge();
416+
tdc_purge(true);
417+
fail= run_backup_proc_phase(thd, BACKUP_PROC_PHASE_DDL_LOCKED) ||
408418
upgrade_and_process(thd, mdl_request, MDL_BACKUP_WAIT_COMMIT,
409419
BACKUP_PROC_PHASE_COMMIT_LOCKED);
410420
}

storage/maria/ma_backup.cc

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -468,23 +468,7 @@ namespace
468468
data_path= index_path;
469469
index_path+= index_ext;
470470
data_path+= data_ext;
471-
return flush_table_if_needed(index_path) ||
472-
copy_file(index_path) || copy_file(data_path);
473-
}
474-
475-
/* index_path is relative to datadir */
476-
int flush_table_if_needed(const std::string& index_path)
477-
{
478-
/* Internally Aria identifies tables by fully resolved abolsute paths.
479-
We need such path for the index file to be able to determine if the table
480-
is open.*/
481-
char canonical_path[FN_REFLEN];
482-
fn_format(canonical_path, index_path.c_str(), "", "", MY_RETURN_REAL_PATH);
483-
MARIA_HA *info= _ma_test_if_reopen(canonical_path);
484-
if (!info)
485-
return 0; /* Table not open, nothing to be done */
486-
return _ma_flush_table_files(info, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX,
487-
FLUSH_KEEP, FLUSH_KEEP);
471+
return copy_file(index_path) || copy_file(data_path);
488472
}
489473

490474
int copy_control_file() noexcept

0 commit comments

Comments
 (0)