aparnasuresh85 commented on code in PR #2611:
URL: https://github.com/apache/solr/pull/2611#discussion_r1707659461


##########
solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/CollectionPropertiesZkStateReader.java:
##########
@@ -300,10 +313,11 @@ private VersionedCollectionProps 
fetchCollectionProperties(String collection, Wa
       throws KeeperException, InterruptedException {
     final String znodePath = getCollectionPropsPath(collection);
     // lazy init cache cleaner once we know someone is using collection 
properties.
-    if (collectionPropsCacheCleaner == null) {
-      synchronized (zkStateReader.getUpdateLock()) { // Double-checked locking
-        if (collectionPropsCacheCleaner == null) {
-          collectionPropsCacheCleaner = notifications.submit(new 
CacheCleaner());
+    if (cacheCleanerThread == null) {
+      synchronized (this) {
+        if (cacheCleanerThread == null) {

Review Comment:
   I tried this. Using the following code, where cacheCleanerExecutor is 
defined as 
   ```
    private final ScheduledExecutorService cacheCleanerExecutor =
         Executors.newSingleThreadScheduledExecutor(new 
SolrNamedThreadFactory("cacheCleaner"));
   
   ```:
   
   and then used in `fetchCollectionProperties()` as follows:
   ```
    if (cacheCleanerExecutor.isShutdown()) {
         synchronized (this) {
           if (cacheCleanerExecutor.isShutdown()) {
             cacheCleanerExecutor.scheduleAtFixedRate(new CacheCleaner(), 0, 1, 
TimeUnit.MINUTES);
           }
         }
     }
   ```
   
   I ran a Junit test and set a breakpoint at 
`cacheCleanerExecutor.scheduleAtFixedRate`, it is never hit. 
   
   But when I changed to using a state variable like the following, I see the 
breakpoint being hit to schedule the cacheCleaner thread
   ```
   if (collectionPropsCacheCleanerInitialized.compareAndSet(false, true)) {
         synchronized (this) {
             cacheCleanerExecutor.scheduleAtFixedRate(new CacheCleaner(), 0, 1, 
TimeUnit.MINUTES);
         }
    }
   ```
   
   



-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to