roryqi commented on code in PR #13384:
URL: https://github.com/apache/gravitino/pull/13384#discussion_r4547773870


##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java:
##########
@@ -478,11 +479,33 @@ public LoadTableResponse updateTable(
   }
 
   public LoadTableResponse updateTable(IcebergTableChange icebergTableChange) {
+    getMetadataCache().invalidate(icebergTableChange.getTableIdentifier());

Review Comment:
   Fixed in 0e4b3cfd59. Cache invalidation now runs in a finally block after 
commitTransaction(), including when the commit fails. Parameterized regression 
tests cover both update entry points and reproduce old metadata being cached 
during the commit, plus cache cleanup after a failed commit. All 289 unit tests 
in the two affected modules passed.



##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java:
##########
@@ -478,11 +479,33 @@ public LoadTableResponse updateTable(
   }
 
   public LoadTableResponse updateTable(IcebergTableChange icebergTableChange) {
+    getMetadataCache().invalidate(icebergTableChange.getTableIdentifier());

Review Comment:
   Fixed in 0e4b3cfd59. Cache invalidation now runs in a finally block after 
commitTransaction(), including when the commit fails. Parameterized regression 
tests cover both update entry points and reproduce old metadata being cached 
during the commit, plus cache cleanup after a failed commit. All 289 unit tests 
in the two affected modules passed.



##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java:
##########
@@ -478,11 +479,33 @@ public LoadTableResponse updateTable(
   }
 
   public LoadTableResponse updateTable(IcebergTableChange icebergTableChange) {
+    getMetadataCache().invalidate(icebergTableChange.getTableIdentifier());
     Transaction transaction = icebergTableChange.getTransaction();
     transaction.commitTransaction();
     return loadTable(icebergTableChange.getTableIdentifier());
   }
 
+  /**
+   * Builds an {@link IcebergTableChange} and commits it within a single 
proxied call. When this
+   * wrapper is behind the {@link KerberosAwareIcebergCatalogProxy}, the 
entire operation, including
+   * the metadata.json read triggered by {@code loadTable()} inside the 
builder, runs under the
+   * impersonated user's UGI context.
+   *
+   * <p>The catalog passed to the builder is the same underlying instance 
returned by {@link
+   * #getCatalog()}; it is not itself proxied. The builder must execute inside 
this wrapper method
+   * so that table loading and transaction construction remain within the 
proxy's Kerberos boundary.
+   * Moving the builder call outside this method would bypass impersonation 
even when using the same
+   * catalog.
+   *
+   * @param builder a function that uses the underlying catalog to build an 
{@link
+   *     IcebergTableChange}
+   * @return the response after committing the table change
+   */
+  public LoadTableResponse buildAndUpdateTable(Function<Catalog, 
IcebergTableChange> builder) {
+    IcebergTableChange change = builder.apply(getCatalog());

Review Comment:
   Addressed in 0e4b3cfd59. Added Javadoc to updateTable(IcebergTableChange) 
explaining that it cannot establish impersonation for the earlier table load or 
transaction construction. Callers requiring Kerberos impersonation must build 
changes inside buildAndUpdateTable on the proxied wrapper.



##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java:
##########
@@ -478,11 +479,33 @@ public LoadTableResponse updateTable(
   }
 
   public LoadTableResponse updateTable(IcebergTableChange icebergTableChange) {
+    getMetadataCache().invalidate(icebergTableChange.getTableIdentifier());
     Transaction transaction = icebergTableChange.getTransaction();
     transaction.commitTransaction();
     return loadTable(icebergTableChange.getTableIdentifier());
   }
 
+  /**
+   * Builds an {@link IcebergTableChange} and commits it within a single 
proxied call. When this
+   * wrapper is behind the {@link KerberosAwareIcebergCatalogProxy}, the 
entire operation, including
+   * the metadata.json read triggered by {@code loadTable()} inside the 
builder, runs under the
+   * impersonated user's UGI context.
+   *
+   * <p>The catalog passed to the builder is the same underlying instance 
returned by {@link
+   * #getCatalog()}; it is not itself proxied. The builder must execute inside 
this wrapper method
+   * so that table loading and transaction construction remain within the 
proxy's Kerberos boundary.
+   * Moving the builder call outside this method would bypass impersonation 
even when using the same
+   * catalog.
+   *
+   * @param builder a function that uses the underlying catalog to build an 
{@link
+   *     IcebergTableChange}
+   * @return the response after committing the table change
+   */
+  public LoadTableResponse buildAndUpdateTable(Function<Catalog, 
IcebergTableChange> builder) {
+    IcebergTableChange change = builder.apply(getCatalog());

Review Comment:
   Addressed in 0e4b3cfd59. Added Javadoc to updateTable(IcebergTableChange) 
explaining that it cannot establish impersonation for the earlier table load or 
transaction construction. Callers requiring Kerberos impersonation must build 
changes inside buildAndUpdateTable on the proxied wrapper.



##########
catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergBackend.java:
##########
@@ -115,13 +116,14 @@ private void reload() {
         IcebergCatalogUtil.withGcsServiceAccountCredentials(new 
IcebergConfig(conf));
     try {
       IcebergCatalogWrapper rawWrapper = new 
IcebergCatalogWrapper(icebergConfig);
+      // Initialize the catalog here so configuration errors are reported 
during reload.
+      Catalog catalog = rawWrapper.getCatalog();

Review Comment:
   Clarified in 0e4b3cfd59. The previous Kerberos capability check already 
called rawWrapper.getCatalog(), and the helper constructor also obtained the 
catalog. ClosableHiveCatalog.initialize() creates and logs in the 
KerberosClient needed by doKerberosOperations(), so initialization must precede 
proxy use. The existing initialization order is preserved; table metadata reads 
run later through the proxy. Added a code comment and assertions covering 
initialization once before proxied operations.



##########
catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergBackend.java:
##########
@@ -115,13 +116,14 @@ private void reload() {
         IcebergCatalogUtil.withGcsServiceAccountCredentials(new 
IcebergConfig(conf));
     try {
       IcebergCatalogWrapper rawWrapper = new 
IcebergCatalogWrapper(icebergConfig);
+      // Initialize the catalog here so configuration errors are reported 
during reload.
+      Catalog catalog = rawWrapper.getCatalog();

Review Comment:
   Clarified in 0e4b3cfd59. The previous Kerberos capability check already 
called rawWrapper.getCatalog(), and the helper constructor also obtained the 
catalog. ClosableHiveCatalog.initialize() creates and logs in the 
KerberosClient needed by doKerberosOperations(), so initialization must precede 
proxy use. The existing initialization order is preserved; table metadata reads 
run later through the proxy. Added a code comment and assertions covering 
initialization once before proxied operations.



-- 
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