apache / apache/shenyu

[BUG] AbstractLogCollector.start() leaks thread pool and consumer thread on repeated calls

Open
#6,655 2 comments 0 reactions 0 assignees View on GitHub
priority: high type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

- severity: High
- files: `shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/collector/AbstractLogCollector.java:72-83`
- description: `start()` creates a new `ShenyuThreadPoolExecutor` as a local variable (never stored as a field) and submits `this::consume` to it. No `started.compareAndSet` guard; does not shut down any previously created executor. `AbstractLogPluginDataHandler.handlerPlugin()` calls `logCollector().start()` on every config change. Each call leaks the old pool and starts a competing consumer on the same `bufferQueue`.
- impact: On every logging config refresh, a new thread pool and consumer leak; competing consumers cause duplicate log processing and thread exhaustion.
- suggested_fix: Store executor as a field; shut it down at the start of `start()`; guard with `started.compareAndSet(false, true)`.
- confidence: High
- related_existing: none

---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/00-consolidated-critical-high.md`](docs/scan2-2026-08-02/00-consolidated-critical-high.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with AbstractLogCollector.java:72-83 and trace the logCollector().start() call from AbstractLogPluginDataHandler.handlerPlugin(). Confirm how repeated configuration changes create competing consumers and retain executors. Done means repeated starts no longer leak pools or consumer threads, duplicate processing is prevented, and the existing logging behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
observability-sre
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.