elephone-184 opened a new pull request, #4973:
URL: https://github.com/apache/rocketmq-dashboard/pull/4973

   ## What is the purpose of the change
   
   When administrators downscale topic partition queues (e.g. from 16 queues 
down to 8 queues), any queues with `queueId >= targetQueueNum` are immediately 
cut off from client publishing and routing. If these truncated queues still 
hold unconsumed messages, those messages become silently stranded until queues 
are re-expanded, potentially causing data lag, consumer starvation, or business 
SLA violations.
   
   This PR introduces an automated `TopicQueueShrinkGuardEngine`:
   1. `TopicShrinkPrecheckVO`: Domain report capturing `safeToShrink`, total 
unconsumed messages on truncated queues, per-queue risk ratings (`CRITICAL`, 
`HIGH`, `LOW`), and step-by-step graceful migration guidance.
   2. `TopicQueueShrinkGuardEngine`: Cross-references live `TopicQueueStatsVO` 
min/max offsets across all brokers against the proposed `targetQueueNum`. It 
detects stranded backlog, computes risk severity, and recommends an automated 
3-phase drainage pipeline (writeQueue reduction -> consumer catch-up -> 
readQueue finalization).
   3. Controller & Service wiring: Integrates through 
`MetadataService.precheckTopicQueueShrink` and exposes 
`/api/topics/{name}/precheck-shrink` in `TopicController`.
   4. Comprehensive unit test suite covering expansion no-ops, zero-backlog 
safe shrinks, dangerous backlog detection across multiple brokers, and 
service/controller tests.
   
   ## Brief changelog
   
   - Add `TopicShrinkPrecheckVO.java` domain model.
   - Add `TopicQueueShrinkGuardEngine.java` evaluation logic.
   - Add `precheckTopicQueueShrink` in `MetadataService` and 
`/api/topics/{name}/precheck-shrink` in `TopicController`.
   - Add `TopicQueueShrinkGuardEngineTest.java` and expand 
`MetadataServiceTest.java` and `TopicControllerTest.java`.
   
   ## Verifying this change
   
   - `TopicQueueShrinkGuardEngineTest`: verifies expansion handling, invalid 
queue counts, zero backlog scenarios, and multi-broker queue truncation risks.
   - `MetadataServiceTest`: verifies integration with topic metadata resolution.
   - `TopicControllerTest`: verifies `/api/topics/{name}/precheck-shrink` REST 
endpoint mapping.


-- 
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]

Reply via email to