Repository navigation
fix(#12774): a derived index name is not carried in the index metadata, so a rename cannot leave it stale for TRUNCATE TYPE - #12784
Conversation
…ex metadata, so a rename cannot leave it stale for TRUNCATE TYPE
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 28 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
This pull request is merged. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Triage: The fix is small and targeted. It adds
Minor note: the checklist item for running |
What does this PR do?
An index name that equals the name derived from the type and the properties is no longer stored as the
typeIndexNameof the index metadata when the index is built; only a name that differs from it (a manual name) is.LocalDocumentType.manualIndexName(typeName, propertyNames, family, name)(new):namewhen it differs fromdefaultIndexName(...),nullotherwise.TypeIndexBuilder.create()andBucketIndexBuilder.create()storemanualIndexName(...)instead of the raw name handed throughwithIndexName.Motivation
#12774: after
REBUILD INDEX,ALTER TYPE D NAME DrenandTRUNCATE TYPE Dren, anLSM_SPARSE_VECTORindex came back asD[tk,wt]on typeDren, flagged as a manual name, so it was persisted that way and survived a reopen.vectorSparseNeighbors('D[tk,wt]', ...)then failed withType with name 'D' was not found, and a new typeDcould not get the same sparse index (AlreadyExistsException: Index 'D[tk,wt]' already exists).REBUILD INDEXhands the TypeIndex name back throughwithIndexName, which the builders stored as thetypeIndexNameof the bucket-level metadata. The rename moves the TypeIndex and the sub-indexes'typeName, and leaves that stored name at the old derived one.TRUNCATE TYPEre-creates the index fromgetMetadataForNewFile(), which carries the stale name, andLocalDocumentType.addIndexInternalcompares it with the name derived from the CURRENT type name: they differ, so it takes it for a manual name. Confirmed by running the sequence on main: the same stale name is reached byCREATE INDEXD[tk,wt]ON D (tk, wt) LSM_SPARSE_VECTOR(the derived name spelled out), a rename and a truncate, with no REBUILD at all.The fix is on the producing side (option 2 of the issue, applied where every caller meets it): the derived name never enters the metadata, so there is nothing for a rename to leave behind.
RebuildIndexStatementandDatabaseCheckerkeep handing the name back, which still keeps a manual name through a REBUILD (#5791, #4139) and renames a derived one with the type (#10751). Nothing changes on a hot path: the comparison runs once per index build.Related issues
Fixes #12774
Additional Notes
New test
Issue12774StaleIndexNameAfterTruncateTest(8 tests, engine):sparseIndexKeepsDerivedNameAfterRebuildRenameTruncate: the sequence of the issue;Dren[tk,wt]onDrenafter the truncate and after a reopen, a new typeDtakes its own sparse index,vectorSparseNeighbors('Dren[tk,wt]', ...)answers over the renamed type andD[tk,wt]over the new one,DROP TYPE DrenleavesD[tk,wt].sparseIndexNamedByTheUserKeepsItsNameAfterRebuildRenameTruncate:CREATE INDEX myname ON D (tk, wt) LSM_SPARSE_VECTORkeepsmynamethrough rebuild, rename, truncate and reopen, and answersvectorSparseNeighbors('myname', ...).indexNamedLikeTheDerivedOneFollowsTheRenameAfterTruncate: the derived name spelled out inCREATE INDEXfollows the rename (no REBUILD involved).everyKindKeepsDerivedNameAfterRebuildRenameTruncate(5 kinds: NOTUNIQUE, FULL_TEXT, GEOSPATIAL, LSM_VECTOR, LSM_SPARSE_VECTOR): derived name after the sequence and after a reopen. Only the sparse vector one was wrong on main.On origin/main (dc07b20) 3 of the 8 fail (the sparse vector ones,
D[tk,wt]@Dreninstead ofDren[tk,wt]@Dren); with the fix all 8 pass.Second run, 165 tests, 0 failures:
LSMTreeIndexTest,ManualIndexNameGuardTestand theCheckDatabase*classes.Neighbours run with the fix, 271 tests, 0 failures:
Issue12774StaleIndexNameAfterTruncateTest,RebuildIndexPreservesNameTest,TypeRenameTest(incl. nested),CheckDatabaseFixPreservesIndexMetadataTest,CreateIndexIfNotExistsTest,TypeCreationTest,TruncateType4817Test,TruncateTypeIndexBug4352Test,TruncateTypeVectorIndexBug4359Test,TruncateTypeStatementTestParserTest,RebuildIndexTest,RebuildIndexInPlaceTest,RebuildIndexInPlaceKindsTest,RebuildIndexOrphanBucketTest.Checklist
mvn clean packagecommand