pub fn spawn_flow_flush(
stores: Arc<ServerStores>,
band: Arc<Mutex<Option<Fleet>>>,
) -> JoinHandle<()> ⓘExpand description
Start the flow flush: every FLOW_FLUSH_INTERVAL, forever.
The live half of the flow ledger is a set of atomics in this process; this
is what makes it survive a restart. It COPIES the live slots into the
control store rather than adding to them (gunnar_core::FlowLedger::flush),
so running it twice writes the same rows twice instead of doubling them —
which is what lets it run on a tick without any coordination, and what lets
a slot opened after a restart be seeded from the stored row rather than from
zero.
It is a task of its own and NOT a line in the dashboard’s two-second tick, deliberately: that tick is documented as reading a few atomics and nothing else, and this writes redb. A flush on the dashboard’s thread would put a database commit between the operator and the screen.
It also carries the day boundary on an IDLE server. A namespace that was pushed to at 23:59 and then left alone has a live slot still holding yesterday; nothing on the transfer path will notice, because there is no transfer. The flush rolls it and writes the completed day.
Fire and forget, like spawn_tombstone_sweep: it holds no lock the server
needs, its work is on the blocking pool, and a failed write is logged and
retried on the next tick — the counters are still in RAM, so nothing is lost
by carrying on.