Repository navigation
Description
Summary
After REBUILD INDEX on an LSM_SPARSE_VECTOR index, a rename of its type and a TRUNCATE TYPE, the index is re-created under the OLD type name: D[tk,wt] on a type now called Dren, flagged as a manual name, so it is persisted that way and survives a reopen. The consequences are visible: vectorSparseNeighbors('D[tk,wt]', ...) answers SchemaException: Type with name 'D' was not found for the name the catalog prints, and creating a new type D with the same sparse index is refused with AlreadyExistsException: Index 'D[tk,wt]' already exists.
Cause: REBUILD INDEX hands the TypeIndex name back as typeIndexName in the bucket-level index metadata (RebuildIndexStatement.java:568, :578). LocalDocumentType.addIndexInternal (LocalDocumentType.java:2822) knows that "a REBUILD hands the derived name back as the custom one, and it is no manual name: a rename of the type has to move it" and compares the custom name with the name derived from the CURRENT type name to tell a manual name apart. The rename moves the TypeIndex (TypeIndex.updateTypeName, TypeIndex.java:832) but leaves typeIndexName in the sub-index metadata at the old derived name. When TRUNCATE TYPE re-creates the sparse index from that metadata, the stale name no longer equals the derived one (Dren[tk,wt]), so it is taken for a manual name and the TypeIndex is minted under it (new TypeIndex(manualName ? customName : derivedName, this, manualName)), and from then on hasManualName() makes it persist (LocalDocumentType.java:3422).
How it is reached
Plain SQL, any protocol: REBUILD INDEX (or REBUILD INDEX *) at some point in the life of the index, ALTER TYPE x NAME y, then TRUNCATE TYPE y. Found by a model-based fuzz of index kinds (FULL_TEXT, GEOSPATIAL, LSM_VECTOR, LSM_SPARSE_VECTOR) with random create/drop/rebuild/rename/truncate/reopen.
Reproduce
origin/main dc07b20.
CREATE DOCUMENT TYPE D
CREATE PROPERTY D.id INTEGER
CREATE PROPERTY D.tk ARRAY_OF_INTEGERS
CREATE PROPERTY D.wt ARRAY_OF_FLOATS
CREATE INDEX ON D (tk, wt) LSM_SPARSE_VECTOR METADATA { dimensions: 8 }
INSERT INTO D SET id = 1, tk = [1,2], wt = [1.0, 2.0] -- in a transaction
REBUILD INDEX *
ALTER TYPE D NAME Dren
TRUNCATE TYPE Dren
SELECT name, typeName FROM schema:indexes
-- {"name":"D[tk,wt]","typeName":"Dren"} expected "Dren[tk,wt]"
-- the same after a reopen
CREATE DOCUMENT TYPE D
CREATE PROPERTY D.tk ARRAY_OF_INTEGERS
CREATE PROPERTY D.wt ARRAY_OF_FLOATS
CREATE INDEX ON D (tk, wt) LSM_SPARSE_VECTOR METADATA { dimensions: 8 }
-- AlreadyExistsException: Index 'D[tk,wt]' already exists
SELECT expand(vectorSparseNeighbors('D[tk,wt]', [1], [1.0], 5))
-- the same name over the new type D: CommandSQLParsingException: No sparse vector index found on properties 'tk,wt' for type 'D'Without the REBUILD INDEX the name is right after the same rename and truncate (Dren[tk,wt]). An LSM_TREE index named Dren[g] survived the same sequence in the fuzz run (the vector and sparse vector paths are the ones that re-create the TypeIndex from the sub-index metadata on truncate).
Version
origin/main dc07b20 (26.12.1-SNAPSHOT).
Options
- Rename moves the sub-indexes'
typeIndexNamealong when the TypeIndex has no manual name (TypeIndex.updateTypeNameOfSubIndexesOn/IndexInternal.updateTypeName): clear it, so the next mint derives the name from the current type. - Do not hand the derived name back from REBUILD: pass
typeIndex.hasManualName() ? name : nullatRebuildIndexStatement.java:568/578andDatabaseChecker.java:626. - In
addIndexInternalignore a custom name whose derivation under SOME earlier name of the type is the custom name (not available: the history is not kept), so 1 or 2 is the fix.
Activity
fix(ArcadeData#12774): a derived index name is not carried in the ind…
lvca commentedon Nov 24, 2026
Fixed by #12784, shipping in 26.12.1.
What was wrong
After
REBUILD INDEX, a rename of the type (ALTER TYPE D NAME Dren) and aTRUNCATE TYPE, anLSM_SPARSE_VECTORindex came back named after the old type:D[tk,wt]on a type now calledDren. That name was saved, so it also survived a restart. As a resultvectorSparseNeighbors('D[tk,wt]', ...)failed withType with name 'D' was not found, and a new typeDcould not get the same sparse index (Index 'D[tk,wt]' already exists).What changes for you
An index that has the default name now follows the type through the rename and the truncate: it is
Dren[tk,wt]afterwards, also after a restart, and the old name is free for a new type. An index you named yourself keeps its name, as before.One side effect: an index created by spelling the default name out (for example
CREATE INDEX `D[tk,wt]` ON D (tk, wt) LSM_SPARSE_VECTOR) is now treated like any index with the default name, so it follows a rename of the type.The fix prevents the wrong name from being created. It does not rename an index that already came out with the old name in an existing database: drop it and create it again.
❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.