diff options
-rw-r--r-- | mysql-test/suite/maria/maria-recovery.result | 38 | ||||
-rw-r--r-- | mysql-test/suite/maria/maria-recovery.test | 30 | ||||
-rw-r--r-- | storage/maria/ma_recovery.c | 13 |
3 files changed, 81 insertions, 0 deletions
diff --git a/mysql-test/suite/maria/maria-recovery.result b/mysql-test/suite/maria/maria-recovery.result index 6c9af3eac88..915dc53b460 100644 --- a/mysql-test/suite/maria/maria-recovery.result +++ b/mysql-test/suite/maria/maria-recovery.result @@ -292,6 +292,44 @@ t1 CREATE TABLE `t1` ( ) ENGINE=Aria AUTO_INCREMENT=17 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 insert into t1 values(null, "f"); drop table t1; +Test that bulk insert works with recovery +CREATE TABLE t1 (i int, key(i)) TRANSACTIONAL=1 ENGINE=ARIA; +CREATE TABLE t2 (i int, key(i)) TRANSACTIONAL=1 ENGINE=ARIA; +connection admin; +* copied t2 for feeding_recovery +* copied t1 for feeding_recovery +connection default; +insert into t2 values +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (3), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(0), (1), (2), (3), (4), (5), (6), (7), (8), (9); +insert into t1 select * from t2; +insert into t2 select * from t2; +connection admin; +SET SESSION debug_dbug="+d,maria_flush_whole_log,maria_crash"; +* crashing mysqld intentionally +set global aria_checkpoint_interval=1; +ERROR HY000: Lost connection to MySQL server during query +* recovery happens +connection default; +use mysqltest; +select count(*) from t1; +count(*) +100 +select count(*) from t2; +count(*) +200 +check table t2; +Table Op Msg_type Msg_text +mysqltest.t2 check status OK +drop table t1,t2; drop database mysqltest_for_feeding_recovery; drop database mysqltest_for_comparison; drop database mysqltest; diff --git a/mysql-test/suite/maria/maria-recovery.test b/mysql-test/suite/maria/maria-recovery.test index b0f01f37d0d..a1671a56d53 100644 --- a/mysql-test/suite/maria/maria-recovery.test +++ b/mysql-test/suite/maria/maria-recovery.test @@ -195,6 +195,36 @@ show create table t1; insert into t1 values(null, "f"); drop table t1; +--echo Test that bulk insert works with recovery +let $mms_tables=2; + +CREATE TABLE t1 (i int, key(i)) TRANSACTIONAL=1 ENGINE=ARIA; +CREATE TABLE t2 (i int, key(i)) TRANSACTIONAL=1 ENGINE=ARIA; +-- source include/maria_make_snapshot_for_feeding_recovery.inc +insert into t2 values + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (3), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), + (0), (1), (2), (3), (4), (5), (6), (7), (8), (9); +insert into t1 select * from t2; +insert into t2 select * from t2; +let $mvr_restore_old_snapshot=0; +let $mms_compare_physically=0; +let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash"; +let $mvr_crash_statement= set global aria_checkpoint_interval=1; +let $mms_tables=0; +-- source include/maria_verify_recovery.inc +select count(*) from t1; +select count(*) from t2; +check table t2; +drop table t1,t2; + # clean up everything let $mms_purpose=feeding_recovery; eval drop database mysqltest_for_$mms_purpose; diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index 6b1911bf903..dc1a974fd7d 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -1403,6 +1403,11 @@ static int new_table(uint16 sid, const char *name, LSN lsn_of_file_id) } if (cmp_translog_addr(lsn_of_file_id, share->state.create_rename_lsn) <= 0) { + /* + This can happen if the table was dropped and re-created since this + redo entry or if the table had a bulk insert directly after create, + in which case the create_rename_lsn changed. + */ tprint(tracef, ", has create_rename_lsn " LSN_FMT " more recent than" " LOGREC_FILE_ID's LSN " LSN_FMT ", ignoring open request", LSN_IN_PARTS(share->state.create_rename_lsn), @@ -3616,8 +3621,16 @@ my_bool _ma_reenable_logging_for_table(MARIA_HA *info, my_bool flush_pages) { /* Ensure that recover is not executing any redo before this */ if (!maria_in_recovery) + { + if (share->id != 0) + { + mysql_mutex_lock(&share->intern_lock); + translog_deassign_id_from_share(share); + mysql_mutex_unlock(&share->intern_lock); + } share->state.is_of_horizon= share->state.create_rename_lsn= share->state.skip_redo_lsn= translog_get_horizon(); + } /* We are going to change callbacks; if a page is flushed at this moment this can cause race conditions, that's one reason to flush pages |