mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-10 15:22:56 +00:00
fix: avoid writing manifest and wal if no files are actually flushed (#1698)
* fix: avoid writing manifest and wal if no files are actually flushed * fix: simplify log
This commit is contained in:
@@ -16,7 +16,7 @@ use std::collections::HashSet;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
|
||||
use common_base::readable_size::ReadableSize;
|
||||
use common_telemetry::{debug, error, timer};
|
||||
use common_telemetry::{debug, error, info, timer};
|
||||
use store_api::logstore::LogStore;
|
||||
use store_api::storage::RegionId;
|
||||
|
||||
@@ -148,6 +148,10 @@ impl<S: LogStore> CompactionTask for CompactionTaskImpl<S> {
|
||||
e
|
||||
})?;
|
||||
compacted.extend(self.expired_ssts.iter().map(FileHandle::meta));
|
||||
|
||||
let input_ids = compacted.iter().map(|f| f.file_id).collect::<Vec<_>>();
|
||||
let output_ids = output.iter().map(|f| f.file_id).collect::<Vec<_>>();
|
||||
info!("Compacting SST files, input: {input_ids:?}, output: {output_ids:?}");
|
||||
self.write_manifest_and_apply(output, compacted)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
|
||||
@@ -239,6 +239,10 @@ impl<S: LogStore> FlushJob<S> {
|
||||
let _timer = timer!(FLUSH_ELAPSED);
|
||||
|
||||
let file_metas = self.write_memtables_to_layer().await?;
|
||||
if file_metas.is_empty() {
|
||||
// skip writing manifest and wal if no files are flushed.
|
||||
return Ok(());
|
||||
}
|
||||
self.write_manifest_and_apply(&file_metas).await?;
|
||||
|
||||
Ok(())
|
||||
@@ -287,13 +291,14 @@ impl<S: LogStore> FlushJob<S> {
|
||||
});
|
||||
}
|
||||
|
||||
let metas = futures_util::future::try_join_all(futures)
|
||||
let metas: Vec<_> = futures_util::future::try_join_all(futures)
|
||||
.await?
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect();
|
||||
|
||||
logging::info!("Successfully flush memtables to files: {:?}", metas);
|
||||
let file_ids = metas.iter().map(|f| f.file_id).collect::<Vec<_>>();
|
||||
logging::info!("Successfully flush memtables, region:{region_id}, files: {file_ids:?}");
|
||||
Ok(metas)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user