Repository navigation
Description
Description
An index created with ASYNC becomes available to the optimizer before its background build has populated the index data. During this interval, queries successfully return an empty result instead of using the base table or reporting that the index is not ready.
The same behavior is reproducible with FULLTEXT, IVF_FLAT, and HNSW indexes.
Environment
- Branch:
main - Commit:
50319026a69e45c3c190cb7a09e9c5fbdb7f6857 git_version():50319026a- Deployment: local single-node MatrixOne
Reproduction
FULLTEXT
SET experimental_fulltext_index = 1;
CREATE TABLE docs(id BIGINT PRIMARY KEY, body TEXT);
INSERT INTO docs
SELECT result,
IF(MOD(result, 10) = 0, 'database search text', 'ordinary text')
FROM generate_series(1, 100000) g;
CREATE FULLTEXT INDEX ft ON docs(body) WITH PARSER ngram ASYNC;
SELECT COUNT(*)
FROM docs
WHERE MATCH(body) AGAINST('+database' IN BOOLEAN MODE);IVF_FLAT
SET experimental_ivf_index = 1;
CREATE TABLE ivf(id BIGINT PRIMARY KEY, e VECF32(3));
INSERT INTO ivf
SELECT result,
CONCAT('[', MOD(result,101), ',', MOD(result,37), ',', MOD(result,17), ']')
FROM generate_series(1, 10000) g;
CREATE INDEX ivf_idx USING ivfflat ON ivf(e)
OP_TYPE 'vector_l2_ops' LISTS = 20 ASYNC;
SELECT id
FROM ivf
ORDER BY l2_distance(e, '[1,1,1]')
LIMIT 10;HNSW
SET experimental_hnsw_index = 1;
CREATE TABLE hnsw(id BIGINT PRIMARY KEY, e VECF32(3));
INSERT INTO hnsw
SELECT result,
CONCAT('[', MOD(result,97), ',', MOD(result,31), ',', MOD(result,13), ']')
FROM generate_series(1, 10000) g;
CREATE INDEX hnsw_idx USING hnsw ON hnsw(e)
OP_TYPE 'vector_l2_ops' ASYNC;
SELECT id
FROM hnsw
ORDER BY l2_distance(e, '[1,1,1]')
LIMIT 10;Actual result
Immediately after each CREATE ... ASYNC returns:
- FULLTEXT returns count
0instead of10000. - IVF_FLAT returns zero rows instead of 10 rows.
- HNSW returns zero rows instead of 10 rows.
- No error is returned.
The test was repeated with three newly created databases. All three rounds reproduced the same result:
ROUND=1 fulltext_immediate=0 ready_after=10.259s ivf_immediate=0 ready_after=18.695s hnsw_immediate=0 ready_after=10.011s
ROUND=2 fulltext_immediate=0 ready_after=10.658s ivf_immediate=0 ready_after=19.212s hnsw_immediate=0 ready_after=9.896s
ROUND=3 fulltext_immediate=0 ready_after=10.869s ivf_immediate=0 ready_after=18.910s hnsw_immediate=0 ready_after=10.017s
After the background build finishes, the same SQL returns the expected rows without any schema change.
Prepared statements and literal SQL show the same behavior, so this is not limited to prepared-plan reuse.
Expected result
Queries must not silently use an incomplete index. Until the asynchronous build is ready, MatrixOne should either:
- use a correctness-preserving base-table path, or
- return an explicit index-not-ready status.
The index should become eligible for query planning only after its initial build is complete.
Additional observations
CREATE ... ASYNCitself returns quickly as expected.- Existing distributed tests wait for the background build before querying; they do not cover queries issued immediately after DDL returns.
- The FULLTEXT, IVF_FLAT, and HNSW build implementations differ, but the externally visible state transition is the same: the catalog definition is visible before the populated index is ready for reads.
Activity
cpegeric commentedon Aug 11, 2026
async don't promise immediate result. Nothing to fix here.