yym108 opened a new pull request, #11238:
URL: https://github.com/apache/rocketmq/pull/11238
### Which Issue(s) This PR Fixes
- Fixes #9328
### Brief Description
When broker initialization fails before the message store exists, shutdown
attempts to persist delay offsets and throws the reported null-pointer
exception while resolving their path. Resolving the path alone also permits an
empty, uninitialized offset table to overwrite the primary file and its backup.
Resolve the path from the broker's store configuration and allow persistence
only after delay offsets load successfully. Normal loading, slave
synchronization loading and persistence share the same lock; a failed reload
disables persistence until a successful load. Successfully loaded offsets can
still be saved before scheduled delivery starts.
This addresses the shutdown exception and subsequent offset overwrite. It
does not recover files already corrupted by a power interruption or establish
the cause of the original initialization failure.
### How Did You Test This Change?
- 21 tests passed: `BrokerInitializationFailureTest` (9),
`ScheduleMessageServiceTest` (4), `BrokerControllerTest` (5), and
`SlaveSynchronizeTest` (3).
- New regression coverage includes missing/uninitialized stores, invalid
delay levels, offset correction failure, unreadable primary/backup data, failed
reloads, successful normal/slave loads, and repeated shutdown.
- A repeated-shutdown reproduction preserved primary offsets `{1:42}` and
backup offsets `{1:40}` across both shutdowns.
- Validated on macOS ARM64 with Zulu JDK 21; real power-loss behavior and
Windows/Linux execution were not tested.
- Maven's configured Checkstyle/SpotBugs checks and `git diff --check`
passed. Local JDK 21 execution used JaCoCo 0.8.12, Javassist 3.30.2-GA, Byte
Buddy experimental support and JDK module opens, without POM changes.
--
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]