提交 b1f6e7e8 编写于 作者: G groot

handle exception in merge file


Former-commit-id: 687e64645af47e42f030a456a0c7c9921748198e
上级 5fedc4a2
......@@ -363,6 +363,7 @@ Status DBImpl::MergeFiles(const std::string& table_id, const meta::DateT& date,
const meta::TableFilesSchema& files) {
ENGINE_LOG_DEBUG << "Merge files for table " << table_id;
//step 1: create table file
meta::TableFileSchema table_file;
table_file.table_id_ = table_id;
table_file.date_ = date;
......@@ -374,6 +375,7 @@ Status DBImpl::MergeFiles(const std::string& table_id, const meta::DateT& date,
return status;
}
//step 2: merge files
ExecutionEnginePtr index =
EngineFactory::Build(table_file.dimension_, table_file.location_, (EngineType)table_file.engine_type_);
......@@ -397,9 +399,25 @@ Status DBImpl::MergeFiles(const std::string& table_id, const meta::DateT& date,
if (index_size >= options_.index_trigger_size) break;
}
//step 3: serialize to disk
try {
index->Serialize();
} catch (std::exception& ex) {
//typical error: out of disk space or permition denied
std::string msg = "Serialize merged index encounter exception" + std::string(ex.what());
ENGINE_LOG_ERROR << msg;
table_file.file_type_ = meta::TableFileSchema::TO_DELETE;
status = meta_ptr_->UpdateTableFile(table_file);
ENGINE_LOG_DEBUG << "Failed to update file to index, mark file: " << table_file.file_id_ << " to to_delete";
index->Serialize();
std::cout << "ERROR: failed to persist merged index file: " << table_file.location_
<< ", possible out of disk space" << std::endl;
return Status::Error(msg);
}
//step 4: update table files state
if (index_size >= options_.index_trigger_size) {
table_file.file_type_ = meta::TableFileSchema::TO_INDEX;
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册