Skip to content

[ISSUE #9328] Preserve delay offsets when broker initialization fails - #11238

Open
yym108 wants to merge 1 commit into
apache:developfrom
yym108:fix/issue-9328-preserve-delay-offsets
Open

yym108 wants to merge 1 commit into
apache:developfrom
yym108:fix/issue-9328-preserve-delay-offsets

Conversation

@yym108

@yym108 yym108 commented Sep 26, 2026

Copy link
Copy Markdown

Which Issue(s) This PR Fixes

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Bug title

1 participant