Skip to content

Always remove dropped tables from remote data folder cache - #427

Open
CGodiksen wants to merge 2 commits into
mainfrom
bug/remote-table-cache
Open

Always remove dropped tables from remote data folder cache#427
CGodiksen wants to merge 2 commits into
mainfrom
bug/remote-table-cache

Conversation

@CGodiksen

Copy link
Copy Markdown
Collaborator

This PR fixes a bug that causes errors if a table was dropped in a cluster and then a table with the same name was created. When we drop tables in clusters, the node receiving the DROP table statement is responsible for dropping the table from the remote data folder and its local data folder and each peer node is only responsible for dropping the table from their own local data folder.

However, since we cache the tables in both the local data folder and the remote data folder, and the cache is only cleared when the table is dropped from the DataFolder, the peer nodes never removed the cached version from their remote data folder. This means a cache error was caused on the peer nodes if a table with the same name was created again.

This PR moves cache removal up, adds a separate method for it in DataFolder, and always tries to remove the table from the remote data folder cache when it is dropped. This means we technically "remove" the table from the remote data folder cache twice on the node receiving the statement, but the operation is cheap.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are localized, align with the stated cluster cache-invalidation bug, and reuse existing location computation to remove the correct cache entry.

Pull request overview

Fixes stale DeltaTable cache entries in clustered deployments so that dropping a table reliably invalidates cached remote-table handles on peer nodes, preventing cache-related errors when recreating a table with the same name.

Changes:

  • Move Delta table cache invalidation out of delete_table_files() and make it an explicit step in DataFolder::drop_table().
  • Add DataFolder::remove_delta_table_from_cache() to centralize cache invalidation logic.
  • Ensure Context::drop_table() also clears the remote data folder cache (when present) to handle peer-node cache invalidation in clusters.
File summaries
File Description
crates/modelardb_storage/src/data_folder/mod.rs Refactors drop path to explicitly remove the dropped table’s DeltaTable from the cache via a new helper method.
crates/modelardb_server/src/context.rs Clears the remote data folder’s cached DeltaTable on table drop to prevent stale cache usage on peer nodes in clusters.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

3 participants