Skip to main content

tuwunel_admin/query/raw/
flush.rs

1//! `flush` raw query: force a RocksDB LSM-tree memtable flush.
2//!
3//! Calls [`tuwunel_database::Engine::sort`], flushing RocksDB's memtables to
4//! on-disk SST files. An LSM-tree flush, not a libc `fflush(3)` or `fsync(2)`,
5//! and not the write-ahead-log `flush`/`sync` engine methods.
6
7use tokio::time::Instant;
8use tuwunel_core::Result;
9
10use crate::admin_command;
11
12/// Flush the RocksDB memtables to SST files: an LSM-tree flush, not
13/// `fflush(3)` or `fsync(2)`.
14#[admin_command]
15pub(super) async fn raw_flush(&self) -> Result {
16	let timer = Instant::now();
17
18	self.blocking_db(|db| db.engine.sort()).await?;
19
20	let elapsed = timer.elapsed();
21
22	write!(self, "Memtables flushed to SST files in {elapsed:?}.").await
23}