LuciferYang opened a new issue, #14549:
URL: https://github.com/apache/gravitino/issues/14549
### Version
main branch
### Describe what's wrong
With `gravitino.client.session.forwardUser=true`, `GravitinoConnector` keeps
one Gravitino client per session user in `perUserSessionCache` (size
`gravitino.client.session.cache.maxSize`, idle expiry
`gravitino.client.session.cache.expireAfterAccessSeconds`), and its removal
listener closes the client. `getMetadata` reads the cache once per transaction,
and the returned `GravitinoMetadata` keeps using that client until the
transaction ends without holding the cache entry.
So when another session evicts the entry while a transaction is still open,
the transaction's next Gravitino call goes to a closed client and fails. The
request never reaches the server.
### Error message and/or stacktrace
```
io.trino.spi.TrinoException: Connection pool shut down
at
org.apache.gravitino.trino.connector.GravitinoErrorCode.toTrinoException(GravitinoErrorCode.java:167)
at
org.apache.gravitino.trino.connector.catalog.CatalogConnectorMetadata.listSchemaNames(CatalogConnectorMetadata.java:156)
at
org.apache.gravitino.trino.connector.GravitinoMetadata.listSchemaNames(GravitinoMetadata.java:138)
Caused by: java.lang.IllegalStateException: Connection pool shut down
at org.apache.hc.core5.util.Asserts.check(Asserts.java:38)
at
org.apache.hc.core5.pool.StrictConnPool.lease(StrictConnPool.java:175)
at
org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.lease(PoolingHttpClientConnectionManager.java:326)
```
### How to reproduce
A unit test in `trino-connector/src/common/test`, with a real
`GravitinoConnector` and real per-user clients against a stub HTTP server:
1. Configure the connector with `gravitino.client.session.forwardUser=true`,
`gravitino.client.authType=simple` and
`gravitino.client.session.cache.maxSize=1`.
2. As `alice`, call `getMetadata` for transaction T1 and `listSchemaNames`:
it succeeds.
3. As `bob`, call `getMetadata` for transaction T2 and `listSchemaNames`: it
succeeds and evicts alice's client.
4. In T1, call `listSchemaNames` again as `alice`: it fails with the error
above, and the stub server receives no third request.
### Additional context
A fix should keep a client open while a transaction still uses it and close
an evicted client once no transaction uses it. `GravitinoConnector` overrides
`commit` but not `rollback`, so it currently has no hook for the end of a
rolled-back transaction.
--
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]