apache / apache/shenyu

[BUG] initPrx busy-spins on lock contention burning CPU

Open Beginner friendly
#6,737 1 comment 0 reactions 0 assignees View on GitHub
plugin: tars priority: medium type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

- severity: Medium
- files: `shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-tars/src/main/java/org/apache/shenyu/plugin/tars/cache/ApplicationConfigCache.java:189-206`
- description: `initPrx` is a `while(true)` loop that calls `tryLockedLoadMetaData(...)` whenever `prxClassCache.get(path)` is null. `tryLockedLoadMetaData` uses `LOCK.tryLock()`; if the lock is held, it returns immediately, leaving `prxClass` null, so the loop re-enters with no `Thread.yield()`/backoff.
- impact: Under concurrent tars metadata registration, worker threads spin-wait (100% CPU) for the duration of ByteBuddy class generation.
- suggested_fix: Acquire the lock blockingly inside the loop, or back off with `Thread.yield()` when `tryLock()` fails.
- confidence: Medium
- related_existing: none

---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/06-medium-tiers.md`](docs/scan2-2026-08-02/06-medium-tiers.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-tars/src/main/java/org/apache/shenyu/plugin/tars/cache/ApplicationConfigCache.java:189-206. Read the initPrx loop together with tryLockedLoadMetaData and observe lock-contention behavior. Done means contention no longer causes a tight CPU-burning loop while TARS metadata and ByteBuddy class generation still complete correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, performance
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.