Skip to content

Conversation

@yuqi1129
Copy link
Contributor

@yuqi1129 yuqi1129 commented Jan 6, 2026

What changes were proposed in this pull request?

This pull request enhances the correctness and robustness of relation caching in the entity storage layer, and expands test coverage to ensure proper handling of multiple bindings for tags and policies. The main changes include improved cache invalidation logic in the RelationalEntityStore and new parameterized tests that verify relation consistency when entities are bound to multiple tags or policies.

Why are the changes needed?

It's a bug

Fix: #9635

Does this PR introduce any user-facing change?

N/A.

How was this patch tested?

UTs.

Copilot AI review requested due to automatic review settings January 6, 2026 13:54
@yuqi1129 yuqi1129 self-assigned this Jan 6, 2026
@yuqi1129 yuqi1129 marked this pull request as draft January 6, 2026 13:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR attempts to fix a cache invalidation issue for tag associations where bidirectional relationships were not being properly invalidated. When associating tags with metadata objects, only one side of the relationship cache was being cleared, leading to stale cache data.

  • Adds bidirectional cache invalidation in insertRelation method (line 256)
  • Adds cache invalidation for destination entities in updateEntityRelations method (lines 269-275)
  • Includes a new comprehensive test for multiple tag bindings to verify the fix

However, the implementation contains a critical bug where the wrong entity type is used for destination entity cache invalidation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStore.java Adds cache invalidation for both source and destination entities in relation operations, but uses incorrect entity type for destinations
core/src/test/java/org/apache/gravitino/storage/TestEntityStorage.java Adds new test case verifying that a single tag can be associated with multiple catalogs and the associations are correctly maintained

@yuqi1129 yuqi1129 closed this Jan 7, 2026
@yuqi1129 yuqi1129 reopened this Jan 7, 2026
@yuqi1129 yuqi1129 marked this pull request as ready for review January 7, 2026 03:59
@yuqi1129 yuqi1129 added the branch-1.1 Automatically cherry-pick commit to branch-1.1 label Jan 7, 2026
@jerryshao jerryshao requested a review from Copilot January 8, 2026 08:28

@ParameterizedTest
@MethodSource("storageProvider")
void testTagRelationMultipleBindings(String type) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we split the cache-related tests to a new class? This file is too big to maintain.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest not adding tests to this file continuously.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see and will try to use a separate class to hold them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

branch-1.1 Automatically cherry-pick commit to branch-1.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug report] Cache data inconsistent, when use tag

2 participants