Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WorkQueueProcessor leaves threads running after forceShutdown() #1142

Closed
elrodro83 opened this issue Mar 24, 2018 · 0 comments
Closed

WorkQueueProcessor leaves threads running after forceShutdown() #1142

elrodro83 opened this issue Mar 24, 2018 · 0 comments
Assignees
Labels
type/bug A general bug
Milestone

Comments

@elrodro83
Copy link

Expected behavior

forceShutdown() completely shutdowns its inner executor, leaving no threads from it running

Actual behavior

One of the WorkQueueProcessor's inner executor threads keeps running after forceShutdown(), even after being interrupted.

Steps to reproduce

This test (copied from TopicProcessorTest into WorkQueuProcessorTest) reproduces the behavior:

	@Test
	public void testForceShutdownAfterShutdown() throws InterruptedException {
		WorkQueueProcessor<String> processor = WorkQueueProcessor.<String>builder()
				.name("processor").bufferSize(4).build();
		Publisher<String> publisher = Flux.fromArray(new String[] { "1", "2", "3", "4", "5" });
		publisher.subscribe(processor);
		
		AssertSubscriber<String> subscriber = AssertSubscriber.create(0);
		processor.subscribe(subscriber);
		
		subscriber.request(1);
		
		Thread.sleep(250);
		
		processor.shutdown();
		
		assertFalse(processor.awaitAndShutdown(Duration.ofMillis(400)));
		
		processor.forceShutdown();
		
		// This assertion fails
		assertTrue(processor.awaitAndShutdown(Duration.ofMillis(400)));
	}

A thread dump taken before the failing assertion, shows just one of the threads still running:

"processor-1" #16 daemon prio=5 os_prio=0 tid=0x00007f56e0680000 nid=0x390b runnable [0x00007f5721c66000]
   java.lang.Thread.State: RUNNABLE
        at sun.misc.Unsafe.park(Native Method)
        at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:312)
        at reactor.core.publisher.WorkQueueProcessor$WorkQueueInner.run(WorkQueueProcessor.java:505)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1129)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:748)

   Locked ownable synchronizers:
        - <0x000000076d598d18> (a java.util.concurrent.ThreadPoolExecutor$Worker)

Reactor Core version

3.2.0.M1

JVM version (e.g. java -version)

java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants