anilkumgopalap commented on code in PR #14862:
URL: https://github.com/apache/gravitino/pull/14862#discussion_r4643544492


##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/LocationProvider.java:
##########
@@ -253,7 +265,78 @@ public interface TableLocationProvider {
    * #provisionTableLocation(TableLocationContext)}, it is called concurrently 
and must be
    * thread-safe.
    *
+   * <p>The result reports whether this call released anything. The catalog 
only logs it; it does
+   * not change the outcome of the drop.
+   *
    * @param context the table that is gone and the context needed to release 
its location
+   * @return true if the provider released an allocation for the location, 
false if there was
+   *     nothing to release, such as a location it does not recognize or one 
already released
+   */
+  boolean unprovisionTableLocation(TableLocationContext context);
+
+  /**
+   * Provisions the location of a schema that is being created. The default 
implementation returns
+   * null.
+   *
+   * <p>The context carries the properties of the creation request, including 
a caller-supplied
+   * {@code location}, if any. As with tables, what happens to a supplied 
location is the provider's
+   * decision: return a location to place the schema there; return null or a 
blank string to leave
+   * the location to the caller, in which case the schema is created with the 
properties of the
+   * request as they are, including any {@code location} the caller supplied; 
or throw to refuse the
+   * creation.
+   *
+   * <p>A location that is returned is stored verbatim as the schema's {@code 
location} property.
+   * Because the built-in provider derives the location of a table from its 
schema's {@code
+   * location}, recording it also keeps the schema consistent with the tables 
placed under it.
+   *
+   * <p>It is called before the schema is stored, and before the catalog finds 
out whether a schema
+   * of that name already exists, so it can be called for a name that is 
taken; the creation then
+   * fails with {@link SchemaAlreadyExistsException}. A provider that knows 
the schema exists may
+   * throw that itself. As with tables, there is no compensating unprovision 
for a creation that

Review Comment:
   It means the catalog doesn't roll back: if `provisionSchemaLocation` 
succeeded but the schema then isn't stored (e.g. it already exists, or the 
store write fails), the catalog does not call `unprovisionSchemaLocation` for 
it. I've reworded it to say exactly that.



##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/LocationProvider.java:
##########
@@ -253,7 +265,78 @@ public interface TableLocationProvider {
    * #provisionTableLocation(TableLocationContext)}, it is called concurrently 
and must be
    * thread-safe.
    *
+   * <p>The result reports whether this call released anything. The catalog 
only logs it; it does
+   * not change the outcome of the drop.
+   *
    * @param context the table that is gone and the context needed to release 
its location
+   * @return true if the provider released an allocation for the location, 
false if there was
+   *     nothing to release, such as a location it does not recognize or one 
already released
+   */
+  boolean unprovisionTableLocation(TableLocationContext context);
+
+  /**
+   * Provisions the location of a schema that is being created. The default 
implementation returns
+   * null.
+   *
+   * <p>The context carries the properties of the creation request, including 
a caller-supplied
+   * {@code location}, if any. As with tables, what happens to a supplied 
location is the provider's
+   * decision: return a location to place the schema there; return null or a 
blank string to leave
+   * the location to the caller, in which case the schema is created with the 
properties of the
+   * request as they are, including any {@code location} the caller supplied; 
or throw to refuse the
+   * creation.
+   *
+   * <p>A location that is returned is stored verbatim as the schema's {@code 
location} property.
+   * Because the built-in provider derives the location of a table from its 
schema's {@code
+   * location}, recording it also keeps the schema consistent with the tables 
placed under it.
+   *
+   * <p>It is called before the schema is stored, and before the catalog finds 
out whether a schema
+   * of that name already exists, so it can be called for a name that is 
taken; the creation then
+   * fails with {@link SchemaAlreadyExistsException}. A provider that knows 
the schema exists may
+   * throw that itself. As with tables, there is no compensating unprovision 
for a creation that
+   * fails after this method returned: a provider answering idempotently may 
have returned the
+   * allocation of the schema that exists, and releasing it would take it from 
that schema.

Review Comment:
   Right, the interface doesn't require idempotency, and a provider that can 
tell the schema exists should throw `SchemaAlreadyExistsException`. The 
sentence was explaining why the catalog doesn't release on failure: some 
backends return the existing allocation for the same name instead of failing 
(DataMesh's provisioning calls behave that way), so a rollback could release 
the allocation of the schema that does exist. I've removed that detail and kept 
only the behavior, see the reply above.



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