Should ClientPool consider UGI when reusing a connection?
Query engine
Spark
Question
I have a question regarding the ClientPool in HiveCatalog. It seems we don’t consider UGI when reusing a client, does this mean we could perform the operation with an incorrect identity in a multi-tenant scenario?
We have a spark thrift server to run DDLs from different users, and we randomly encounter authorization failures. By checking audit logs, we noticed the UGI used is different from the user submitting the DDL.
@pvary is this something that you could potentially help answering?
Sorry for the delay - I was OOO.
Since we are reusing the HMSClient objects, we can face authorization issues if we are using Catalogs with multi-tenant scenarios. We were briefly considering using custom keys for the CachedClientPool.clientPoolCache, but at that time decided against it, since we did not see an immediate benefit/use-case. Spark was not reusing the Catalogs, and Hive was using a server side catalog using the HS2 credentials anyway.
This might be a situation where some hash of the bunch of configuration values, or some more specific cache key should be useful.
Hey @pvary , thanks for your input. I also suspected that catalogs are not supposed to be shared among sessions. But I noticed that CachedClientPool.clientPoolCache is a static member. IIUC that means the underlying pool can still be reused, even if new catalog instances are created for each session, right?
@lirui-apache: you are correct. Even though the Catalogs should not be shared between sessions, we might end up sharing pools in the same JVM
Even though the Catalogs should not be shared between sessions, we might end up sharing pools in the same JVM
Thanks @pvary. Is this the intended behavior at the moment? IMO it's better to add some more info to the cache key, similar to how Hadoop maintains FileSystem cache.
As you have a usecase which needs this now, and even at the time of the decision it was clear that it would be needed in the longer term, I would be happy to review the PR if you have time to add this feature. Thanks, Peter
OK, I'll work on a PR for this