Skip to content

Commit a649904

Browse files
committed
MDEV-35033 LeakSanitizer errors in my_malloc / safe_mutex_lazy_init_deadlock_detection / MHNSW_Context::alloc_node and alike
ctx wasn't released on errors
1 parent 6837bb5 commit a649904

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

mysql-test/main/vector2.result

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,17 @@ Table Op Msg_type Msg_text
1010
test.t analyze status Engine-independent statistics collected
1111
test.t analyze status Table is already up to date
1212
drop table t;
13+
#
14+
# MDEV-35033 LeakSanitizer errors in my_malloc / safe_mutex_lazy_init_deadlock_detection / MHNSW_Context::alloc_node and alike
15+
#
16+
call mtr.add_suppression('mariadbd: Can''t find record in ''t''');
17+
create table t (a int, v blob not null, vector index (v));
18+
insert into t values (1,vec_fromtext('[0]'));
19+
update t set v = vec_fromtext('[0,0]');
20+
ERROR 22007: Incorrect vector value: '...' for column `test`.`t`.`v` at row 1
21+
update t set a = 2;
22+
ERROR HY000: Can't find record in 't'
23+
set global mhnsw_cache_size = 1048576;
24+
insert into t values (2,x'00000000');
25+
drop table t;
26+
set global mhnsw_cache_size = default;

mysql-test/main/vector2.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,22 @@ create table t1(v blob not null, vector index(v)) engine=aria;
1212
create table t (a int, v blob not null, vector index (v));
1313
analyze table t persistent for columns() indexes (v);
1414
drop table t;
15+
16+
--echo #
17+
--echo # MDEV-35033 LeakSanitizer errors in my_malloc / safe_mutex_lazy_init_deadlock_detection / MHNSW_Context::alloc_node and alike
18+
--echo #
19+
call mtr.add_suppression('mariadbd: Can''t find record in ''t''');
20+
create table t (a int, v blob not null, vector index (v));
21+
insert into t values (1,vec_fromtext('[0]'));
22+
23+
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
24+
update t set v = vec_fromtext('[0,0]');
25+
26+
--error ER_KEY_NOT_FOUND
27+
update t set a = 2;
28+
29+
set global mhnsw_cache_size = 1048576;
30+
insert into t values (2,x'00000000');
31+
32+
drop table t;
33+
set global mhnsw_cache_size = default;

sql/vector_mhnsw.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,7 @@ int mhnsw_invalidate(TABLE *table, const uchar *rec, KEY *keyinfo)
13031303
handler *h= table->file;
13041304
MHNSW_Context *ctx;
13051305
bool use_ctx= !MHNSW_Context::acquire(&ctx, table, true);
1306+
SCOPE_EXIT([ctx, table](){ ctx->release(table); });
13061307

13071308
/* metadata are checked on open */
13081309
DBUG_ASSERT(graph);
@@ -1333,7 +1334,6 @@ int mhnsw_invalidate(TABLE *table, const uchar *rec, KEY *keyinfo)
13331334
graph->file->position(graph->record[0]);
13341335
FVectorNode *node= ctx->get_node(graph->file->ref);
13351336
node->deleted= true;
1336-
ctx->release(table);
13371337
}
13381338

13391339
return 0;

0 commit comments

Comments
 (0)