Skip to content

feat: crash recovery and graceful shutdown (story 1.9)#9

Closed
vieiralucas wants to merge 0 commit intofeat/1-8-message-acknowledgmentfrom
feat/1-9-crash-recovery-graceful-shutdown
Closed

feat: crash recovery and graceful shutdown (story 1.9)#9
vieiralucas wants to merge 0 commit intofeat/1-8-message-acknowledgmentfrom
feat/1-9-crash-recovery-graceful-shutdown

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Feb 11, 2026

Summary

  • Implement crash recovery that scans for expired leases on startup and reclaims them so messages re-enter the ready pool
  • Add WAL flush on graceful shutdown to ensure all writes are durable before exit
  • Add parse_lease_expiry_key() for extracting queue_id and msg_id from expiry keys
  • Add flush() method to Storage trait, implemented via flush_wal(true) in RocksDB

Test plan

  • recovery_preserves_messages_after_restart — enqueue 5 messages, restart scheduler, verify all delivered
  • recovery_reclaims_expired_leases — create expired lease, restart, verify reclaimed and message delivered to consumer
  • recovery_preserves_queue_definitions — create 3 queues, restart, verify all present
  • shutdown_flushes_wal — enqueue, shutdown, reopen storage from disk, verify data survived
  • All 48 tests pass, clippy clean, fmt clean

Summary by cubic

Adds crash recovery and graceful shutdown: on startup we reclaim expired leases so messages re-enter the ready pool; on shutdown we flush the RocksDB WAL for durability. Completes Story 1.9 and closes Epic 1.

  • New Features
    • Run recovery before the main loop; log reclaimed count and queue summary.
    • Scan lease_expiry <= now; atomically delete lease and expiry.
    • Storage::flush added; RocksDB uses flush_wal(true) on shutdown.
    • Added parse_lease_expiry_key() to extract queue_id and msg_id.

Written for commit ac33d31. Summary will update on new commits.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

@vieiralucas vieiralucas force-pushed the feat/1-8-message-acknowledgment branch from f13c613 to 1e1eb19 Compare February 11, 2026 12:13
@vieiralucas vieiralucas force-pushed the feat/1-9-crash-recovery-graceful-shutdown branch from dd6a7e4 to 26ab66e Compare February 11, 2026 12:14
@vieiralucas vieiralucas force-pushed the feat/1-8-message-acknowledgment branch from 1e1eb19 to 73640dd Compare February 11, 2026 13:18
@vieiralucas vieiralucas force-pushed the feat/1-9-crash-recovery-graceful-shutdown branch from 26ab66e to 955b3f4 Compare February 11, 2026 13:18
@vieiralucas vieiralucas force-pushed the feat/1-8-message-acknowledgment branch from 73640dd to 1b962e3 Compare February 11, 2026 16:10
@vieiralucas vieiralucas force-pushed the feat/1-9-crash-recovery-graceful-shutdown branch 3 times, most recently from e4093e0 to f50183e Compare February 11, 2026 16:18
@vieiralucas vieiralucas force-pushed the feat/1-8-message-acknowledgment branch 2 times, most recently from 9dd102a to e695dd0 Compare February 11, 2026 16:21
@vieiralucas vieiralucas force-pushed the feat/1-9-crash-recovery-graceful-shutdown branch from f50183e to 23296cd Compare February 11, 2026 16:21
@vieiralucas vieiralucas force-pushed the feat/1-8-message-acknowledgment branch from e695dd0 to 7ccb2f4 Compare February 11, 2026 16:23
@vieiralucas vieiralucas force-pushed the feat/1-9-crash-recovery-graceful-shutdown branch 2 times, most recently from 2155453 to c26f8c2 Compare February 11, 2026 21:00
@vieiralucas vieiralucas force-pushed the feat/1-8-message-acknowledgment branch 2 times, most recently from 7537a50 to d794ecd Compare February 11, 2026 21:03
@vieiralucas vieiralucas force-pushed the feat/1-9-crash-recovery-graceful-shutdown branch from c26f8c2 to 0127a98 Compare February 11, 2026 21:03
@vieiralucas vieiralucas force-pushed the feat/1-8-message-acknowledgment branch from d794ecd to 6918a46 Compare February 11, 2026 21:15
@vieiralucas vieiralucas force-pushed the feat/1-9-crash-recovery-graceful-shutdown branch from 0127a98 to 5096d21 Compare February 11, 2026 21:15
@vieiralucas vieiralucas force-pushed the feat/1-8-message-acknowledgment branch from 6918a46 to ac33d31 Compare February 11, 2026 21:33
@vieiralucas vieiralucas force-pushed the feat/1-9-crash-recovery-graceful-shutdown branch from 5096d21 to ac33d31 Compare February 11, 2026 21:33
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.

1 participant