[BUG] DiscoveryUpstreamServiceImpl.createOrUpdate missing @Transactional (DB write + external sync partial-failure)
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
- severity: Medium
- files: `shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/DiscoveryUpstreamServiceImpl.java:101-106, 205-223`
- description: `createOrUpdate` (public, no `@Transactional`) dispatches to private `create`/`update`, each of which does `mapper.insert`/`update` and then `fetchAll(...)` (which calls `discoveryProcessor.changeUpstream` — an external/discovery sync side-effect). If `fetchAll`/`changeUpstream` throws, the row write is already committed. `DiscoveryUpstreamController.createDiscoveryUpstreamList` compounds this by looping `createOrUpdate` with no transaction wrapper.
- impact: Upstream rows persist in the DB while the discovery processor was never updated; gateway and admin disagree about upstream state.
- suggested_fix: Add `@Transactional(rollbackFor = Exception.class)` to `createOrUpdate` and wrap the batch endpoint.
- 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
Read DiscoveryUpstreamServiceImpl.java at lines 101-106 and 205-223, then inspect DiscoveryUpstreamController.createDiscoveryUpstreamList and existing transaction tests or patterns. Exercise failures from fetchAll or discoveryProcessor.changeUpstream, including the batch path, and verify the resulting database and discovery state match the intended behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, database, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100