jerryshao commented on code in PR #14967:
URL: https://github.com/apache/gravitino/pull/14967#discussion_r4582418797


##########
core/src/main/java/org/apache/gravitino/storage/relational/mapper/TagMetadataObjectRelMapper.java:
##########
@@ -19,19 +19,62 @@
 package org.apache.gravitino.storage.relational.mapper;
 
 import java.util.List;
+import java.util.Set;
 import javax.annotation.Nullable;
+import org.apache.gravitino.MetadataObject;
+import org.apache.gravitino.storage.relational.po.DomainAssignmentPO;
 import org.apache.gravitino.storage.relational.po.TagMetadataObjectRelPO;
 import org.apache.gravitino.storage.relational.po.TagPO;
 import org.apache.gravitino.storage.relational.po.TagRelationTagPO;
 import org.apache.ibatis.annotations.DeleteProvider;
 import org.apache.ibatis.annotations.InsertProvider;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.SelectProvider;
 import org.apache.ibatis.annotations.UpdateProvider;
 
 public interface TagMetadataObjectRelMapper {
   String TAG_METADATA_OBJECT_RELATION_TABLE_NAME = "tag_relation_meta";
 
+  /**
+   * Reads selected domain assignments before resolving object names.
+   *
+   * @param metalake The containing metalake.
+   * @param domainIds Selected domain IDs.
+   * @param types Selected object types.
+   * @param candidateDomainIds Domains supplying the candidate objects, or 
empty for all.
+   * @return Assignment rows with the matching domain ID.
+   */
+  @Select({
+    "<script>",
+    "SELECT d.domain_id AS domainId, r.tag_id AS tagId, r.tag_value AS 
tagValue,",
+    "r.metadata_object_id AS metadataObjectId, r.metadata_object_type AS 
metadataObjectType",
+    "FROM domain_meta d JOIN metalake_meta m ON m.metalake_id = d.metalake_id",
+    "JOIN tag_meta t ON t.tag_id = d.backing_tag_id AND t.metalake_id = 
m.metalake_id",
+    "JOIN tag_relation_meta r ON r.tag_id = t.tag_id",
+    "WHERE m.metalake_name = #{metalake} AND m.deleted_at = 0 AND d.deleted_at 
= 0",
+    "AND t.deleted_at = 0 AND r.deleted_at = 0",
+    "AND (d.backing_tag_value IS NULL OR d.backing_tag_value = r.tag_value)",

Review Comment:
   Thanks for the reproducer. I agree this can omit valid members when a domain 
is rebound between reading its binding and querying its assignments. Given that 
this corner case requires a concurrent rebind during a normal list request, I’d 
like to defer the fix for this PR. A complete fix should use the same binding 
snapshot in both the initial assignment query and the second pass that collects 
the other visible domain paths.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to