apache / apache/shenyu

[BUG] AbstractDataChangedListener cache-update methods scan ALL namespaces, not just the changed one

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

Description

## Description
`updateSelectorCache` -> `selectorService.listAll()`; `updateRuleCache` -> `ruleService.listAll()`; `updateAppAuthCache` -> `appAuthService.listAll()`; `updateDiscoveryUpstreamDataCache` -> `discoveryUpstreamService.listAll()`; `updateProxySelectorDataCache` -> `proxySelectorService.listAll()`; `updateAiProxyApiKeyCache` -> `aiProxyApiKeyService.listAll()`. All call the no-arg `listAll()` (ALL namespaces), even though `updateMetaDataCache` correctly uses `listAll(namespaceId)`. So a single selector change in namespace A triggers a full-table scan across all namespaces.

## Location
```
shenyu-admin/.../listener/AbstractDataChangedListener.java:353-395
```

## Impact
Work scales with total system size, not the changed namespace. Wasted DB + CPU proportional to total config on every change.

## Suggested fix
Use `listAllByNamespaceId(...)` for all groups (the methods exist).

## Related existing issue(s)
None

_Identified during the 2026-08-02 audit; full list in [`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in shenyu-admin/.../listener/AbstractDataChangedListener.java:353-395 and compare the affected cache-update methods with updateMetaDataCache. Inspect the existing listAllByNamespaceId(...) methods for each service, then verify that a change in one namespace no longer scans other namespaces and that the affected cache updates still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, database
Issue type
Bug
Difficulty
2/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.