-
Improvement
-
Resolution: Fixed
-
Major
-
None
-
-
2.1200.v4b_a_3da_2eb_db_4
The Branch API has a synchronized method to access the ProjectFactory of a Multibranch project jenkins.branch.MultiBranchProject.getProjectFactory:
That method is used in many scenario and that includes from hudson.model.AbstractItem.getRootDir through the ChildNameGenerator:
at jenkins.branch.MultiBranchProject.getProjectFactory(MultiBranchProject.java:343)
### Above call has no need to synchronize, the value is guaranteed to be non-null.
at jenkins.branch.MultiBranchProjectDescriptor$ChildNameGeneratorImpl.dirNameFromItem(MultiBranchProjectDescriptor.java:244)
at jenkins.branch.MultiBranchProjectDescriptor$ChildNameGeneratorImpl.dirNameFromItem(MultiBranchProjectDescriptor.java:222)
at com.cloudbees.hudson.plugins.folder.ChildNameGenerator.dirName(ChildNameGenerator.java:198)
at com.cloudbees.hudson.plugins.folder.AbstractFolder.getRootDirFor(AbstractFolder.java:538)
at jenkins.branch.MultiBranchProject.getRootDirFor(MultiBranchProject.java:870)
at jenkins.branch.MultiBranchProject.getRootDirFor(MultiBranchProject.java:130)
at hudson.model.AbstractItem.getRootDir(AbstractItem.java:201)
This can cause some contention and deadlocks in scenario where a process loops through multibranch children (linked issues) or items are loaded / reloaded. Though most of the time the locking is not necessary since a ProjectFactory is not often updated..
The point being that we expect the ProjectFactory to be initialized once and that's when we need synchronization. dnusbaum mentioned that double-checked locking would be better suited here by for example making the field volatile and and only synchronize on this when the field is being initialized.
- relates to
-
JENKINS-72678 Thread Deadlock during GitHub Organization Scan and WeatherColumn
- Open
-
JENKINS-73715 Deadlock between Queue.maintain and BranchIndexing
- Closed
- links to