GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — SingleThreadEventExecutor: do not start threads when shutting down never-used executors by arimu1 · Pull Request #17183 · netty/netty

SingleThreadEventExecutor: do not start threads when shutting down never-used executors #17183

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.

Sign up for GitHub

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

Closed
arimu1 wants to merge 13 commits into netty:4.2 from arimu1:fix/17135-shutdown-unstarted-threads

Uh oh!

There was an error while loading. Please reload this page.

Closed

SingleThreadEventExecutor: do not start threads when shutting down never-used executors #17183

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
fb206da
SingleThreadEventExecutor: skip thread start on unused shutdown
arimu1 Aug 1, 2026
59c7f47
chore: re-trigger CI after environmental OOM/KQueue failures
arimu1 Aug 2, 2026
2aa4f08
SingleThreadEventExecutor: fix never-started shutdown for IoEventLoop
arimu1 Aug 3, 2026
a9a6d4a
Document never-started group quiet-period tradeoff for #17135
arimu1 Aug 4, 2026
d0ed2ad
SingleThreadEventExecutor: honor quiet period for never-started children
arimu1 Aug 4, 2026
8186b96
IoUringIoHandler: destroy never-initialized rings without io_uring_enter
arimu1 Aug 12, 2026
4494123
Address review: drop MultithreadEventExecutorGroup hunk; remove unuse…
arimu1 Aug 12, 2026
3373ed5
SingleThreadEventExecutor: fix execute/suspend race stranding tasks
arimu1 Aug 21, 2026
c719d82
SingleThreadEventExecutor: restart worker after suspend wind-down if …
arimu1 Aug 21, 2026
5c5bf0f
Merge branch '4.2' into fix/17135-shutdown-unstarted-threads
normanmaurer Aug 25, 2026
68879cd
Merge branch '4.2' into fix/17135-shutdown-unstarted-threads
arimu1 Oct 3, 2026
fae4cca
SingleThreadEventExecutor: reject tasks that race never-started termi…
arimu1 Oct 3, 2026
378d158
Merge branch '4.2' into fix/17135-shutdown-unstarted-threads
chrisvest Oct 19, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
Document never-started group quiet-period tradeoff for #17135
Never-started MultithreadEventExecutorGroup children still force
quietPeriod=0 so unused workers are not started. Document that late
execute after group.shutdownGracefully(nonZero) is rejected on those
children, and add a regression test covering that contract.
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@arimu1
arimu1 committed Aug 21, 2026
commit a9a6d4a6072d86b52f6fe623fe5ae0d3825b1d35

There are no files selected for viewing

6 changes: 6 additions & 0 deletions 6 common/src/main/java/io/netty/util/concurrent/MultithreadEventExecutorGroup.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit uni
// SingleThreadEventExecutor can terminate without creating a worker thread that
// would only exit immediately (#17135). Children that already run still honor
// the caller's quietPeriod/timeout.
//
// Consequence: unused children may reach TERMINATED before the caller's quiet
// period elapses. Tasks submitted via next()/execute after that are rejected
// on those children — accepting them would require starting the worker, which
// is exactly what this path avoids. Already-started children keep full quiet-
// period task acceptance.
if (l instanceof SingleThreadEventExecutor
&& ((SingleThreadEventExecutor) l).isNeverStarted()) {
l.shutdownGracefully(0, 0, unit);
Expand Down
47 changes: 47 additions & 0 deletions 47 common/src/test/java/io/netty/util/concurrent/SingleThreadEventExecutorTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,53 @@ public Thread newThread(@NotNull Runnable r) {
}
}

/**
* Never-started MultithreadEventExecutorGroup children force quietPeriod=0 on shutdown
* (#17135). After that, execute on the group must not start workers — it rejects.
* Already-started children still honor the caller's quiet period.
*/
@Test
@Timeout(value = 10, unit = TimeUnit.SECONDS)
public void testGroupShutdownNonZeroQuietPeriodRejectsExecuteOnNeverStartedChildren()
throws Exception {
final AtomicInteger threadsCreated = new AtomicInteger();
ThreadFactory threadFactory = new ThreadFactory() {
private final AtomicInteger idx = new AtomicInteger();
@Override
public Thread newThread(@NotNull Runnable r) {
threadsCreated.incrementAndGet();
return new Thread(r, "group-quiet-" + idx.getAndIncrement());
}
};

final int nThreads = 8;
DefaultEventExecutorGroup group = new DefaultEventExecutorGroup(nThreads, threadFactory);
try {
assertEquals(0, threadsCreated.get());
// Non-zero quiet period on the group; unused children still terminate immediately.
group.shutdownGracefully(100, 100, TimeUnit.MILLISECONDS);
// Give never-started children time to reach TERMINATED via the 0,0 path.
Thread.sleep(20);
assertThrows(RejectedExecutionException.class, new Executable() {
@Override
public void execute() {
group.execute(new Runnable() {
@Override
public void run() {
// must not run — children already terminated without workers
}
});
}
});
assertEquals(0, threadsCreated.get(),
"execute after group shutdown must not start never-used children");
group.terminationFuture().syncUninterruptibly();
assertTrue(group.isTerminated());
} finally {
group.shutdownGracefully();
}
}

/**
* A never-started executor that receives a task before shutdown still starts a thread and runs it.
*/
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.