apache / apache/shenyu

[BUG] TagServiceImpl.update is not transactional yet performs recursive multi-row updates before updating the parent

Open Beginner friendly
#6,552 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

## Description
`update` is not annotated `@Transactional`. It calls `updateSubTags(tagDTO)` which loads all tags, rebuilds the `ext` chain, and recursively calls `tagMapper.updateByPrimaryKey(tagDO)` for every descendant, *then* updates the parent itself. If the parent update (or any descendant update) fails, the descendants that already succeeded are left with `ext` values computed from the new parent while the parent row still holds the old values — a torn tree.

## Location
```
shenyu-admin/.../service/impl/TagServiceImpl.java:86-92 (recursion at :156-193)
```

## Impact
Sub-tree `ext` metadata becomes inconsistent with the parent; some children updated, parent/others not, with no rollback.

## Suggested fix
Annotate `update` with `@Transactional(rollbackFor = Exception.class)`.

## Related existing issue(s)
#6520 is a different NPE on missing `parentTagId`; not a dup.

_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/.../service/impl/TagServiceImpl.java at update (lines 86-92), then trace the recursive updateSubTags path at lines 156-193. Check how the multi-row updates behave when a descendant or the parent update fails; done means the whole update rolls back instead of leaving inconsistent ext values.

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-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.