[core] Invalidate partition cache when dropping a database - #10259
Open
LuciferYang wants to merge 1 commit into
Open
LuciferYang wants to merge 1 commit into
LuciferYang wants to merge 1 commit into
Conversation
The cascade branch of dropDatabase invalidated only the table-cache entries it happened to find, by key set. Tables whose table-cache entry had expired were missed entirely, so with the partition cache enabled a dropped database's partitions were served to a recreated same-name table until the entry itself expired. Enumerate the database's tables before the cascade drop and route each through invalidateTable, which clears the partition cache and the branch entries too. Assisted-by: GLM-5.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
CachingCatalog.dropDatabasewith cascade invalidated only the table cache entries it found throughtableCache.asMap().keySet(), and never touched the partition cache. It also missed tables whose table cache entry had already expired while their partition cache entry was still live. With the partition cache enabled, a same-name table recreated within the cache TTL was served the dropped database's partitions, since the partition cache is keyed only byIdentifier.This enumerates the database's tables with
listTablesbefore the drop and routes each throughinvalidateTable, which clears the table cache, the partition cache, and the branch entries. Enumeration happens beforesuper.dropDatabasebecause the tables are gone from the wrapped catalog afterwards. CascadedropDatabasenow invalidates caches the same way a directdropTabledoes.This closes #10257.
Tests
Adds
CachingCatalogTest.testDropDatabaseCascadeInvalidatesPartitionCache: it caches a partition fordb.tbl, drops the database with cascade, and asserts the nextlistPartitionsreloads from the wrapped catalog instead of returning the stale entry. The test does not pre-populate the table cache, so it also pins the case where the old table-cache key-set enumeration would have missed the entry.API and Format
No.
Documentation
No.