Details
-
Bug
-
Status: In Review (View Workflow)
-
Major
-
Resolution: Unresolved
-
N/A
-
None
Description
Since the vector index is a separate .ibd file, not surprisingly DISCARD / IMPORT TABLESPACE on a table with such index doesn't work "out of the box". That is, it still handles the main tablespace, but does nothing to the vector one – DISCARD doesn't remove it, IMPORT ignores it. While doing so it doesn't produce any errors or warnings.
I think it can lead to human errors and to unexpected results later:
--source include/have_innodb.inc
|
|
--let $datadir= `select @@datadir`
|
|
create table t (a int, v blob not null, vector(v)) engine=InnoDB; |
insert into t values (1,x'00000000'),(1,x'00000000'); |
select a, vec_totext(v) from t; |
select a, vec_totext(v) from t order by vec_distance_euclidean(v,x'00000000') limit 1; |
|
flush table t for export; |
--list_files $datadir/test/
|
--copy_file $datadir/test/t.ibd $datadir/test/t.ibd.save
|
--copy_file $datadir/test/t#i#00.ibd $datadir/test/t#i#00.ibd.save
|
--copy_file $datadir/test/t.cfg $datadir/test/t.cfg.save
|
unlock tables;
|
create or replace table t (a int, v blob not null, vector(v)) engine=InnoDB; |
alter table t discard tablespace; |
--list_files $datadir/test/
|
--remove_file $datadir/test/t#i#00.ibd
|
--move_file $datadir/test/t#i#00.ibd.save $datadir/test/t#i#00.ibd
|
--move_file $datadir/test/t.ibd.save $datadir/test/t.ibd
|
--move_file $datadir/test/t.cfg.save $datadir/test/t.cfg
|
alter table t import tablespace; |
flush tables;
|
select a, vec_totext(v) from t; |
select a, vec_totext(v) from t order by vec_distance_euclidean(v,x'00000000') limit 1; |
|
--source include/restart_mysqld.inc
|
|
select a, vec_totext(v) from t; |
select a, vec_totext(v) from t order by vec_distance_euclidean(v,x'00000000') limit 1; |
|
# Cleanup
|
drop table t; |
In the above, everything up to the server restart "works", import succeeds, the table contents exists, the key seems to exist, only it is empty. FLUSH TABLES doesn't help either:
flush tables;
|
select a, vec_totext(v) from t; |
a vec_totext(v)
|
1 [0.000000]
|
1 [0.000000]
|
select a, vec_totext(v) from t order by vec_distance_euclidean(v,x'00000000') limit 1; |
a vec_totext(v)
|
# restart
|
Only after server restart InnoDB notices that something is wrong:
# restart
|
select a, vec_totext(v) from t; |
a vec_totext(v)
|
1 [0.000000]
|
1 [0.000000]
|
select a, vec_totext(v) from t order by vec_distance_euclidean(v,x'00000000') limit 1; |
bug.t [ fail ]
|
Test ended at 2024-10-03 12:27:38 |
|
CURRENT_TEST: bug.t
|
mysqltest: At line 31: query 'select a, vec_totext(v) from t order by vec_distance_euclidean(v,x'00000000') limit 1' failed: ER_TABLE_CORRUPT (1877): Table `test`.`t#i#00` is corrupted. Please drop the table and recreate. |
bb-11.6-MDEV-32887-vector 77be73c489fb7c21ca58e78cef10e0c166f293d8 |
2024-10-03 12:27:38 0 [ERROR] InnoDB: Expected tablespace id 11 but found 0 in the file ./test/t#i#00.ibd
|
2024-10-03 12:27:38 0 [Note] InnoDB: Buffer pool(s) load completed at 241003 12:27:38
|
...
|
2024-10-03 12:27:38 3 [ERROR] InnoDB: Expected tablespace id 11 but found 0 in the file ./test/t#i#00.ibd
|
2024-10-03 12:27:38 3 [ERROR] mariadbd: Table `test`.`t#i#00` is corrupted. Please drop the table and recreate.
|
2024-10-03 12:27:38 3 [ERROR] Got error 126 when reading table './test/t'
|
2024-10-03 12:27:38 3 [ERROR] mariadbd: Index for table 't' is corrupt; try to repair it
|
As a short-term solution, I suppose DISCARD and IMPORT on tables with vector keys should be forbidden. However, for vector-containing tables specifically, given that their creation/population is so expensive, the ability to move tablespaces could be attractive.
Attachments
Issue Links
- is caused by
-
MDEV-34939 vector search in 11.7
- Closed