apache / apache/shenyu

[BUG] — `ProxySelectorServiceImpl.listByPage`: 4×N+1 per row

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

Description

- severity: High; files: `shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ProxySelectorServiceImpl.java:113-148`; SQL `discovery-rel-sqlmap.xml:54-59`, `discovery-upstream-sqlmap.xml:145-150`
- description: Inside the `forEach` over `proxySelectorMapper.selectByQuery` results, for EACH row the method issues 4 separate mapper calls (`discoveryRelMapper.selectByProxySelectorId`, `discoveryHandlerMapper.selectById`, `discoveryMapper.selectById`, `discoveryUpstreamMapper.selectByDiscoveryHandlerId`). `discovery_rel` has no index on `proxy_selector_id`/`discovery_handler_id`.
- impact: List latency grows linearly with page size × 4 round-trips; seconds on large inventories.
- suggested_fix: Batch-fetch `discovery_rel` by `proxy_selector_id IN (...)` once, then batch the referenced handlers/discoveries/upstreams; or rewrite as a single JOIN.
- confidence: High

---
_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 in shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ProxySelectorServiceImpl.java:113-148 and trace the four mapper calls inside the proxy-selector result loop. Then read discovery-rel-sqlmap.xml:54-59 and discovery-upstream-sqlmap.xml:145-150 to understand the current queries. Done means listByPage avoids the per-row round trips through batching or a JOIN while preserving its results and reducing query growth with page size.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
backend, databases, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.