Skip to content

[core] Invalidate partition cache when dropping a database - #10259

Open
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-082-dropdb-partcache
Open

LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-082-dropdb-partcache

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Purpose

CachingCatalog.dropDatabase with cascade invalidated only the table cache entries it found through tableCache.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 by Identifier.

This enumerates the database's tables with listTables before the drop and routes each through invalidateTable, which clears the table cache, the partition cache, and the branch entries. Enumeration happens before super.dropDatabase because the tables are gone from the wrapped catalog afterwards. Cascade dropDatabase now invalidates caches the same way a direct dropTable does.

This closes #10257.

Tests

Adds CachingCatalogTest.testDropDatabaseCascadeInvalidatesPartitionCache: it caches a partition for db.tbl, drops the database with cascade, and asserts the next listPartitions reloads 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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] CachingCatalog cascade dropDatabase leaves stale partition cache entries

1 participant