yuqi1129 opened a new issue, #12145:
URL: https://github.com/apache/gravitino/issues/12145
### Version
main branch
### Describe what's wrong
In embedded integration tests, `MiniGravitino.stop()` returns after the old
HTTP port becomes unavailable, without waiting for the server task and
`GravitinoEnv.shutdown()` to finish.
The next test class can start another embedded server in the same JVM while
the previous shutdown is still running. Because `GravitinoEnv` is a singleton
with mutable component fields, the old shutdown can close the newly initialized
`CatalogManager`. Since #10480, this permanently closes the new manager's
`ClassLoaderPool`, and subsequent catalog creation fails.
### Error message and/or stacktrace
`MetalakeIT.testMetalakeAvailable` failed in CI:
```
java.lang.IllegalStateException: ClassLoaderPool is already closed
at
org.apache.gravitino.utils.ClassLoaderPool.acquire(ClassLoaderPool.java:67)
at
org.apache.gravitino.catalog.CatalogManager.createCatalogWrapper(CatalogManager.java:1198)
```
Failed run:
https://github.com/apache/gravitino/actions/runs/29865361861/job/88752222436?pr=12096
### How to reproduce
Run client-java integration tests in embedded mode so multiple test classes
repeatedly start and stop `MiniGravitino`.
The failure requires this ordering:
1. Server A begins shutdown.
2. Its HTTP port closes, so `MiniGravitino.stop()` returns.
3. Server B initializes the singleton `GravitinoEnv`.
4. Server A's unfinished shutdown closes Server B's `CatalogManager`.
5. Server B attempts to create a catalog.
### Additional context
PR #10480 exposed the race by introducing the terminal
`ClassLoaderPool.close()` state. PR #12096 is unrelated.
`MiniGravitino.stop()` should wait for the server task to terminate
completely. The environment lifecycle should also prevent overlapping
initialize/shutdown operations on the singleton.
--
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]