btlqql opened a new pull request, #5320:
URL: https://github.com/apache/rocketmq-dashboard/pull/5320
### Which Issue(s) This PR Fixes
- Fixes #5290
### Brief Description
`RocketMQAdminClientImpl.doPreviewResetOffset`
(server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQAdminClientImpl.java:958)
called `admin.examineConsumeStats(name)` first and, when that failed with
`CONSUMER_NOT_ONLINE`, returned `emptyResetOffsetPreview(...)` — i.e.
`allowReset=false`, `queueCount=0` and the warning "Consumer group is not
online and no consume offset data is available". The 确认重置 button is gated on
`allowReset`, so a stopped (but backlogged) group could never be reset through
the UI, although the apply path calls `resetOffsetNew`, which resolves the
target offsets from the topic route and applies them to an offline group.
The fix keeps the stats-based preview when the broker reports consume stats,
and otherwise previews the reset the way `resetOffsetNew` performs it: the read
queues are enumerated from `TopicRouteData` (`readQueueNums` per broker) and
every target offset is resolved with `searchOffset`/`minOffset`/`maxOffset`, so
the dialog shows the same per-queue impact and enables the reset. Because the
broker does not report the committed consumer offsets of an offline group,
those offsets (and the resulting current lag / delta) are reported as unknown
instead of as fabricated zeroes, and the preview carries an extra warning
naming the group. The two other `isConsumerNotOnline` conditions (`%RETRY%`
route missing, broadcast group with an empty offset table) keep the previous
empty preview.
### How Did You Test This Change?
New test
`RocketMQAdminClientImplTest#previewResetOffsetShouldFallBackToTheTopicRouteForAnOfflineGroup`
makes `examineConsumeStats("cg-orders")` throw
`MQBrokerException(ResponseCode.CONSUMER_NOT_ONLINE)`, gives the topic `orders`
a route with two read queues on `broker-a`, and asserts the preview is
applicable per queue (target offsets 80 and 300 after clamping the second
queue's `searchOffset` of 500 to its `maxOffset`), with unknown committed
offsets and the offline warning.
Red run on the unmodified tree:
```
$ cd server && mvn -B -ntp test -Dtest=RocketMQAdminClientImplTest
[ERROR]
RocketMQAdminClientImplTest.previewResetOffsetShouldFallBackToTheTopicRouteForAnOfflineGroup
-- Time elapsed: 0.310 s <<< FAILURE!
org.opentest4j.AssertionFailedError:
Expecting value to be true but was false
at
...RocketMQAdminClientImplTest.previewResetOffsetShouldFallBackToTheTopicRouteForAnOfflineGroup(RocketMQAdminClientImplTest.java:585)
[ERROR] Tests run: 81, Failures: 1, Errors: 0, Skipped: 0
[INFO] BUILD FAILURE
```
Green run after the fix (same command, same test class):
```
$ cd server && mvn -B -ntp test -Dtest=RocketMQAdminClientImplTest
[INFO] Tests run: 81, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
5.375 s -- in
org.apache.rocketmq.studio.provider.apache.RocketMQAdminClientImplTest
[INFO] Tests run: 81, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
```
`mvn` also runs checkstyle at `validate`; both runs report `You have 0
Checkstyle violations.`
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits
- [x] Tests added or updated for non-trivial changes
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
— not applicable: no UI text was added or changed, the preview warning is a
server payload string like the existing ones
- [x] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks) — no new package or layer dependency; the change stays inside
`provider/apache`
- [x] New source files carry the ASF license header — no new source file
- [x] Documentation touched where behaviour changed (README / `docs/` /
in-app help) — not applicable: the endpoint contract
(`ResetConsumerOffsetPreviewVO`) is unchanged, only its values for offline
groups; `docs/api-spec.md` is owned by another change
--
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]