enkilee opened a new pull request, #6313:
URL: https://github.com/apache/rocketmq-dashboard/pull/6313
<!-- Make sure the base branch is `master`: that is the RocketMQ Studio
trunk. -->
### Which Issue(s) This PR Fixes
<!-- Link the issue with a keyword so it closes on merge. Trivial fixes need
no issue.
https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
-->
- Fixes #<issue-id>
### Brief Description
<!-- What changes and why. Keep it short — the diff already shows how. -->
```
`AlertService.acknowledgeAlert` performed two writes — marking the alert
row acknowledged, then transitioning the active rule state from FIRING to
ACKED — without a transaction, so the two statements auto-committed
independently. When the state transition failed (database exception, dead
lock, connection loss), the alert row was already acknowledged while its
state stayed FIRING: the `NativeAlertProcessor` kept evaluating the rule
and sending REMINDER notifications for an alert the user had already
confirmed, and the inconsistency was permanent — no later step repairs it.
Every other multi-write method in `AlertService` already carries
`@Transactional` for the same reason (`updateRule`, `toggleRule`,
`deleteRule`, `bulkToggleRules`, `bulkDeleteRules`, `clearAcknowledged`).
`acknowledgeAlert` was the lone exception.
Fix: add `@Transactional` to `acknowledgeAlert`, so the alert-row update
and the state transition commit or roll back together.
Test: `AlertAcknowledgeTransactionTest` (dev profile, H2 fed by
classpath:db/schema.sql, `AlertStateRepository` injected as a failing
`@MockitoBean`) asserts through a `JdbcTemplate` probe row that a
state-transition failure rolls back the alert-row write, and that a
successful acknowledgement commits it. Mutation-checked: removing the
`@Transactional` annotation reddens the rollback case.
```
## Changed files
-
`server/src/main/java/org/apache/rocketmq/studio/ops/alert/AlertService.java`
(+8 lines: `@Transactional` annotation + Javadoc on `acknowledgeAlert`)
-
`server/src/test/java/org/apache/rocketmq/studio/ops/alert/AlertAcknowledgeTransactionTest.java`
(new, +104 lines: transaction rollback integration test)
```
`AlertService.acknowledgeAlert` performed two writes — marking the alert
row acknowledged, then transitioning the active rule state from FIRING to
ACKED — without a transaction, so the two statements auto-committed
independently. When the state transition failed (database exception, dead
lock, connection loss), the alert row was already acknowledged while its
state stayed FIRING: the `NativeAlertProcessor` kept evaluating the rule
and sending REMINDER notifications for an alert the user had already
confirmed, and the inconsistency was permanent — no later step repairs it.
Every other multi-write method in `AlertService` already carries
`@Transactional` for the same reason (`updateRule`, `toggleRule`,
`deleteRule`, `bulkToggleRules`, `bulkDeleteRules`, `clearAcknowledged`).
`acknowledgeAlert` was the lone exception.
Fix: add `@Transactional` to `acknowledgeAlert`, so the alert-row update
and the state transition commit or roll back together.
Test: `AlertAcknowledgeTransactionTest` (dev profile, H2 fed by
classpath:db/schema.sql, `AlertStateRepository` injected as a failing
`@MockitoBean`) asserts through a `JdbcTemplate` probe row that a
state-transition failure rolls back the alert-row write, and that a
successful acknowledgement commits it. Mutation-checked: removing the
`@Transactional` annotation reddens the rollback case.
```
## Changed files
-
`server/src/main/java/org/apache/rocketmq/studio/ops/alert/AlertService.java`
(+8 lines: `@Transactional` annotation + Javadoc on `acknowledgeAlert`)
-
`server/src/test/java/org/apache/rocketmq/studio/ops/alert/AlertAcknowledgeTransactionTest.java`
(new, +104 lines: transaction rollback integration test)
-
### How Did You Test This Change?
<!-- Paste the commands you ran and what they printed. Typical verification:
backend `cd server && mvn -B -ntp test` (integration tests need
MySQL 8, see CONTRIBUTING.md)
frontend `cd web && npm test && npm run lint && npm run build`
A pull request with no verification will not be merged. -->
### Checklist
- [ ] One coherent change; unrelated modifications are not bundled in
- [ ] Commit subject follows Conventional Commits (`feat:` / `fix:` /
`refactor:` / `chore:` / `docs:` / `perf:`)
- [ ] Tests added or updated for non-trivial changes, test methods named
`...Test`
- [ ] New UI text has both Chinese and English entries under `web/src/i18n/`
- [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks)
- [ ] New source files carry the ASF license header
- [ ] Documentation touched where behaviour changed (README / `docs/` /
in-app help)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]