Lifecycle
This document defines the authoritative lifecycle of an AeroDB instance.
It governs:
- CLI behavior
- Process startup
- Shutdown semantics
- Crash recovery
- Restart guarantees
- Operator expectations
If implementation behavior conflicts with this document, the implementation is wrong.
AeroDB lifecycle is explicit, deterministic, and conservative.
1. Lifecycle States¶
An AeroDB instance exists in exactly one of the following states:
- UNINITIALIZED
- INITIALIZING
- RECOVERING
- VERIFYING
- SERVING
- SHUTTING_DOWN
- TERMINATED
Transitions are strictly ordered.
There are no parallel states.
2. UNINITIALIZED¶
The system is UNINITIALIZED when:
data_dirdoes not exist- or contains no AeroDB metadata
Allowed action:
Behavior:
- Creates directory structure
- Initializes WAL and storage files
- Creates metadata directories
- Does NOT start serving
No queries or writes allowed.
3. INITIALIZING¶
Entered on:
Steps:
- Load configuration
- Validate config
- Load schemas
Failure at any step → TERMINATED.
No WAL or storage access before schema load completes.
4. RECOVERING¶
Entered after INITIALIZING succeeds.
Performed by Recovery Manager.
Steps:
- Replay WAL from byte 0
- Apply records to storage
- Rebuild indexes
Rules:
- WAL corruption → TERMINATED
- Storage corruption → TERMINATED
- No partial replay
- No degraded mode
Same WAL must always produce same state.
5. VERIFYING¶
Entered after RECOVERING.
Steps:
- Sequentially scan storage
- Validate checksums
- Verify schema references
Failure → TERMINATED.
This guarantees internal consistency before serving.
6. SERVING¶
Entered only after VERIFYING succeeds.
Behavior:
- API becomes available
- Global execution lock active
- Queries and writes allowed
- All operations serialized
System remains SERVING until explicit shutdown or crash.
7. SHUTTING_DOWN¶
Entered on:
- SIGTERM
- CLI stop
- controlled exit
Steps:
- Stop accepting API requests
- Wait for in-flight operation
- Write
clean_shutdownmarker - Exit process
No background cleanup.
8. TERMINATED¶
Final state.
Process exits.
Causes:
- Fatal error
- Crash
- Operator shutdown
On next start:
- Full recovery always runs
9. Crash Semantics¶
Crash includes:
- power loss
- SIGKILL
- panic
- segmentation fault
Behavior:
- clean_shutdown marker absent
- WAL replay required
- storage verified
- indexes rebuilt
Crash does NOT corrupt correctness unless disk data is corrupted.
10. Restart Semantics¶
Restart always executes:
- INITIALIZING
- RECOVERING
- VERIFYING
- SERVING
Clean shutdown does NOT skip recovery in Phase 0.
Fast-start is forbidden.
11. Upgrade Semantics (Phase 0)¶
Phase 0 does NOT support:
- in-place upgrades
- rolling upgrades
- schema migrations
Binary upgrades require:
- Full shutdown
- Replace executable
- Start
Backward compatibility is not guaranteed.
12. Operator Responsibilities¶
Operators must:
- maintain backups
- monitor disk health
- respond to FATAL errors
- restore from backup if corruption occurs
AeroDB does not auto-repair.
13. Determinism Guarantees¶
Given identical:
- WAL
- storage
- schemas
- config
AeroDB must:
- reach SERVING
- expose identical data
- return identical query results
No lifecycle step may depend on time or environment.
14. Phase-0 Limitations¶
Explicitly unsupported:
- hot reload
- online upgrades
- partial recovery
- read-only mode
- degraded serving
Failure is terminal.
15. Authority¶
This document governs:
- CLI commands
- Recovery Manager
- main.rs
- operator expectations
Violations are correctness bugs.