LuciferYang opened a new pull request, #14657:
URL: https://github.com/apache/gravitino/pull/14657

   ### What changes were proposed in this pull request?
   
   - `BaseCatalog.catalog()` loads the Gravitino catalog on first use and keeps 
it for the life of the Flink catalog instance. A failed load is not kept, so 
the next call tries again.
   - It also loads the catalog again when the shared `GravitinoCatalogManager` 
has been closed and created again, because the kept handle uses the REST client 
of the manager that loaded it.
   - The Flink version modules add `mockito-inline` as a test dependency for 
the new tests' static mock.
   
   ### Why are the changes needed?
   
   `catalog()` sent a `loadCatalog` request every time, because the Java client 
does not cache catalogs, and nearly every Flink catalog method calls it before 
its own schema or table request. Flink resolves tables more than once while 
planning and doesn't cache the lookups, so planning `SELECT * FROM cat.db.t` 
sent 8 requests to the Gravitino server where 4 are enough, and `INSERT INTO 
cat.db.s SELECT * FROM cat.db.t` sent 10 instead of 5.
   
   Flink keeps each catalog instance for the whole session. Schema and table 
calls made through the kept handle still go to the server every time, by 
catalog name.
   
   Fixes #14655
   
   ### Does this PR introduce _any_ user-facing change?
   
   No, apart from fewer requests to the Gravitino server.
   
   ### How was this patch tested?
   
   - `TestBaseCatalog.testCatalogHandleFetchedOncePerInstance`: three 
`catalog()` calls load the catalog once.
   - `TestBaseCatalog.testCatalogHandleLoadFailureIsNotCached`: after a load 
fails with `NoSuchCatalogException`, the next call loads again.
   - `TestBaseCatalog.testCatalogHandleReloadedWhenManagerIsReplaced`: when 
`GravitinoCatalogManager.get()` starts returning a different manager, the 
catalog is loaded again from that manager.
   - The request counts above come from counting the catalog methods Flink 
calls while planning those queries on Flink 1.20 and 2.1.
   


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