From 8c6c6168e89de0817b68686636c9fc27c12cf31d Mon Sep 17 00:00:00 2001 From: git-hulk Date: Wed, 20 Dec 2023 22:04:12 +0800 Subject: [PATCH 1/4] Use human readable string instead of the integer when printing flush/compaction reason --- src/storage/event_listener.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/storage/event_listener.cc b/src/storage/event_listener.cc index 6e054945669..64c4bc9452f 100644 --- a/src/storage/event_listener.cc +++ b/src/storage/event_listener.cc @@ -77,7 +77,7 @@ bool IsDiskQuotaExceeded(const rocksdb::Status &bg_error) { void EventListener::OnCompactionCompleted(rocksdb::DB *db, const rocksdb::CompactionJobInfo &ci) { LOG(INFO) << "[event_listener/compaction_completed] column family: " << ci.cf_name << ", job_id: " << ci.job_id - << ", compaction reason: " << static_cast(ci.compaction_reason) + << ", compaction reason: " << rocksdb::GetCompactionReasonString(ci.compaction_reason) << ", output compression type: " << CompressType2String(ci.compression) << ", base input level(files): " << ci.base_input_level << "(" << ci.input_files.size() << ")" << ", output level(files): " << ci.output_level << "(" << ci.output_files.size() << ")" @@ -90,7 +90,7 @@ void EventListener::OnCompactionCompleted(rocksdb::DB *db, const rocksdb::Compac void EventListener::OnFlushBegin(rocksdb::DB *db, const rocksdb::FlushJobInfo &fi) { LOG(INFO) << "[event_listener/flush_begin] column family: " << fi.cf_name << ", thread_id: " << fi.thread_id - << ", job_id: " << fi.job_id << ", reason: " << static_cast(fi.flush_reason); + << ", job_id: " << fi.job_id << ", reason: " << rocksdb::GetFlushReasonString(fi.flush_reason); } void EventListener::OnFlushCompleted(rocksdb::DB *db, const rocksdb::FlushJobInfo &fi) { From 40be9adee88db7d5523df61a9939737044b4ffd5 Mon Sep 17 00:00:00 2001 From: git-hulk Date: Wed, 20 Dec 2023 22:35:09 +0800 Subject: [PATCH 2/4] Add subcompaction event listner --- src/storage/event_listener.cc | 27 +++++++++++++++++++++++++++ src/storage/event_listener.h | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/src/storage/event_listener.cc b/src/storage/event_listener.cc index 64c4bc9452f..484e30f2fff 100644 --- a/src/storage/event_listener.cc +++ b/src/storage/event_listener.cc @@ -75,6 +75,17 @@ bool IsDiskQuotaExceeded(const rocksdb::Status &bg_error) { return err_msg.find(exceeded_quota_str) != std::string::npos; } +void EventListener::OnCompactionBegin(rocksdb::DB *db, const rocksdb::CompactionJobInfo &ci) { + LOG(INFO) << "[event_listener/compaction_begin] column family: " << ci.cf_name << ", job_id: " << ci.job_id + << ", compaction reason: " << rocksdb::GetCompactionReasonString(ci.compaction_reason) + << ", output compression type: " << CompressType2String(ci.compression) + << ", base input level(files): " << ci.base_input_level << "(" << ci.input_files.size() << ")" + << ", output level(files): " << ci.output_level << "(" << ci.output_files.size() << ")" + << ", input bytes: " << ci.stats.total_input_bytes << ", output bytes:" << ci.stats.total_output_bytes + << ", is_manual_compaction:" << (ci.stats.is_manual_compaction ? "yes" : "no") + << ", elapsed(micro): " << ci.stats.elapsed_micros; +} + void EventListener::OnCompactionCompleted(rocksdb::DB *db, const rocksdb::CompactionJobInfo &ci) { LOG(INFO) << "[event_listener/compaction_completed] column family: " << ci.cf_name << ", job_id: " << ci.job_id << ", compaction reason: " << rocksdb::GetCompactionReasonString(ci.compaction_reason) @@ -88,6 +99,22 @@ void EventListener::OnCompactionCompleted(rocksdb::DB *db, const rocksdb::Compac storage_->CheckDBSizeLimit(); } +void EventListener::OnSubcompactionBegin(const rocksdb::SubcompactionJobInfo &si) { + LOG(INFO) << "[event_listener/subcompaction_begin] column family: " << si.cf_name << ", job_id: " << si.job_id + << ", compaction reason: " << rocksdb::GetCompactionReasonString(si.compaction_reason) + << ", output compression type: " << CompressType2String(si.compression); +} + +void EventListener::OnSubcompactionCompleted(const rocksdb::SubcompactionJobInfo &si) { + LOG(INFO) << "[event_listener/subcompaction_begin] column family: " << si.cf_name << ", job_id: " << si.job_id + << ", compaction reason: " << rocksdb::GetCompactionReasonString(si.compaction_reason) + << ", output compression type: " << CompressType2String(si.compression) + << ", base input level(files): " << si.base_input_level << ", output level(files): " << si.output_level + << ", input bytes: " << si.stats.total_input_bytes << ", output bytes:" << si.stats.total_output_bytes + << ", is_manual_compaction:" << (si.stats.is_manual_compaction ? "yes" : "no") + << ", elapsed(micro): " << si.stats.elapsed_micros; +} + void EventListener::OnFlushBegin(rocksdb::DB *db, const rocksdb::FlushJobInfo &fi) { LOG(INFO) << "[event_listener/flush_begin] column family: " << fi.cf_name << ", thread_id: " << fi.thread_id << ", job_id: " << fi.job_id << ", reason: " << rocksdb::GetFlushReasonString(fi.flush_reason); diff --git a/src/storage/event_listener.h b/src/storage/event_listener.h index 4cd1606f3d1..3e978c23841 100644 --- a/src/storage/event_listener.h +++ b/src/storage/event_listener.h @@ -31,7 +31,11 @@ class EventListener : public rocksdb::EventListener { ~EventListener() override = default; void OnFlushBegin(rocksdb::DB *db, const rocksdb::FlushJobInfo &fi) override; void OnFlushCompleted(rocksdb::DB *db, const rocksdb::FlushJobInfo &fi) override; + void OnCompactionBegin(rocksdb::DB *db, const rocksdb::CompactionJobInfo &ci) override; void OnCompactionCompleted(rocksdb::DB *db, const rocksdb::CompactionJobInfo &ci) override; + void OnSubcompactionBegin(const rocksdb::SubcompactionJobInfo &si) override; + void OnSubcompactionCompleted(const rocksdb::SubcompactionJobInfo &si) override; + void OnBackgroundError(rocksdb::BackgroundErrorReason reason, rocksdb::Status *status) override; void OnTableFileDeleted(const rocksdb::TableFileDeletionInfo &info) override; void OnStallConditionsChanged(const rocksdb::WriteStallInfo &info) override; From 0d1553a532082ed73cc22e37e6dd89e59c5605c8 Mon Sep 17 00:00:00 2001 From: hulk Date: Wed, 20 Dec 2023 22:55:02 +0800 Subject: [PATCH 3/4] Update src/storage/event_listener.cc Co-authored-by: Twice --- src/storage/event_listener.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/event_listener.cc b/src/storage/event_listener.cc index 484e30f2fff..a7a1a08aef0 100644 --- a/src/storage/event_listener.cc +++ b/src/storage/event_listener.cc @@ -106,7 +106,7 @@ void EventListener::OnSubcompactionBegin(const rocksdb::SubcompactionJobInfo &si } void EventListener::OnSubcompactionCompleted(const rocksdb::SubcompactionJobInfo &si) { - LOG(INFO) << "[event_listener/subcompaction_begin] column family: " << si.cf_name << ", job_id: " << si.job_id + LOG(INFO) << "[event_listener/subcompaction_completed] column family: " << si.cf_name << ", job_id: " << si.job_id << ", compaction reason: " << rocksdb::GetCompactionReasonString(si.compaction_reason) << ", output compression type: " << CompressType2String(si.compression) << ", base input level(files): " << si.base_input_level << ", output level(files): " << si.output_level From fe9539676007bb6be602b7707d5dd33aebfca9fa Mon Sep 17 00:00:00 2001 From: hulk Date: Thu, 1 Feb 2024 13:19:33 +0800 Subject: [PATCH 4/4] Update src/storage/event_listener.cc --- src/storage/event_listener.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/storage/event_listener.cc b/src/storage/event_listener.cc index 3e9c77031b7..a32f8b70300 100644 --- a/src/storage/event_listener.cc +++ b/src/storage/event_listener.cc @@ -82,8 +82,7 @@ void EventListener::OnCompactionBegin(rocksdb::DB *db, const rocksdb::Compaction << ", base input level(files): " << ci.base_input_level << "(" << ci.input_files.size() << ")" << ", output level(files): " << ci.output_level << "(" << ci.output_files.size() << ")" << ", input bytes: " << ci.stats.total_input_bytes << ", output bytes:" << ci.stats.total_output_bytes - << ", is_manual_compaction:" << (ci.stats.is_manual_compaction ? "yes" : "no") - << ", elapsed(micro): " << ci.stats.elapsed_micros; + << ", is_manual_compaction:" << (ci.stats.is_manual_compaction ? "yes" : "no"); } void EventListener::OnCompactionCompleted(rocksdb::DB *db, const rocksdb::CompactionJobInfo &ci) {