neatHyperTxt-meesho opened a new pull request, #6783:
URL: https://github.com/apache/hive/pull/6783

   ### What changes were proposed in this pull request?
   CachedStore.startCacheUpdateService/stopCacheUpdateService no longer 
synchronize on the CachedStore class monitor. They use a dedicated lock object, 
cacheUpdateMaster is volatile, and startCacheUpdateService has a lock-free fast 
path for the common already-initialized case. A regression test is included: it 
holds the class monitor (as triggerPreWarm does for the entire duration of 
prewarm) and asserts startCacheUpdateService still returns.
   
   ### Why are the changes needed?
   triggerPreWarm() is static synchronized and holds the CachedStore class 
monitor for the whole prewarm. startCacheUpdateService() was also static 
synchronized and is called from setConf() on every RawStore construction — once 
per new HMS worker thread. On a cold-started HMS every incoming RPC therefore 
blocked on that monitor until prewarm completed (~10 minutes on our production 
deployment with 21k cached tables), even though the read paths already fall 
back to the raw store while the cache is cold. Thread dumps show worker threads 
BLOCKED entering startCacheUpdateService. After the fix, RPCs are served from 
the backing DB during prewarm (get_table ~30ms in our tests) and the cache 
takes over once prewarm completes.
   
   ### Does this PR introduce _any_ user-facing change?
   No. The behavior change is that HMS serves requests during CachedStore 
prewarm instead of hanging; no API or config changes.
   
   ### How was this patch tested?
   New unit test 
TestCachedStore#testStartCacheUpdateServiceNotBlockedByPrewarmMonitor — a 
helper thread holds the CachedStore class monitor while another thread calls 
startCacheUpdateService; on the old code the call blocks and the test fails by 
timeout, with the fix it returns immediately. Run with:
   mvn test -pl standalone-metastore/metastore-server -am 
-Dtest='TestCachedStore#testStartCacheUpdateServiceNotBlockedByPrewarmMonitor' 
-Dtest.groups=org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest
   Also verified on a production Hive 4.2.0 deployment: before — zero RPCs 
served during a ~10 minute prewarm; after — RPCs answered in tens of 
milliseconds throughout prewarm.


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to