1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

MDEV-35223 REPAIR does not fix MyISAM table with vector key after crash recovery

resort to alter for repair too
This commit is contained in:
Sergei Golubchik
2024-10-23 20:08:57 +02:00
parent e8cff8e829
commit 7d081c1b83
4 changed files with 52 additions and 1 deletions

View File

@@ -90,3 +90,26 @@ connection con1;
disconnect con1; disconnect con1;
connection default; connection default;
drop table t1; drop table t1;
#
# MDEV-35223 REPAIR does not fix MyISAM table with vector key after crash recovery
#
call mtr.add_suppression('t#i#00'' is marked as crashed and should be repaired');
create table t (v vector(1) not null, vector(v)) engine=myisam;
insert into t (v) values (0x30303030),(0x31313131);
# restart
check table t extended;
Table Op Msg_type Msg_text
test.t check warning 1 client is using or hasn't closed the table properly
test.t check Error Table './test/t#i#00' is marked as crashed and should be repaired
test.t check status Operation failed
repair table t extended;
Table Op Msg_type Msg_text
test.t repair note Table does not support optimize, doing recreate + analyze instead
test.t repair status OK
check table t extended;
Table Op Msg_type Msg_text
test.t check status OK
select v from t order by vec_distance_euclidean(0x323233232,v) limit 1;
v
0000
drop table t;

View File

@@ -56,3 +56,17 @@ xa prepare 'x';
--disconnect con1 --disconnect con1
--connection default --connection default
drop table t1; drop table t1;
--echo #
--echo # MDEV-35223 REPAIR does not fix MyISAM table with vector key after crash recovery
--echo #
call mtr.add_suppression('t#i#00'' is marked as crashed and should be repaired');
create table t (v vector(1) not null, vector(v)) engine=myisam;
insert into t (v) values (0x30303030),(0x31313131);
--let $shutdown_timeout=0
--source include/restart_mysqld.inc
check table t extended;
repair table t extended;
check table t extended;
select v from t order by vec_distance_euclidean(0x323233232,v) limit 1;
drop table t;

View File

@@ -5366,6 +5366,14 @@ int handler::ha_check(THD *thd, HA_CHECK_OPT *check_opt)
} }
if (unlikely((error= check(thd, check_opt)))) if (unlikely((error= check(thd, check_opt))))
return error; return error;
for (uint i= table->s->keys; i < table->s->total_keys; i++)
{
DBUG_ASSERT(table->s->hlindexes() == 1);
if (table->hlindex_open(i))
return HA_ADMIN_FAILED;
if ((error= table->hlindex->file->check(thd, check_opt)))
return error;
}
/* Skip updating frm version if not main handler. */ /* Skip updating frm version if not main handler. */
if (table->file != this || opt_readonly) if (table->file != this || opt_readonly)
return error; return error;
@@ -5424,7 +5432,7 @@ int handler::ha_repair(THD* thd, HA_CHECK_OPT* check_opt)
if (result == HA_ADMIN_OK && !opt_readonly && if (result == HA_ADMIN_OK && !opt_readonly &&
table->file->ha_check_for_upgrade(check_opt) == HA_ADMIN_OK) table->file->ha_check_for_upgrade(check_opt) == HA_ADMIN_OK)
result= update_frm_version(table); result= update_frm_version(table);
return result; return table->s->hlindexes() ? HA_ADMIN_TRY_ALTER : result;
} }

View File

@@ -1287,12 +1287,18 @@ int mhnsw_read_first(TABLE *table, KEY *keyinfo, Item *dist, ulonglong limit)
{ {
if (int err= search_layer(ctx, graph, target, NEAREST, if (int err= search_layer(ctx, graph, target, NEAREST,
1, cur_layer, &candidates, false)) 1, cur_layer, &candidates, false))
{
graph->file->ha_rnd_end();
return err; return err;
}
} }
if (int err= search_layer(ctx, graph, target, NEAREST, if (int err= search_layer(ctx, graph, target, NEAREST,
static_cast<uint>(limit), 0, &candidates, false)) static_cast<uint>(limit), 0, &candidates, false))
{
graph->file->ha_rnd_end();
return err; return err;
}
auto result= new (thd->mem_root) Search_context(&candidates, ctx, target); auto result= new (thd->mem_root) Search_context(&candidates, ctx, target);
graph->context= result; graph->context= result;