You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "lhjchn (via GitHub)" <gi...@apache.org> on 2026/06/04 01:24:56 UTC
[PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
lhjchn opened a new pull request, #11417:
URL: https://github.com/apache/gravitino/pull/11417
### What changes were proposed in this pull request?
Previously `DropCatalogStoredProcedure` only checked the Trino connector's local cache (the `catalogConnectors` map) to decide whether a catalog exists. When the local connector was null, it directly threw "not exists"
without checking the Gravitino server.
This PR changes the null branch to call `metalake.dropCatalog(catalogName, true)` on the server:
1. If the server returns true, the catalog is dropped on the server successfully.
2. If the server returns false, the catalog does not exist on the server either. We then respect the `ignore_not_exist` flag: return silently if true, throw `GRAVITINO_CATALOG_NOT_EXISTS` if false.
The branch where the local connector is found stays the same as before.
Also adds a unit test class `TestDropCatalogStoredProcedure` for the new code path and updates the Javadoc.
### Why are the changes needed?
Fix: #11401
The local cache may not have the catalog even though it exists on the Gravitino server. This can happen when:
1. The catalog is created with invalid properties and the connector fails to load.
2. The cache entry is evicted.
3. Trino is restarted before the background scheduler reloads it.
In this state the catalog cannot be dropped (local check returns null, `drop_catalog` throws "not exists") and cannot be recreated either (the server still holds the metadata, `create_catalog` throws "already exists"). The
user has no way to recover without restarting Trino or calling the server-side API directly.
By falling back to the server-side drop when the local cache misses, the user can clean up the catalog with the same `drop_catalog` procedure.
### Does this PR introduce _any_ user-facing change?
No new API, configuration, or property key.
The behavior of `drop_catalog(catalog, ignore_not_exist)` changes only for the bug case: calls that previously failed with "not exists" while the catalog actually existed on the server now succeed. The other cases (catalog
truly does not exist anywhere; catalog exists in the local cache) behave the same as before.
### How was this patch tested?
Added a new unit test class `TestDropCatalogStoredProcedure` with three cases:
1. The local cache does not contain the catalog but the server does. The procedure should call the server-side drop and complete without error.
2. The catalog is absent from both the local cache and the server, with `ignoreNotExist=false`. The procedure should throw `GRAVITINO_CATALOG_NOT_EXISTS`.
3. Same as case 2 but with `ignoreNotExist=true`. The procedure should return silently and must not trigger a local cache reload.
Ran `./gradlew :trino-connector:trino-connector:test -PskipITs` and `./gradlew :trino-connector:trino-connector:spotlessApply`, both pass.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "lhjchn (via GitHub)" <gi...@apache.org>.
lhjchn commented on PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#issuecomment-4629135211
@yuqi1129 Sure, I'll create a PR for branch-1.3.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "lhjchn (via GitHub)" <gi...@apache.org>.
lhjchn commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3356814005
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
I noticed PR #11432 covers the same fix with a more concise change.Would it make sense to keep this PR instead? It already includes unit tests for the fallback path and updated Javadoc. I'm happy to simplify the main code to match the shorter style in #11432 if preferred.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "lhjchn (via GitHub)" <gi...@apache.org>.
lhjchn commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3356796684
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
1. You're right, I'll remove the "cache was evicted" wording.
2. The user sees the catalog via CLI/REST/UI, just not from Trino.
create_catalog with bad props succeeds on server but fails to load
locally, so drop_catalog says "not exists" while create_catalog says
"already exists".
I noticed PR #11432 covers the same fix with a more concise change.
Would it make sense to keep this PR instead? It already includes
unit tests for the fallback path and updated Javadoc. I'm happy to
simplify the main code to match the shorter style in #11432 if
preferred.
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
1. You're right, I'll remove the "cache was evicted" wording.
2. The user sees the catalog via CLI/REST/UI, just not from Trino.
create_catalog with bad props succeeds on server but fails to load
locally, so drop_catalog says "not exists" while create_catalog says
"already exists".
I noticed PR #11432 covers the same fix with a more concise change.
Would it make sense to keep this PR instead? It already includes
unit tests for the fallback path and updated Javadoc. I'm happy to
simplify the main code to match the shorter style in #11432 if
preferred.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#issuecomment-4621075766
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|66.78% **`-0.02%`**|:green_circle:|
|:-|:-|:-:|
|Files changed|65.55%|:green_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|1.72%|:red_circle:|
|api|46.82%|:green_circle:|
|authorization-common|85.96%|:green_circle:|
|aws|3.66%|:red_circle:|
|azure|2.47%|:red_circle:|
|catalog-common|10.04%|:red_circle:|
|catalog-fileset|80.33%|:green_circle:|
|catalog-glue|66.08% **`+3.45%`**|:green_circle:|
|catalog-hive|79.33%|:green_circle:|
|catalog-jdbc-clickhouse|80.02%|:green_circle:|
|catalog-jdbc-common|45.31%|:green_circle:|
|catalog-jdbc-doris|80.28%|:green_circle:|
|catalog-jdbc-hologres|54.03%|:green_circle:|
|catalog-jdbc-mysql|79.23%|:green_circle:|
|catalog-jdbc-oceanbase|78.38%|:green_circle:|
|catalog-jdbc-postgresql|82.29%|:green_circle:|
|catalog-jdbc-starrocks|78.51%|:green_circle:|
|catalog-kafka|77.01%|:green_circle:|
|catalog-lakehouse-generic|44.89%|:green_circle:|
|catalog-lakehouse-hudi|79.1%|:green_circle:|
|catalog-lakehouse-iceberg|85.66%|:green_circle:|
|catalog-lakehouse-paimon|79.29%|:green_circle:|
|catalog-model|77.72%|:green_circle:|
|cli|44.51%|:green_circle:|
|client-java|77.91%|:green_circle:|
|common|49.99%|:green_circle:|
|core|82.49% **`-0.01%`**|:green_circle:|
|filesystem-hadoop3|76.97%|:green_circle:|
|flink|0.0%|:red_circle:|
|flink-common|41.2%|:green_circle:|
|flink-runtime|0.0%|:red_circle:|
|gcp|14.12%|:red_circle:|
|hadoop-common|10.39%|:red_circle:|
|hive-metastore-common|53.26%|:green_circle:|
|iceberg-common|56.54%|:green_circle:|
|iceberg-rest-server|72.76%|:green_circle:|
|idp-basic|85.99%|:green_circle:|
|integration-test-common|0.0%|:red_circle:|
|jobs|66.17%|:green_circle:|
|lance-common|20.83%|:red_circle:|
|lance-rest-server|60.27%|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|82.95%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|85.73%|:green_circle:|
|server-common|73.13% **`+4.57%`**|:green_circle:|
|spark|32.79%|:red_circle:|
|spark-common|37.99% **`-4.82%`**|:red_circle:|
|trino-connector|39.97% **`+0.15%`**|:red_circle:|
<details>
<summary>Files</summary>
|Module|File|Coverage||
|:-|:-|:-|:-:|
|catalog-glue|[GlueCatalogOperations.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/catalogs/catalog-glue/src/main/java/org/apache/gravitino/catalog/glue/GlueCatalogOperations.java)|72.38%|:green_circle:|
||[GlueConstants.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/catalogs/catalog-glue/src/main/java/org/apache/gravitino/catalog/glue/GlueConstants.java)|0.0%|:red_circle:|
|core|[PrincipalMapperFactory.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/core/src/main/java/org/apache/gravitino/auth/PrincipalMapperFactory.java)|70.0%|:green_circle:|
||[GroupMapperFactory.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/core/src/main/java/org/apache/gravitino/auth/GroupMapperFactory.java)|66.67%|:green_circle:|
||[GroupMapper.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/core/src/main/java/org/apache/gravitino/auth/GroupMapper.java)|0.0%|:red_circle:|
||[PrincipalMapper.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/core/src/main/java/org/apache/gravitino/auth/PrincipalMapper.java)|0.0%|:red_circle:|
|server-common|[StaticSignKeyValidator.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/server-common/src/main/java/org/apache/gravitino/server/authentication/StaticSignKeyValidator.java)|93.51%|:green_circle:|
||[JwksTokenValidator.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/server-common/src/main/java/org/apache/gravitino/server/authentication/JwksTokenValidator.java)|93.1%|:green_circle:|
||[JettyServerConfig.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/server-common/src/main/java/org/apache/gravitino/server/web/JettyServerConfig.java)|89.2%|:green_circle:|
||[KerberosAuthenticator.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/server-common/src/main/java/org/apache/gravitino/server/authentication/KerberosAuthenticator.java)|85.9%|:green_circle:|
|spark-common|[HivePropertiesConverter.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/hive/HivePropertiesConverter.java)|95.71%|:green_circle:|
||[BaseCatalog.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/catalog/BaseCatalog.java)|0.0%|:red_circle:|
||[CatalogNameAdaptor.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/version/CatalogNameAdaptor.java)|0.0%|:red_circle:|
|trino-connector|[DropCatalogStoredProcedure.java](https://github.com/lhjchn/gravitino/blob/3fbe4258d156bdd0f7fa456146f3ac7d1033cd34/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java)|53.85%|:red_circle:|
</details>
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3356829639
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
You can go forward with your PR as you raise it ahead of #11432
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "lhjchn (via GitHub)" <gi...@apache.org>.
lhjchn commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3356809144
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
1. You're right, I'll remove the "cache was evicted" wording.
2. The user sees the catalog via CLI/REST/UI, just not from Trino.
create_catalog with bad props succeeds on server but fails to load
locally, so drop_catalog says "not exists" while create_catalog says
"already exists".
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3360065302
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -90,14 +92,23 @@ public void dropCatalog(String catalogName, boolean ignoreNotExist) {
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
if (catalogConnector == null) {
- if (ignoreNotExist) {
- return;
+ boolean dropped =
+ catalogConnectorManager.getMetalake(metalake).dropCatalog(catalogName, true);
+ if (!dropped) {
+ if (ignoreNotExist) {
+ return;
+ }
+ throw new TrinoException(
+ GravitinoErrorCode.GRAVITINO_CATALOG_NOT_EXISTS,
+ "Catalog " + NameIdentifier.of(metalake, catalogName) + " not exists.");
}
-
- throw new TrinoException(
- GravitinoErrorCode.GRAVITINO_CATALOG_NOT_EXISTS,
- "Catalog " + NameIdentifier.of(metalake, catalogName) + " not exists.");
+ LOG.info(
+ "Drop catalog {} in metalake {} from server (no local connector) successfully.",
+ catalogName,
+ metalake);
+ return;
Review Comment:
After a successful server-side drop in the local-cache-miss branch, the method returns without calling `catalogConnectorManager.loadMetalakeSync()` / checking `catalogConnectorExist(...)`. Because `CatalogConnectorManager` updates `catalogConnectors` asynchronously via its scheduled loader, a connector for this catalog can be added concurrently after the initial `getCatalogConnector(...)` null check. In that race, this procedure would drop the catalog on the server but leave a stale local connector registered until the next refresh cycle. Consider reusing the same sync-reload + existence check used in the non-null branch to ensure the local view is consistent immediately after the server-side drop.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3360018166
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
I’ve closed #11432. You can go ahead with your PR.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "lhjchn (via GitHub)" <gi...@apache.org>.
lhjchn commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3356784893
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
1. You're right, I'll remove the "cache was evicted" wording.
2. The user sees the catalog via CLI/REST/UI, just not from Trino.
create_catalog with bad props succeeds on server but fails to load
locally, so drop_catalog says "not exists" while create_catalog says
"already exists".
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "lhjchn (via GitHub)" <gi...@apache.org>.
lhjchn commented on PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#issuecomment-4629140136
@yuqi1129 Sure, I'll create a PR for branch-1.3 .
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 merged PR #11417:
URL: https://github.com/apache/gravitino/pull/11417
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3353237722
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
1. The catalogs cache implementation is a map, see: https://github.com/apache/gravitino/blob/c4259fccdc35aae856a47100357a68a6b7d4cb80/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/CatalogConnectorManager.java#L71-L72, I can't get why it will be evicted.
2. `the connector failed to load at startup`, I'm afraid that we can't see the catalog as it fails to be loaded at startup, so can we remove it without being aware of its existence?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "lhjchn (via GitHub)" <gi...@apache.org>.
lhjchn commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3360755696
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
@yuqi1129 Hi, do you think the conditional logic should be simplified further?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#issuecomment-4618634298
@yuqi1129 please help to review this PR, thanks.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "lhjchn (via GitHub)" <gi...@apache.org>.
lhjchn commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3356809144
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
Thanks for your review @yuqi1129
1. You're right, I'll remove the "cache was evicted" wording.
2. The user sees the catalog via CLI/REST/UI, just not from Trino. create_catalog with bad props succeeds on server but fails to load locally, so drop_catalog says "not exists" while create_catalog says "already exists".
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "lhjchn (via GitHub)" <gi...@apache.org>.
lhjchn commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3356809144
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
1. You're right, I'll remove the "cache was evicted" wording.
2. The user sees the catalog via CLI/REST/UI, just not from Trino. create_catalog with bad props succeeds on server but fails to load locally, so drop_catalog says "not exists" while create_catalog says "already exists".
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#issuecomment-4628990740
@lhjchn
Can you also raise a PR to fix the problem in branch-1.3? I forgot to add the tag `branch-1.3`, which will be used to cherry-pick to `branch-1.3`, thanks.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "lhjchn (via GitHub)" <gi...@apache.org>.
lhjchn commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3356814005
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
I noticed PR #11432 covers the same fix with a more concise change.
Would it make sense to keep this PR instead? It already includes
unit tests for the fallback path and updated Javadoc. I'm happy to
simplify the main code to match the shorter style in #11432 if
preferred.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "lhjchn (via GitHub)" <gi...@apache.org>.
lhjchn commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3356784893
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
1. You're right, I'll remove the "cache was evicted" wording.
2. The user sees the catalog via CLI/REST/UI, just not from Trino.
create_catalog with bad props succeeds on server but fails to load
locally, so drop_catalog says "not exists" while create_catalog says
"already exists".
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11401] fix(trino-connector): drop_catalog falls back to server when local cache misses [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3360769957
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
The current changes is okay for me, and let us merge it.
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -79,25 +79,48 @@ public Procedure createStoredProcedure() throws NoSuchMethodException, IllegalAc
/**
* Drops the specified catalog.
*
+ * <p>If the catalog is not present in the local connector cache, this method falls back to a
+ * server-side drop against the Gravitino server. The local cache may legitimately be missing the
+ * entry (e.g. the connector failed to load at startup, or the cache was evicted), so consulting
+ * the server avoids leaving the catalog in a zombie state where it can be neither dropped nor
+ * re-created. Only when the server also reports that the catalog does not exist is {@code
+ * ignoreNotExist} consulted to decide between silent return and an error.
+ *
* @param catalogName the name of the catalog to drop
- * @param ignoreNotExist whether to ignore if the catalog does not exist (only checked when the
- * catalog cannot be found initially)
+ * @param ignoreNotExist whether to ignore if the catalog does not exist on both the local cache
+ * and the Gravitino server
* @throws TrinoException if the catalog does not exist and ignoreNotExist is false
*/
public void dropCatalog(String catalogName, boolean ignoreNotExist) {
try {
CatalogConnectorContext catalogConnector =
catalogConnectorManager.getCatalogConnector(
catalogConnectorManager.getTrinoCatalogName(metalake, catalogName));
+
+ // The local in-memory cache may not have an entry even if the catalog exists on
+ // the Gravitino server (e.g. the connector failed to load at startup, or the cache was
+ // evicted). In that case the catalog would otherwise be stuck in a zombie state:
+ // it cannot be dropped here because the local check would say "not exists", and it
+ // cannot be re-created either because the server still holds the metadata.
+ // Fall back to the server-side drop so the server is the source of truth.
if (catalogConnector == null) {
Review Comment:
The current change is okay for me, and let us merge it.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org