Bug 578204 - Livelock in OverflowingLRUCache.privateRemoveEntry()
Summary: Livelock in OverflowingLRUCache.privateRemoveEntry()
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: API Tools (show other bugs)
Version: 4.22   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 4.23 M2   Edit
Assignee: Andrey Loskutov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-13 10:57 EST by Andrey Loskutov CLA
Modified: 2022-01-18 02:23 EST (History)
0 users

See Also:


Attachments
Screenshot from VisiualVM (247.46 KB, image/png)
2022-01-13 10:57 EST, Andrey Loskutov CLA
no flags Details
VisualVM snapshot (27.11 KB, application/octet-stream)
2022-01-13 10:57 EST, Andrey Loskutov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Loskutov CLA 2022-01-13 10:57:02 EST
Created attachment 287830 [details]
Screenshot from VisiualVM

Looks like I've run into a MT issue in OverflowingLRUCache with changes to bug 576736. I see now ~20 jobs busy hanging in the privateRemoveEntry() method, and that never ends. 
This is not a deadlock, but seem to be a problem with the while loop inside the OverflowingLRUCache.privateRemoveEntry() method.

The jobs seem to repeat same operation again and again, basically with same stack.
There were already similar bugs reported, see bug 175531 and bug 128000, I believe the fix was not in the OverflowingLRUCache but in the clients, which makes me wonder if the fixes were done in the right place.

"Worker-2547: Performing API Analysis" #8641 prio=5 os_prio=0 cpu=9594.08ms elapsed=289.01s tid=0x00007ffd74183000 nid=0x6a50 runnable  [0x00007ffdbc8fb000]
   java.lang.Thread.State: RUNNABLE
	at java.util.Hashtable.get(java.base@11.0.10/Hashtable.java:379)
	- locked <0x0000000501900f90> (a java.util.Hashtable)
	at org.eclipse.jdt.internal.core.OverflowingLRUCache.privateRemoveEntry(OverflowingLRUCache.java:293)
	at org.eclipse.jdt.internal.core.OverflowingLRUCache.makeSpace(OverflowingLRUCache.java:190)
	at org.eclipse.jdt.internal.core.OverflowingLRUCache.put(OverflowingLRUCache.java:351)
	at org.eclipse.pde.api.tools.internal.model.ApiModelCache.cacheElementInfo(ApiModelCache.java:164)
	at org.eclipse.pde.api.tools.internal.model.AbstractApiTypeRoot.getStructure(AbstractApiTypeRoot.java:74)
	at org.eclipse.pde.api.tools.internal.provisional.comparator.ApiComparator$2.visit(ApiComparator.java:665)
	at org.eclipse.pde.api.tools.internal.model.ArchiveApiTypeContainer.accept(ArchiveApiTypeContainer.java:198)
	at org.eclipse.pde.api.tools.internal.provisional.comparator.ApiComparator.internalCompare(ApiComparator.java:659)
	at org.eclipse.pde.api.tools.internal.provisional.comparator.ApiComparator.compare(ApiComparator.java:289)
	at org.eclipse.pde.api.tools.internal.provisional.comparator.ApiComparator.compare(ApiComparator.java:315)
	at org.eclipse.pde.api.tools.internal.builder.BaseApiAnalyzer.checkCompatibility(BaseApiAnalyzer.java:1504)
	at org.eclipse.pde.api.tools.internal.builder.BaseApiAnalyzer.analyzeComponent(BaseApiAnalyzer.java:269)
	at org.eclipse.pde.api.tools.internal.builder.ApiAnalysisBuilder.buildAll(ApiAnalysisBuilder.java:923)
	at org.eclipse.pde.api.tools.internal.builder.ApiAnalysisBuilder.work(ApiAnalysisBuilder.java:427)
	at org.eclipse.pde.api.tools.internal.builder.ApiAnalysisBuilder$ApiAnalysisJob.run(ApiAnalysisBuilder.java:579)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Comment 1 Andrey Loskutov CLA 2022-01-13 10:57:37 EST
Created attachment 287831 [details]
VisualVM snapshot
Comment 2 Andrey Loskutov CLA 2022-01-13 11:09:51 EST
OK, reading javadoc on the base class LRUCache one can see following:

 * <p>This implementation is NOT thread-safe.  Synchronization wrappers would
 * have to be added to ensure atomic insertions and deletions from the cache.

So the bug is in PDE that should make sure access of the cache is MT safe.
Comment 3 Eclipse Genie CLA 2022-01-13 12:11:14 EST
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189606
Comment 5 Eclipse Genie CLA 2022-01-14 04:01:11 EST
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189627
Comment 7 Andrey Loskutov CLA 2022-01-17 07:12:50 EST
Seem to work now with I20220116-1800, I don't see API jobs hanging anymore.