This is an automatically generated e-mail. To reply, visit:

Review request for Ambari, DIPAYAN BHOWMICK, Jonathan Hurley, Mahadev Konar, 
and Rohit Choudhary.

Bugs: AMBARI-16146

Repository: ambari


Earlier : The synchronized UserLocalConnection.initialValue() was taking time 
to get hive connection and all other threads were blocking to get inside this 
synchronized block.

In this patch : 
1. Removed synchronized from UserLocalConnection.initialValue() and from 
2. Introduced locking on specific key and not the complete method. Key would be 
like Connection_INSTANCE-NAME:USER-NAME. So threads for other keys will not get 
into contension with this lock. This avoids blocking of thread that do not want 
to initialize different keys.
3. Used tryLock and fail with exception if lock cannot be obtained immediately. 
This avoids blocking of threads that want to initialize same key as one key 
should be initialized only once.
4. corrected synchronization at several places inside UserLocal class.



Diff: https://reviews.apache.org/r/47305/diff/


Manual testing done by introducing Thread.sleep in 
UserLocalConnection.initialValue() and creating more requests with following 
combinations and logs.
0. first thread for connection + user + view combination obtains the lock and 
goes inside UserLocalConnection.initialValue() and sleeps
1. same user, same hive view requests for connections fails to get lock with 
2. same user, different hive view -- if first request gets new lock and goes 
inside UserLocalConnection.initialValue().
3. same user, different hive view -- if connection created once then works 
fine. does not block.
4. different user, same view -- gets new lock and goes inside 
UserLocalConnection.initialValue() if first, else works fine.
5. different user, different view -- works as 4.
6. once the first thread come out of initialValue(), rest threads don't try to 
get lock and don't fail either, works fine.


Nitiraj Rathore

Reply via email to