[BUG] DiscoveryUpstreamServiceImpl.importData(namespace,...) missing @Transactional (partial commit on failure)
- 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/DiscoveryUpstreamServiceImpl.java:292-331`
- description: The single-arg `importData(List)` at line 255 is annotated `@Transactional(rollbackFor = Exception.class)`, but the namespace-scoped overload at line 293 is **not** (verified: grep shows no `@Transactional` between line 255 and 293). The method loops, inserts rows one-by-one, and remaps `discoveryHandlerId` via `context.getDiscoveryHandlerIdMapping()`. If a mid-loop insert fails, earlier inserts are already committed with no rollback. `ConfigsServiceImpl.configsImport` wraps the call with no outer transaction.
- impact: Partial import leaves orphaned discovery-upstream rows pointing at non-existent handlers; retrying the import then double-counts or fails differently.
- suggested_fix: Add `@Transactional(rollbackFor = Exception.class)` to the namespace overload, consistent with the single-arg version.
- confidence: High
- related_existing: none. The reported upstream items are N+1/listAll concerns, not this transaction gap.
---
_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
Read `DiscoveryUpstreamServiceImpl.java` around lines 255 and 292–331, comparing the annotations on the two `importData` overloads. Check how `ConfigsServiceImpl.configsImport` calls the namespace-scoped overload and review its tests for import failures. Done means a mid-loop failure rolls back earlier inserts as well as the failing import.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100