Skip to content

feat(cluster): add maintenance service with defrag, alarm, and status#117

Merged
slow2342 merged 1 commit into
mainfrom
feat/cluster-ops-tools
Jun 12, 2026
Merged

feat(cluster): add maintenance service with defrag, alarm, and status#117
slow2342 merged 1 commit into
mainfrom
feat/cluster-ops-tools

Conversation

@slow2342

Copy link
Copy Markdown
Owner

Summary

Add AetherMaintenance gRPC service providing operational tools for cluster maintenance: Defrag, Alarm, and Status.

Changes

  • proto/maintenance.proto — Service definition with Defrag, Alarm, Status RPCs, AlarmType enum (NONE, NOSPACE, CORRUPT), AlarmAction enum (GET, ACTIVATE, ACKNOWLEDGE).
  • src/cluster/alarm.rs — Thread-safe AlarmManager with activate, acknowledge, get_all, has_alarm. 7 unit tests.
  • src/cluster/mod.rs — Cluster module entry, exports AlarmManager and AlarmType.
  • src/api/maintenance.rsMaintenanceService implementing all 3 RPCs. defrag runs via spawn_blocking. alarm validates action/alarm_type and delegates to AlarmManager. status returns real raft term, commit/applied index, db sizes, and dynamic learner status.
  • src/storage/rocksdb.rsdefrag() compacts only default and mvcc CFs. approximate_size() uses rocksdb.total-sst-files-size. approximate_mem_usage() uses rocksdb.estimate-live-data-size.
  • src/raft/node.rs — Added term: AtomicU64 to RaftSharedState, updated on every tick and ready cycle.
  • src/raft/handle.rs — Added fn term(&self) -> u64 to RaftHandle trait.
  • src/raft/raftrs_handle.rs — Implemented term() reading from shared state.
  • src/main.rs — Wired AlarmManager and MaintenanceService into gRPC server.
  • build.rs — Added proto/maintenance.proto to compilation.

Testing

  • 102 unit tests pass (including 7 new alarm tests)
  • cargo clippy -- -D warnings — no new warnings (pre-existing in raftrs_store.rs)
  • cargo fmt -- --check — clean

How to verify

cargo build
cargo test -p aether --lib
cargo clippy --all-targets -- -D warnings
cargo fmt -- --check

Related issues

Refs #88

Add AetherMaintenance gRPC service providing operational tools:
- Defrag: compact user data column families (default, mvcc) to reclaim
  disk space via spawn_blocking to avoid blocking the async runtime.
- Alarm: activate/acknowledge/get cluster-wide alarms (NOSPACE, CORRUPT)
  backed by a thread-safe in-memory AlarmManager.
- Status: return node status including version, db size, raft commit/applied
  index, raft term, and learner status (computed dynamically from members).

Expose raft term through RaftHandle trait by tracking it in RaftSharedState,
updated on every event loop tick and ready cycle.
@slow2342
slow2342 merged commit 1697efe into main Jun 12, 2026
5 checks passed
@slow2342
slow2342 deleted the feat/cluster-ops-tools branch June 12, 2026 05:37
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