Browse Source

MDEV-34055 Assertion '...' failure or corruption errors upon REPAIR on Aria tables

The problem was two fold:
- REPAIR TABLE t1 USE_FRM did not work for transactional
  Aria tables (Table was thought to be repaired, which it was not) which
  caused issues in later usage of the table.
- When swapping tmp_data file to data file, sort_info files where not
  updated. This caused problems if there was several unique keys and
  there was a duplicate for the second key.
bb-mdev-10.5-mdev-32180
Monty 2 years ago
parent
commit
ec6aa9ac42
  1. 23
      mysql-test/suite/maria/repair.result
  2. 19
      mysql-test/suite/maria/repair.test
  3. 12
      storage/maria/ma_check.c

23
mysql-test/suite/maria/repair.result

@ -62,3 +62,26 @@ SET SESSION aria_sort_buffer_size=default;
#
# End of 10.3 tests
#
#
# MDEV-34055 Assertion `readbytes != (size_t)-1 ||
# (*__errno_location ()) != 9' failure or corruption errors upon
# REPAIR on Aria tables
#
CREATE OR REPLACE TABLE t1 (a INT, b INT, UNIQUE(b), UNIQUE(a)) ENGINE=Aria;
INSERT INTO t1 VALUES (1,2);
REPAIR TABLE t1 EXTENDED QUICK USE_FRM;
Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 1
test.t1 repair status OK
CREATE TABLE t2 (c INT) ENGINE=Aria;
SELECT * FROM t2;
c
REPLACE INTO t1 VALUES (1,3);
REPAIR TABLE t2, t1 QUICK;
Table Op Msg_type Msg_text
test.t2 repair status OK
test.t1 repair status OK
DROP TABLE t1, t2;
#
# End of 10.5 tests
#

19
mysql-test/suite/maria/repair.test

@ -74,3 +74,22 @@ SET SESSION aria_sort_buffer_size=default;
--echo #
--echo # End of 10.3 tests
--echo #
--echo #
--echo # MDEV-34055 Assertion `readbytes != (size_t)-1 ||
--echo # (*__errno_location ()) != 9' failure or corruption errors upon
--echo # REPAIR on Aria tables
--echo #
CREATE OR REPLACE TABLE t1 (a INT, b INT, UNIQUE(b), UNIQUE(a)) ENGINE=Aria;
INSERT INTO t1 VALUES (1,2);
REPAIR TABLE t1 EXTENDED QUICK USE_FRM;
CREATE TABLE t2 (c INT) ENGINE=Aria;
SELECT * FROM t2;
REPLACE INTO t1 VALUES (1,3);
REPAIR TABLE t2, t1 QUICK;
DROP TABLE t1, t2;
--echo #
--echo # End of 10.5 tests
--echo #

12
storage/maria/ma_check.c

@ -2505,6 +2505,11 @@ static int initialize_variables_for_repair(HA_CHECK *param,
maria_versioning(info, 0);
/* remember original number of rows */
*info->state= info->s->state.state;
if (share->data_file_type == BLOCK_RECORD)
share->state.state.data_file_length= MY_ALIGN(sort_info->filelength,
share->block_size);
else
share->state.state.data_file_length= sort_info->filelength;
return 0;
}
@ -2741,7 +2746,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
READ_CACHE, share->pack.header_length, 1, MYF(MY_WME)))
goto err;
}
if (sort_info.new_info->s->data_file_type != BLOCK_RECORD)
if (!block_record)
{
/* When writing to not block records, we need a write buffer */
if (!rep_quick)
@ -2754,7 +2759,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
sort_info.new_info->opt_flag|=WRITE_CACHE_USED;
}
}
else if (block_record)
else
{
scan_inited= 1;
if (maria_scan_init(sort_info.info))
@ -4102,6 +4107,9 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
_ma_check_print_error(param, "Couldn't change to new data file");
goto err;
}
/* Inform sort_delete_record that we are using the new file */
sort_info.new_info->dfile.file= info->rec_cache.file= info->dfile.file;
if (param->testflag & T_UNPACK)
restore_data_file_type(share);

Loading…
Cancel
Save