yuqi1129 opened a new issue, #12403:
URL: https://github.com/apache/gravitino/issues/12403

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   `CatalogManager` closes `CatalogWrapper` synchronously from the catalog 
cache removal listener. Cache expiration and remote change-log invalidation are 
not protected by the local `TreeLock`, so eviction can race with an active 
catalog operation.
   
   `CatalogWrapper.close()` closes the catalog, clears its reference, releases 
the pooled classloader reference, and may clean up the `IsolatedClassLoader`. 
An operation already using that wrapper can consequently fail with 
`NoClassDefFoundError`, `NullPointerException`, or errors from prematurely 
closed catalog resources.
   
   This was identified while reviewing #12350, but it is a JVM object-lifecycle 
invariant and should be fixed separately from the database concurrency protocol.
   
   ### Error message and/or stacktrace
   
   The failure depends on which catalog resource is accessed after eviction. 
Possible symptoms include `NoClassDefFoundError`, `NullPointerException`, or 
errors from a prematurely closed client or connection pool.
   
   ### How to reproduce
   
   1. Start a catalog operation and pause it after obtaining the cached wrapper.
   2. Expire or remotely invalidate the catalog cache entry.
   3. Let the removal listener call `CatalogWrapper.close()`.
   4. Resume the operation and observe access to the closed catalog or 
classloader.
   
   ### Additional context
   
   Introduce an active-operation lease or reference count in `CatalogWrapper`. 
Cache removal should retire the wrapper immediately but defer catalog and 
classloader cleanup until the active count reaches zero. New operations should 
acquire a lease and retry with a freshly loaded wrapper if the old wrapper has 
already retired. Direct production uses of `catalog()` should also be migrated 
to the lease API.
   
   Add deterministic tests for cache expiry, remote invalidation, drop, and 
exactly-once classloader cleanup.


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