Bhavdeep-Sai opened a new pull request, #13677:
URL: https://github.com/apache/gravitino/pull/13677

   ### What changes were proposed in this pull request?
   
   This PR fixes the Gravitino client lifecycle issue described in #13675.
   
   `BaseCatalog` could retain a catalog instance backed by a `GravitinoClient` 
that was later evicted from the Caffeine client cache. The cache removal 
listener closes the evicted client's HTTP transport, leaving the retained 
catalog with a closed client.
   
   This change:
   
   - Dynamically re-resolves the Gravitino catalog through 
`GravitinoCatalogManager` when catalog operations are performed.
   - Invalidates catalog cache entries associated with an evicted Gravitino 
client before closing the client.
   - Prevents `BaseCatalog` from continuing to use a catalog backed by a closed 
client.
   - Adds regression tests covering both client cache expiration and 
maximum-size eviction.
   
   ### Why are the changes needed?
   
   When a cached `GravitinoClient` is evicted, `GravitinoCatalogManager` closes 
the client and its underlying HTTP connection pool.
   
   However, `BaseCatalog` could still hold a catalog instance backed by that 
evicted client. Subsequent metadata operations could therefore attempt to use a 
closed HTTP transport and fail.
   
   Re-resolving the catalog after cache eviction ensures that operations use an 
active Gravitino client, while invalidating the corresponding catalog cache 
entries prevents stale catalog instances from being reused.
   
   Fix: #13675
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   This is a bug fix to the internal Gravitino client and catalog cache 
lifecycle. No user-facing API or configuration property is introduced, removed, 
or changed.
   
   ### How was this patch tested?
   
   Added regression tests covering:
   
   - Client cache expiration.
   - Client cache maximum-size eviction.
   - Catalog cache invalidation when a client is evicted.
   
   The following tests/checks were run:
   
   - `./gradlew :spark-connector:spark-3.5:test --tests 
"org.apache.gravitino.spark.connector.catalog.TestBaseCatalogClientEviction" 
--tests 
"org.apache.gravitino.spark.connector.catalog.TestGravitinoCatalogManager"`
   - `./gradlew :spark-connector:spark-3.5:test`
   - `./gradlew spotlessApply`
   - `git diff --check`
   - `./gradlew test -PskipITs -PskipDockerTests=false`


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