From 736c348cfc1c848d0843cb4e14bc41fa719763c5 Mon Sep 17 00:00:00 2001 From: groot Date: Fri, 29 Nov 2019 17:20:16 +0800 Subject: [PATCH] add log --- core/src/db/DBImpl.cpp | 4 ++-- core/src/db/engine/ExecutionEngineImpl.cpp | 4 ++-- core/src/scheduler/task/BuildIndexTask.cpp | 13 +++++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/core/src/db/DBImpl.cpp b/core/src/db/DBImpl.cpp index c88936a08e..1db686b5ba 100644 --- a/core/src/db/DBImpl.cpp +++ b/core/src/db/DBImpl.cpp @@ -792,12 +792,12 @@ DBImpl::BackgroundCompaction(std::set table_ids) { meta_ptr_->Archive(); { - uint64_t ttl = 1 * meta::SECOND; // default: file data will be erase from cache after few seconds + uint64_t ttl = 10 * meta::SECOND; // default: file data will be erase from cache after few seconds meta_ptr_->CleanUpCacheWithTTL(ttl, &ongoing_files_checker_); } { - uint64_t ttl = 1 * meta::SECOND; // default: file will be deleted after few seconds + uint64_t ttl = 20 * meta::SECOND; // default: file will be deleted after few seconds if (options_.mode_ == DBOptions::MODE::CLUSTER_WRITABLE) { ttl = meta::H_SEC; } diff --git a/core/src/db/engine/ExecutionEngineImpl.cpp b/core/src/db/engine/ExecutionEngineImpl.cpp index a2ef4c70d4..c81d5d8e54 100644 --- a/core/src/db/engine/ExecutionEngineImpl.cpp +++ b/core/src/db/engine/ExecutionEngineImpl.cpp @@ -258,12 +258,12 @@ ExecutionEngineImpl::PhysicalSize() const { Status ExecutionEngineImpl::Serialize() { - ENGINE_LOG_DEBUG << "Serialize index size: " << index_->Size() << " to file: " << location_; auto status = write_index(index_, location_); // here we reset index size by file size, // since some index type(such as SQ8) data size become smaller after serialized index_->set_size(PhysicalSize()); + ENGINE_LOG_DEBUG << "Finish serialize index file: " << location_ << " size: " << index_->Size(); return status; } @@ -496,7 +496,7 @@ ExecutionEngineImpl::BuildIndex(const std::string& location, EngineType engine_t throw Exception(DB_ERROR, status.message()); } - ENGINE_LOG_DEBUG << "Sucessfully build index file: " << location << " size: " << to_index->Size(); + ENGINE_LOG_DEBUG << "Finish build index file: " << location << " size: " << to_index->Size(); return std::make_shared(to_index, location, engine_type, metric_type_, nlist_); } diff --git a/core/src/scheduler/task/BuildIndexTask.cpp b/core/src/scheduler/task/BuildIndexTask.cpp index e952bd0938..681968c402 100644 --- a/core/src/scheduler/task/BuildIndexTask.cpp +++ b/core/src/scheduler/task/BuildIndexTask.cpp @@ -168,7 +168,10 @@ XBuildIndexTask::Execute() { // step 5: save index file try { - index->Serialize(); + status = index->Serialize(); + if (status.ok()) { + ENGINE_LOG_DEBUG << "Failed to serilize index file: " << status.message(); + } } catch (std::exception& ex) { // typical error: out of disk space or permition denied std::string msg = "Serialize index encounter exception: " + std::string(ex.what()); @@ -196,7 +199,13 @@ XBuildIndexTask::Execute() { origin_file.file_type_ = engine::meta::TableFileSchema::BACKUP; engine::meta::TableFilesSchema update_files = {table_file, origin_file}; - status = meta_ptr->UpdateTableFiles(update_files); + + if (table_file.file_size_ > 0) { // makesure index file is sucessfully serialized to disk + status = meta_ptr->UpdateTableFiles(update_files); + } else { + status = Status(DB_ERROR, "Illegal index file: out of disk space or memory"); + } + if (status.ok()) { ENGINE_LOG_DEBUG << "New index file " << table_file.file_id_ << " of size " << index->PhysicalSize() << " bytes"