iceberg icon indicating copy to clipboard operation
iceberg copied to clipboard

Should ClientPool consider UGI when reusing a connection?

Open lirui-apache opened this issue 4 years ago • 7 comments

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.

lirui-apache avatar Oct 28 '22 04:10 lirui-apache

@pvary is this something that you could potentially help answering?

nastra avatar Oct 28 '22 10:10 nastra

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.

pvary avatar Nov 07 '22 14:11 pvary

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 avatar Nov 08 '22 06:11 lirui-apache

@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

pvary avatar Nov 08 '22 08:11 pvary

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.

lirui-apache avatar Nov 08 '22 09:11 lirui-apache

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

pvary avatar Nov 08 '22 12:11 pvary

OK, I'll work on a PR for this

lirui-apache avatar Nov 09 '22 03:11 lirui-apache