This commit is contained in:
groot 2019-11-29 17:20:16 +08:00
parent d5d54f6c35
commit 736c348cfc
3 changed files with 15 additions and 6 deletions

View File

@ -792,12 +792,12 @@ DBImpl::BackgroundCompaction(std::set<std::string> 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;
}

View File

@ -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<ExecutionEngineImpl>(to_index, location, engine_type, metric_type_, nlist_);
}

View File

@ -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"