Potential endless loop in jcr install
-------------------------------------

                 Key: SLING-2086
                 URL: https://issues.apache.org/jira/browse/SLING-2086
             Project: Sling
          Issue Type: Bug
          Components: Installer
    Affects Versions: JCR Installer 3.0.4
            Reporter: Carsten Ziegeler
            Assignee: Carsten Ziegeler
             Fix For: JCR Installer 3.1.0


The log looks like the following:
....
12.05.2011 13:03:27.747 *INFO* [JcrInstaller.4] 
org.apache.sling.installer.provider.jcr.impl.WatchedFolder Watching folder 
/libs/mcm/install (priority 100)
12.05.2011 13:03:27.748 *INFO* [JcrInstaller.4] 
org.apache.sling.installer.provider.jcr.impl.WatchedFolder Watching folder 
/libs/crxde/install (priority 100)
12.05.2011 13:03:27.750 *INFO* [JcrInstaller.4] 
org.apache.sling.installer.provider.jcr.impl.WatchedFolder Watching folder 
/apps/geometrixx/install (priority 200)
12.05.2011 13:03:27.752 *INFO* [JcrInstaller.4] 
org.apache.sling.installer.provider.jcr.impl.JcrInstaller Removing resource 
from 
OSGi installer (folder deleted): []
This repeats every 500ms.

The WatchedFolder.rescanTimer is set, but all WatchedFolders.needsScan() return 
false. That leads to the endless loop, since in JcrInstaller.runOneCycle the 
variable scanWf is always true, but for every watched folder needsScan() 
returns 
false. Therefore the rescanTimer is never reset, but updateFoldersList() is 
called every 500ms.

Probably this is caused by the following timing (for example if you delete 
/apps/geometrixx/install):

   1. The background thread executes runOnCycle in JcrInstaller up to line 446 
(at this time the rescanTimer of the WatchedFolders is not set, but 
updateFoldersListTimer.expired() is true)
   2. The event listener thread calls onEvent of the WatchedFolder for 
/apps/geometrixx/install. This leads to a cal of scheduleScan() which itself 
sets the rescanTimer and also sets needScan to true.
   3. Back in the background thread updateFoldersList() is executed (line 453 
of 
JcrInstaller). In this method it detects that one of the watchedFolder have 
been 
removed and therefore indirectly resets the needScan of the WatchedFolder 
/apps/geometrixx/install back to false (line 385). Unfortunately it doesn't 
reset the rescanTimer.
   4. The next time when runOneCycle is executed, the rescanTimer has exired -> 
scanWF is true. Unfortunately every watchedFolder returns false for 
needsScan(). 
Now you are in a loop, because the rescanTimer will not be reset.

The main problem is, that needsScan and rescanTimer.reset/set must always be 
set 
in parallel, but this is not true for the described usecase.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to