Commit c9a82581 authored by unknown's avatar unknown

WL#3072 - Maria Recovery

Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)


mysql-test/r/maria.result:
  correct result
mysql-test/t/maria.test:
  now we get no error
storage/maria/ma_blockrec.c:
  delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
  ma_get_length() does not change **packet, marking it with 'const' to
  remove some casts in callers of this function. The
  (const uchar**)&header casts will be removed when Monty changes 'header'
  to const uchar*.
  _ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
  so its initialization was superfluous.
storage/maria/ma_check.c:
  Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
  (see comment in code)
storage/maria/ma_create.c:
  FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
  Logging done by _ma_ck_delete() is moved to a function
  (_ma_write_undo_key_delete()), for reusal by R-tree logging.
  _ma_log_delete() is made non-static for same
  reason, and some of its parameters are made pointers to const.
  Removed wrong comment ("Note that for delete key" etc, contradicted by
  code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
  unneeded cast, comment for future
storage/maria/ma_key_recover.c:
  Comment about possible deadlock.
  Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
  Support operation KEY_OP_MULTI_COPY.
  When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
  the proper key insertion|deletion depending on if this is R-tree
  or B-tree.
  Explanation of of _ma_[un]lock_key_del() work, maybe useful for
  mortals like me.
storage/maria/ma_key_recover.h:
  change of prototypes
storage/maria/ma_loghandler.h:
  New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
  Comments
storage/maria/ma_pagecache.c:
  typo
storage/maria/ma_rt_index.c:
  Fix for bug: the page_link pointer in maria_rtree_insert_req()
  could be wrong when we set its 'changed' member; for the solution
  see ma_key_recover.h. It is needed only in cases when we manipulate
  several pages.
  Logging of changes done to pages by key insert/delete.
  maria_rtree_delete()'s main work is moved to a new function
  maria_rtree_real_delete(), which is used by maria_rtree_delete()
  and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
  new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
  Logging of maria_rtree_add_key() and maria_rtree_delete_key().
  When inserting, split is necessary if there is not enough room for key:
  take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
  new prototypes (those functions need to know the page's id
  because they do logging)
storage/maria/ma_rt_mbr.c:
  Comments about what the functions change.
storage/maria/ma_rt_split.c:
  maria_rtree_split_page() needs to know the page's id, because
  it does logging.
  Logging of what a split operation does to the split page (see
  comment of _ma_log_rt_split(): moves of keys inside the page,
  sometimes insertion of the new key, and shrinking of the page)
  and to the new page (receives some keys from split page, and
  sometimes the new key).
storage/maria/ma_rt_test.c:
  ma_rt_test had been forgotten when maria_rkey() was changed some months ago
  (0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
  were rewritten to maria_scan() calls (which implies maria_scan_init()).
  The 'max_i' change is to adapt to the fact that maria_scan() does
  not return deleted records for BLOCK_RECORD but does so for other formats;
  the initial code assumed a certain number of deleted records would be
  returned, we change it to rather count only non-deleted ones.
  We also add more features to this test, like ma_test1 (the plan
  is to run ma_rt_test in ma_test_all-t):
  options to choose records' format, table checksum, transactions,
  checkpoints, end at specific stages, abort without committing,
  and debug trace.
storage/maria/ma_test1.c:
  MY_INIT() does my_init().
storage/maria/ma_write.c:
  Logging done by _ma_ck_write_btree_with_log() is moved to a function
  (_ma_write_undo_key_insert()), for reusal by R-tree logging.
  _ma_log_new() and _ma_log_change() are made non-static for same
  reason. Some parameters of logging functions are made pointers to const.
  If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
  (better checks, bigger record).
storage/maria/maria_read_log.c:
  Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
  rt_test had been forgotten when mi_rkey() was changed some months ago
  (0->HA_WHOLE_KEY change).
  The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
  correct result
mysql-test/r/maria-gis-rtree-trans.result:
  correct result
mysql-test/r/maria-recovery-rtree-ft.result:
  almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
  test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
  Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
  usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
  test of recovery of R-tree and fulltext indices.
parent 28131daa
This diff is collapsed.
This diff is collapsed.
set global maria_log_file_size=4294967295;
drop database if exists mysqltest;
create database mysqltest;
use mysqltest;
* shut down mysqld, removed logs, restarted it
use mysqltest;
CREATE TABLE t1 (
line LINESTRING NOT NULL,
kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po',
name VARCHAR(32)
,SPATIAL key (line)
) transactional=1 row_format=page engine=maria;
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 line 1 line A NULL 32 NULL SPATIAL
CREATE TABLE t2 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)
) transactional=1 row_format=page engine=maria;
SHOW INDEX FROM t2;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t2 1 a 1 a NULL NULL NULL NULL YES FULLTEXT
t2 1 a 2 b NULL NULL NULL NULL YES FULLTEXT
* TEST of REDO: see if recovery can reconstruct if we give it an old table
* copied t2 for feeding_recovery
* copied t1 for feeding_recovery
flush table t2;
* copied t2 for comparison
flush table t1;
* copied t1 for comparison
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* copied t2 back for feeding_recovery
* copied t1 back for feeding_recovery
* recovery happens
check table t2 extended;
Table Op Msg_type Msg_text
mysqltest.t2 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
* TEST of INSERT and DELETE's rollback
flush table t2;
* copied t2 for comparison
flush table t1;
* copied t1 for comparison
lock tables t1 write, t2 write;
SET SESSION debug="+d,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* recovery happens
check table t2 extended;
Table Op Msg_type Msg_text
mysqltest.t2 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
flush table t2;
* copied t2 for comparison
flush table t1;
* copied t1 for comparison
lock tables t1 write, t2 write;
SET SESSION debug="+d,maria_flush_whole_page_cache,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* recovery happens
check table t2 extended;
Table Op Msg_type Msg_text
mysqltest.t2 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
flush table t2;
* copied t2 for comparison
flush table t1;
* copied t1 for comparison
lock tables t1 write, t2 write;
SET SESSION debug="+d,maria_flush_states,maria_flush_whole_log,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* recovery happens
check table t2 extended;
Table Op Msg_type Msg_text
mysqltest.t2 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
flush table t2;
* copied t2 for comparison
flush table t1;
* copied t1 for comparison
lock tables t1 write, t2 write;
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* recovery happens
check table t2 extended;
Table Op Msg_type Msg_text
mysqltest.t2 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
flush table t2;
* copied t2 for comparison
flush table t1;
* copied t1 for comparison
lock tables t1 write, t2 write;
select count(*) from t1;
count(*)
1080
delete from t1;
select count(*) from t1;
count(*)
782
select count(*) from t2;
count(*)
720
delete from t2;
select count(*) from t2;
count(*)
0
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
ERROR HY000: Lost connection to MySQL server during query
* recovery happens
check table t2 extended;
Table Op Msg_type Msg_text
mysqltest.t2 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
drop table t1,t2;
...@@ -2195,13 +2195,6 @@ t1 CREATE TABLE `t1` ( ...@@ -2195,13 +2195,6 @@ t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL `a` int(11) DEFAULT NULL
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
drop table t1; drop table t1;
create table t1 (s varchar(25), fulltext(s)) TRANSACTIONAL= 1;
ERROR HY000: Maria can't yet handle SPATIAL or FULLTEXT keys in transactional mode. For now use TRANSACTIONAL=0
drop table if exists t1;
create table t1 ( fid int not null auto_increment primary key,
g geometry not null, spatial key(g));
ERROR HY000: Maria can't yet handle SPATIAL or FULLTEXT keys in transactional mode. For now use TRANSACTIONAL=0
drop table if exists t1;
set global maria_log_file_size=4294967296; set global maria_log_file_size=4294967296;
Warnings: Warnings:
Warning 1292 Truncated incorrect log_file_size value: '4294967296' Warning 1292 Truncated incorrect log_file_size value: '4294967296'
......
This diff is collapsed.
This diff is collapsed.
--skip-stack-trace --skip-core-file
This diff is collapsed.
...@@ -1410,18 +1410,6 @@ create table t1 (a int); ...@@ -1410,18 +1410,6 @@ create table t1 (a int);
show create table t1; show create table t1;
drop table t1; drop table t1;
#
# Show that we can't yet create fulltext or spatial index with Maria
#
--error 138
create table t1 (s varchar(25), fulltext(s)) TRANSACTIONAL= 1;
drop table if exists t1;
--error 138
create table t1 ( fid int not null auto_increment primary key,
g geometry not null, spatial key(g));
drop table if exists t1;
# #
# Test warning on log file size truncates # Test warning on log file size truncates
# #
......
This diff is collapsed.
...@@ -4442,7 +4442,16 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param) ...@@ -4442,7 +4442,16 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
for (;;) for (;;)
{ {
int flag; int flag;
/*
Assume table is transactional and it had LSN pages in the
cache. Repair has flushed them, left data pages stay in
cache, and disabled transactionality (so share's current page
type is PLAIN); page cache would assert if it finds a cached LSN page
while _ma_scan_block_record() requested a PLAIN page. So we use
UNKNOWN.
*/
enum pagecache_page_type save_page_type= share->page_type;
share->page_type= PAGECACHE_READ_UNKNOWN_PAGE;
if (info != sort_info->new_info) if (info != sort_info->new_info)
{ {
/* Safe scanning */ /* Safe scanning */
...@@ -4459,6 +4468,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param) ...@@ -4459,6 +4468,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
flag= _ma_scan_block_record(info, sort_param->record, flag= _ma_scan_block_record(info, sort_param->record,
info->cur_row.nextpos, 1); info->cur_row.nextpos, 1);
} }
share->page_type= save_page_type;
if (!flag) if (!flag)
{ {
if (sort_param->calc_checksum) if (sort_param->calc_checksum)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment