Background
crusher still has Tokio async paths where shutdown/reload/reconnect can leave work partially abandoned or state inconsistent.
Key candidates:
- top-level spawned tasks are not always joined to completion
- some paths hold
Mutex/RwLock guards across .await
- important shared state (
active_policy_list, delete_policy_ids, INGEST_CHANNEL, LAST_TRANSFER_TIME) is directly shared instead of actor-owned
- timestamp persistence is not guaranteed to be safely flushed during shutdown
Goal
Apply cancellation safety to crusher's Tokio async code so that the system has cooperative cancellation, safe drain behavior, and restart-time state consistency.
Scope
- Identify vulnerable paths
- audit lock-across-await code
- list long-running and detached spawned tasks
- identify work that can be abandoned during shutdown
- Define cancellation policy
- evaluate
CancellationToken / TaskTracker
- define shutdown requested / draining / completed phases
- add a common mechanism to verify all child tasks have stopped
- Improve shared-state ownership
- ban
Mutex/RwLock guards across .await
- move important shared state to actors or single-owner tasks
- redesign the lock-based
SendStream serialization path
- Harden drain and restart consistency
- guarantee pending-work drain and timestamp flush on shutdown
- make timestamp-file persistence safer
- add restart consistency tests
Acceptance Criteria
- no detached tasks remain after shutdown/reload/reconnect
- core lock-across-await paths are removed or structurally redesigned
- top-level shutdown completion means real child-task drain completion
- policy/stream/timestamp state is managed consistently
- tests cover cancellation, shutdown, and restart scenarios
Background
crusherstill has Tokio async paths where shutdown/reload/reconnect can leave work partially abandoned or state inconsistent.Key candidates:
Mutex/RwLockguards across.awaitactive_policy_list,delete_policy_ids,INGEST_CHANNEL,LAST_TRANSFER_TIME) is directly shared instead of actor-ownedGoal
Apply cancellation safety to
crusher's Tokio async code so that the system has cooperative cancellation, safe drain behavior, and restart-time state consistency.Scope
CancellationToken/TaskTrackerMutex/RwLockguards across.awaitSendStreamserialization pathAcceptance Criteria