[infinispan-issues] [JBoss JIRA] (ISPN-10363) LazyInitializingExecutorService.shutdown() is not thread-safe
Dan Berindei (Jira)
issues at jboss.org
Thu Jun 27 05:54:00 EDT 2019
[ https://issues.jboss.org/browse/ISPN-10363?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13752702#comment-13752702 ]
Dan Berindei commented on ISPN-10363:
-------------------------------------
It was not the missing synchronization after all, as {{executor}} is a volatile field.
The real problem is that {{shutdown()}} does nothing if the executor was not already initialized, so {{initIfNeeded()}} can start an executor even after the component was stopped.
> LazyInitializingExecutorService.shutdown() is not thread-safe
> -------------------------------------------------------------
>
> Key: ISPN-10363
> URL: https://issues.jboss.org/browse/ISPN-10363
> Project: Infinispan
> Issue Type: Bug
> Components: Core, Test Suite - Core
> Affects Versions: 10.0.0.Beta3, 9.4.15.Final
> Reporter: Dan Berindei
> Assignee: Dan Berindei
> Priority: Major
> Labels: testsuite_stability
> Fix For: 10.0.0.Beta4
>
>
> {{LazyInitializingExecutorService.shutdown()}} is not synchronized, so it may miss the executor created on another thread.
> Normally the long time between the first use and stop is long enough for this to be a non-issue, but it does cause random thread leaks in {{PersistenceManagerTest}}:
> {noformat}
> 17:57:06,421 DEBUG (testng-PersistenceManagerTest:[]) [DefaultCacheManager] Started cache manager PersistenceManagerTest-NodeB on null
> 17:57:06,423 INFO (testng-PersistenceManagerTest:[]) [TestSuiteProgress] Test starting: org.infinispan.persistence.PersistenceManagerTest.testProcessAfterStop
> 17:57:06,446 INFO (testng-PersistenceManagerTest:[]) [TestSuiteProgress] Test succeeded: org.infinispan.persistence.PersistenceManagerTest.testProcessAfterStop
> 17:57:06,447 DEBUG (testng-PersistenceManagerTest:[]) [DefaultCacheManager] Stopped cache manager PersistenceManagerTest-NodeB
> 17:58:38,062 WARN (main:[]) [ThreadLeakChecker] Possible leaked thread:
> "async-thread-PersistenceManagerTest-NodeB-p54399-t1" daemon prio=5 tid=0x2ab4c nid=NA waiting
> java.lang.Thread.State: WAITING
> at java.base at 11.0.3/jdk.internal.misc.Unsafe.park(Native Method)
> at java.base at 11.0.3/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
> at java.base at 11.0.3/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2081)
> at java.base at 11.0.3/java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:433)
> at java.base at 11.0.3/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
> at java.base at 11.0.3/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
> at java.base at 11.0.3/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
> at java.base at 11.0.3/java.lang.Thread.run(Thread.java:834)
> {noformat}
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
More information about the infinispan-issues
mailing list