Skip to content

Implement CLEAR_TABLE mode for cache invalidation#48

Draft
peterxcli wants to merge 1 commit into
demo-pocfrom
peter/wip
Draft

Implement CLEAR_TABLE mode for cache invalidation#48
peterxcli wants to merge 1 commit into
demo-pocfrom
peter/wip

Conversation

@peterxcli

Copy link
Copy Markdown
Collaborator

This pull request introduces a new cache invalidation mode, CLEAR_TABLE, to ensure that all query condition cache entries for a table are invalidated in response to delete-like operations (such as DELETE, TRUNCATE, and certain MERGE actions) that can rewrite or remove entire row groups. The changes update the optimizer, logical and physical operators, and condition cache store to support this mode, and adjust tests to reflect the new invalidation semantics.

Key changes:

Cache Invalidation Logic

  • Added a new CacheInvalidatorMode::CLEAR_TABLE to represent operations that require clearing all cache entries for a table, such as DELETE, TRUNCATE, and certain MERGE operations. The optimizer now selects this mode for applicable statements. [1] [2] [3] [4]
  • Implemented a new constructor for LogicalCacheInvalidator to support the CLEAR_TABLE mode and updated deserialization logic accordingly. [1] [2] [3]

Condition Cache Store

  • Added a RemoveEntriesForTable method to ConditionCacheStore that deletes all cache entries for a given table, and integrated it into the physical invalidator's finalize logic for the CLEAR_TABLE mode. [1] [2] [3]
  • Updated the cache invalidation operator to invoke RemoveEntriesForTable when in CLEAR_TABLE mode, ensuring all relevant cache entries are removed. [1] [2]

Testing and Verification

  • Updated and expanded tests to verify that DELETE, TRUNCATE, and related operations now clear all cache entries for the target table, and that cache invalidation remains correct after these operations. [1] [2] [3] [4] [5] [6]
  • Added new unit tests for the RemoveEntriesForTable method and for the new CLEAR_TABLE mode constructor of LogicalCacheInvalidator. [1] [2]

Other Improvements

  • Improved comments and updated test descriptions to clarify the new semantics of cache invalidation for delete-like operations. [1] [2] [3]
  • Minor code cleanup and formatting improvements in unrelated areas. [1] [2] [3]

These changes ensure that the query condition cache remains correct and consistent after operations that can affect the entire table, improving reliability and correctness.

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.

1 participant