[MDEV-23398] OPTIMIZE causes strange errors and further data corruption with myisam_repair_threads and too small sort buffer Created: 2020-08-04  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Storage Engine - MyISAM
Affects Version/s: 10.1, 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-23363 Crashes and corruption in get_field_d... Closed

 Description   

-- source include/have_sequence.inc
 
CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY, a TEXT, b TEXT, KEY(id,a(64),b(64))) ENGINE=MyISAM;
INSERT INTO t1 (a) SELECT REPEAT('e',65173) FROM seq_1_to_50;
UPDATE t1 SET a = 'x';
SET SESSION myisam_repair_threads= 6, myisam_sort_buffer_size= 131072;
OPTIMIZE TABLE t1;
INSERT INTO t1 (a) VALUES (NULL);
 
# Cleanup
DROP TABLE t1;

10.2 dc716da4

OPTIMIZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	optimize	error	myisam_sort_buffer_size is too small. Current myisam_sort_buffer_size: 65536  rows: 162961  sort_length: 144
test.t1	optimize	error	Found key at page -1 that points to record outside datafile
test.t1	optimize	status	Operation failed
INSERT INTO t1 (a) VALUES (NULL);
bug.corrupt1                             [ fail ]
        Test ended at 2020-08-04 15:35:47
 
CURRENT_TEST: bug.corrupt1
mysqltest: At line 8: query 'INSERT INTO t1 (a) VALUES (NULL)' failed: 144: Table './test/t1' is marked as crashed and last (automatic?) repair failed

Everything in OPTIMIZE output is strange: current myisam_sort_buffer_size is wrong, the number of rows has nothing to do with the table, and page -1 is obviously a problem. The warning in the error log isn't good either:

2020-08-04 15:35:46 140051098892032 [Warning] Warning: Optimize table got errno 0 on test.t1, retrying

And further the table is marked as crashed.

Reproducible on 10.1-10.5.


Generated at Thu Feb 08 09:22:06 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.