audit: assert storage ordering invariants at runtime

Abort if audit storage fails to start rather than silently
running with an unaudited maintenance socket. Also assert
that storage is already stopped when the audit service is
destroyed, documenting the defer-stack ordering requirement.

Refs SCYLLADB-1615
Refs SCYLLADB-1695
This commit is contained in:
Andrzej Jackowski
2026-04-28 16:24:47 +02:00
parent 543fb6a2db
commit 3755c370ac
2 changed files with 2 additions and 3 deletions

View File

@@ -223,6 +223,7 @@ future<> audit::stop_audit() {
return make_ready_future<>();
}
return audit::audit::audit_instance().invoke_on_all([] (auto& local_audit) {
SCYLLA_ASSERT(!local_audit._storage_running);
return local_audit.shutdown();
}).then([] {
return audit::audit::audit_instance().stop();

View File

@@ -2363,9 +2363,7 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl
// The table-based audit backend needs Raft (via join_cluster)
// to create its keyspace and table.
checkpoint(stop_signal, "starting audit storage");
audit::audit::start_storage(*cfg).handle_exception([&] (auto&& e) {
startlog.error("audit storage start failed: {}", e);
}).get();
audit::audit::start_storage(*cfg).get();
auto audit_storage_stop = defer([] {
audit::audit::stop_storage().get();
});