MDEV-35319 ER_LOCK_DEADLOCK not detected upon DML on table with vector key, server crashes

cannot ignore the error in MHNSW_Share::acquire() - it could be a deadlock
signal, after which no further operations are allowed
This commit is contained in:
Sergei Golubchik 2024-11-04 04:25:31 -08:00
parent 574e18f80d
commit ebbbe9d960
3 changed files with 49 additions and 7 deletions

View File

@ -210,3 +210,20 @@ v
commit;
drop table t;
set global mhnsw_max_cache_size= default;
#
# MDEV-35319 ER_LOCK_DEADLOCK not detected upon DML on table with vector key, server crashes
#
create table t (pk int, b vector(1) not null, vector(b), primary key (pk)) engine=innodb;
insert into t values (1,0x31313131),(2,0x32323232);
start transaction;
insert into t values (3,0x33333333);
connect con1,localhost,root;
DELETE from t;
connection default;
set innodb_lock_wait_timeout= 1;
delete from t;
rollback;
connection con1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
drop table t;
disconnect con1;

View File

@ -206,3 +206,28 @@ commit;
--enable_view_protocol
drop table t;
set global mhnsw_max_cache_size= default;
--echo #
--echo # MDEV-35319 ER_LOCK_DEADLOCK not detected upon DML on table with vector key, server crashes
--echo #
create table t (pk int, b vector(1) not null, vector(b), primary key (pk)) engine=innodb;
insert into t values (1,0x31313131),(2,0x32323232);
start transaction;
insert into t values (3,0x33333333);
--connect con1,localhost,root
--send DELETE from t
--connection default
--let $show_statement= show processlist
--let $field= State
--let $condition= = 'Updating'
--source include/wait_show_condition.inc
set innodb_lock_wait_timeout= 1;
delete from t;
rollback;
--connection con1
--error ER_LOCK_DEADLOCK
--reap
drop table t;
--disconnect con1

View File

@ -1386,8 +1386,11 @@ int mhnsw_invalidate(TABLE *table, const uchar *rec, KEY *keyinfo)
TABLE *graph= table->hlindex;
handler *h= table->file;
MHNSW_Share *ctx;
bool use_ctx= !MHNSW_Share::acquire(&ctx, table, true);
int err= MHNSW_Share::acquire(&ctx, table, true);
SCOPE_EXIT([ctx, table](){ ctx->release(table); });
if (err)
return err;
/* metadata are checked on open */
DBUG_ASSERT(graph);
@ -1413,12 +1416,9 @@ int mhnsw_invalidate(TABLE *table, const uchar *rec, KEY *keyinfo)
if (int err= graph->file->ha_update_row(graph->record[1], graph->record[0]))
return err;
if (use_ctx)
{
graph->file->position(graph->record[0]);
FVectorNode *node= ctx->get_node(graph->file->ref);
node->deleted= true;
}
graph->file->position(graph->record[0]);
FVectorNode *node= ctx->get_node(graph->file->ref);
node->deleted= true;
return 0;
}