apache / apache/shenyu

[BUG] MetaDataServiceImpl.deleteByIdsAndNamespaceId / enabledByIdsAndNamespaceId missing @Transactional

Open
#6,708 1 comment 0 reactions 0 assignees View on GitHub
admin 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-admin/src/main/java/org/apache/shenyu/admin/service/impl/MetaDataServiceImpl.java:110-136`
- description: `deleteByIdsAndNamespaceId` (110) and `enabledByIdsAndNamespaceId` (124) are not `@Transactional`, unlike `createOrUpdate`/`importData`. `deleteByIdsAndNamespaceId` does select → delete → `publisher.onDeleted`; without a transaction the delete commits before the event. `enabledByIdsAndNamespaceId` mutates the loaded VOs (`setEnabled`) and publishes them via `publisher.onEnabled` — but if the DB update returns 0 rows, it still proceeds to publish the mutated (stale) VOs as if enabled.
- impact: Inconsistent state between DB and sync consumers on enable; events may describe a state that was not persisted.
- suggested_fix: Annotate both methods `@Transactional(rollbackFor = Exception.class)`; gate `publisher.onEnabled` on the actual update count.
- confidence: Medium
- related_existing: none. N2 is the cross-namespace update bug in the same method; this is the transaction/event gap.

---
_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-admin/src/main/java/org/apache/shenyu/admin/service/impl/MetaDataServiceImpl.java:110-136 and compare these methods with createOrUpdate and importData. Confirm that deleteByIdsAndNamespaceId and enabledByIdsAndNamespaceId use the required transaction behavior, and that onEnabled is not published when the database update affects zero rows.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.