MS-543 send error status to sdk when load index fail

Former-commit-id: a62922b904c7f7d478f5211b4d215d387ea23ae2
This commit is contained in:
yudong.cai 2019-09-12 14:10:56 +08:00
parent 90cd973587
commit f136df4aaa
6 changed files with 23 additions and 6 deletions

View File

@ -34,6 +34,7 @@ Please mark all change in change log and use the ticket from JIRA.
- MS-474 - Create index hang if use branch-0.3.1 server config
- MS-510 - unittest out of memory and crashed
- MS-507 - Dataset 10m-512, index type sq8performance in-normal when set CPU_CACHE to 16 or 64
- MS-543 - SearchTask fail without exception
## Improvement
- MS-327 - Clean code for milvus

View File

@ -424,6 +424,9 @@ Status DBImpl::QueryAsync(const std::string& table_id, const meta::TableFilesSch
scheduler.Schedule(context);
context->WaitResult();
if (!context->GetStatus().ok()) {
return context->GetStatus();
}
//step 3: print time cost information
double load_cost = context->LoadCost();

View File

@ -69,7 +69,7 @@ std::string Status::ToString() const {
type = "InvalidPath: ";
break;
default:
snprintf(tmp, sizeof(tmp), "Unkown code(%d): ",
snprintf(tmp, sizeof(tmp), "Error code(0x%x): ",
static_cast<int>(code()));
type = tmp;
break;

View File

@ -38,7 +38,9 @@ public:
const ResultSet& GetResult() const { return result_; }
ResultSet& GetResult() { return result_; }
std::string Identity() const { return identity_; }
const std::string& Identity() const { return identity_; }
const Status& GetStatus() const { return status_; }
Status& GetStatus() { return status_; }
void IndexSearchDone(size_t index_id);
void WaitResult();
@ -64,6 +66,7 @@ private:
std::condition_variable done_cond_;
std::string identity_; //for debug
Status status_;
double time_cost_load_ = 0.0; //time cost for load all index files, unit: us
double time_cost_search_ = 0.0; //time cost for entire search, unit: us

View File

@ -98,14 +98,18 @@ XSearchTask::Load(LoadType type, uint8_t device_id) {
server::TimeRecorder rc("");
Status stat = Status::OK();
std::string error_msg;
std::string type_str;
try {
if (type == LoadType::DISK2CPU) {
stat = index_engine_->Load();
type_str = "DISK2CPU";
} else if (type == LoadType::CPU2GPU) {
stat = index_engine_->CopyToGpu(device_id);
type_str = "CPU2GPU";
} else if (type == LoadType::GPU2CPU) {
stat = index_engine_->CopyToCpu();
type_str = "GPU2CPU";
} else {
error_msg = "Wrong load type";
stat = Status(SERVER_UNEXPECTED_ERROR, error_msg);
@ -117,13 +121,18 @@ XSearchTask::Load(LoadType type, uint8_t device_id) {
}
if (!stat.ok()) {
if (error_msg.empty())
error_msg = std::string("Failed to load index file: file not available");
//typical error: file not available
ENGINE_LOG_ERROR << error_msg;
Status s;
if (stat.ToString().find("out of memory") != std::string::npos) {
error_msg = "out of memory: " + type_str;
s = Status(SERVER_OUT_OF_MEMORY, error_msg);
} else {
error_msg = "Failed to load index file: " + type_str;
s = Status(SERVER_UNEXPECTED_ERROR, error_msg);
}
for (auto &context : search_contexts_) {
context->IndexSearchDone(file_->id_);//mark as done avoid dead lock, even failed
context->GetStatus() = s;
}
return;

View File

@ -66,6 +66,7 @@ constexpr ErrorCode SERVER_INVALID_NPROBE = ToServerErrorCode(113);
constexpr ErrorCode SERVER_INVALID_INDEX_NLIST = ToServerErrorCode(114);
constexpr ErrorCode SERVER_INVALID_INDEX_METRIC_TYPE = ToServerErrorCode(115);
constexpr ErrorCode SERVER_INVALID_INDEX_FILE_SIZE = ToServerErrorCode(116);
constexpr ErrorCode SERVER_OUT_OF_MEMORY = ToServerErrorCode(117);
//db error code
constexpr ErrorCode DB_META_TRANSACTION_FAILED = ToDbErrorCode(1);