#1105 update error message when creating IVFSQ8H index without GPU resources (#1117)

pull/1095/head
Cai Yudong 2020-02-08 11:25:10 +08:00 committed by GitHub
parent 032ac328b2
commit ef0e3145eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 39 deletions

View File

@ -47,6 +47,7 @@ Please mark all change in change log and use the issue from GitHub
- \#966 - Update NOTICE.md - \#966 - Update NOTICE.md
- \#1002 - Rename minio to s3 in Storage Config section - \#1002 - Rename minio to s3 in Storage Config section
- \#1078 - Move 'insert_buffer_size' to Cache Config section - \#1078 - Move 'insert_buffer_size' to Cache Config section
- \#1105 - Error message is not clear when creating IVFSQ8H index without gpu resources
## Task ## Task

View File

@ -895,7 +895,7 @@ DBImpl::BackgroundBuildIndex() {
Status status = job->GetStatus(); Status status = job->GetStatus();
ENGINE_LOG_ERROR << "Building index job " << job->id() << " failed: " << status.ToString(); ENGINE_LOG_ERROR << "Building index job " << job->id() << " failed: " << status.ToString();
index_failed_checker_.MarkFailedIndexFile(file_schema); index_failed_checker_.MarkFailedIndexFile(file_schema, status.message());
} else { } else {
ENGINE_LOG_DEBUG << "Building index job " << job->id() << " succeed."; ENGINE_LOG_DEBUG << "Building index job " << job->id() << " succeed.";
@ -1066,13 +1066,10 @@ DBImpl::BuildTableIndexRecursively(const std::string& table_id, const TableIndex
} }
// failed to build index for some files, return error // failed to build index for some files, return error
std::vector<std::string> failed_files; std::string err_msg;
index_failed_checker_.GetFailedIndexFileOfTable(table_id, failed_files); index_failed_checker_.GetErrMsgForTable(table_id, err_msg);
if (!failed_files.empty()) { if (!err_msg.empty()) {
std::string msg = "Failed to build index for " + std::to_string(failed_files.size()) + return Status(DB_ERROR, err_msg);
((failed_files.size() == 1) ? " file" : " files");
msg += ", please double check index parameters.";
return Status(DB_ERROR, msg);
} }
return Status::OK(); return Status::OK();

View File

@ -15,9 +15,10 @@
// specific language governing permissions and limitations // specific language governing permissions and limitations
// under the License. // under the License.
#include "db/IndexFailedChecker.h"
#include <utility> #include <utility>
#include <vector>
#include "db/IndexFailedChecker.h"
namespace milvus { namespace milvus {
namespace engine { namespace engine {
@ -33,35 +34,31 @@ IndexFailedChecker::CleanFailedIndexFileOfTable(const std::string& table_id) {
} }
Status Status
IndexFailedChecker::GetFailedIndexFileOfTable(const std::string& table_id, std::vector<std::string>& failed_files) { IndexFailedChecker::GetErrMsgForTable(const std::string& table_id, std::string& err_msg) {
failed_files.clear();
std::lock_guard<std::mutex> lck(mutex_); std::lock_guard<std::mutex> lck(mutex_);
auto iter = index_failed_files_.find(table_id); auto iter = index_failed_files_.find(table_id);
if (iter != index_failed_files_.end()) { if (iter != index_failed_files_.end()) {
File2RefCount& failed_map = iter->second; err_msg = iter->second.begin()->second[0];
for (auto it_file = failed_map.begin(); it_file != failed_map.end(); ++it_file) {
failed_files.push_back(it_file->first);
}
} }
return Status::OK(); return Status::OK();
} }
Status Status
IndexFailedChecker::MarkFailedIndexFile(const meta::TableFileSchema& file) { IndexFailedChecker::MarkFailedIndexFile(const meta::TableFileSchema& file, const std::string& err_msg) {
std::lock_guard<std::mutex> lck(mutex_); std::lock_guard<std::mutex> lck(mutex_);
auto iter = index_failed_files_.find(file.table_id_); auto iter = index_failed_files_.find(file.table_id_);
if (iter == index_failed_files_.end()) { if (iter == index_failed_files_.end()) {
File2RefCount failed_files; File2ErrArray failed_files;
failed_files.insert(std::make_pair(file.file_id_, 1)); failed_files.insert(std::make_pair(file.file_id_, std::vector<std::string>(1, err_msg)));
index_failed_files_.insert(std::make_pair(file.table_id_, failed_files)); index_failed_files_.insert(std::make_pair(file.table_id_, failed_files));
} else { } else {
auto it_failed_files = iter->second.find(file.file_id_); auto it_failed_files = iter->second.find(file.file_id_);
if (it_failed_files != iter->second.end()) { if (it_failed_files != iter->second.end()) {
it_failed_files->second++; it_failed_files->second.push_back(err_msg);
} else { } else {
iter->second.insert(std::make_pair(file.file_id_, 1)); iter->second.insert(std::make_pair(file.file_id_, std::vector<std::string>(1, err_msg)));
} }
} }
@ -95,7 +92,7 @@ IndexFailedChecker::IgnoreFailedIndexFiles(meta::TableFilesSchema& table_files)
if (it_failed_files != index_failed_files_.end()) { if (it_failed_files != index_failed_files_.end()) {
auto it_failed_file = it_failed_files->second.find((*it_file).file_id_); auto it_failed_file = it_failed_files->second.find((*it_file).file_id_);
if (it_failed_file != it_failed_files->second.end()) { if (it_failed_file != it_failed_files->second.end()) {
if (it_failed_file->second >= INDEX_FAILED_RETRY_TIME) { if (it_failed_file->second.size() >= INDEX_FAILED_RETRY_TIME) {
it_file = table_files.erase(it_file); it_file = table_files.erase(it_file);
continue; continue;
} }

View File

@ -24,7 +24,6 @@
#include <map> #include <map>
#include <mutex> #include <mutex>
#include <string> #include <string>
#include <vector>
namespace milvus { namespace milvus {
namespace engine { namespace engine {
@ -35,10 +34,10 @@ class IndexFailedChecker {
CleanFailedIndexFileOfTable(const std::string& table_id); CleanFailedIndexFileOfTable(const std::string& table_id);
Status Status
GetFailedIndexFileOfTable(const std::string& table_id, std::vector<std::string>& failed_files); GetErrMsgForTable(const std::string& table_id, std::string& err_msg);
Status Status
MarkFailedIndexFile(const meta::TableFileSchema& file); MarkFailedIndexFile(const meta::TableFileSchema& file, const std::string& err_msg);
Status Status
MarkSucceedIndexFile(const meta::TableFileSchema& file); MarkSucceedIndexFile(const meta::TableFileSchema& file);
@ -48,7 +47,7 @@ class IndexFailedChecker {
private: private:
std::mutex mutex_; std::mutex mutex_;
Table2Files index_failed_files_; // table id mapping to (file id mapping to failed times) Table2FileErr index_failed_files_; // table id mapping to (file id mapping to failed times)
}; };
} // namespace engine } // namespace engine

View File

@ -55,7 +55,7 @@ class OngoingFileChecker : public meta::Meta::CleanUpFilter {
private: private:
std::mutex mutex_; std::mutex mutex_;
Table2Files ongoing_files_; // table id mapping to (file id mapping to ongoing ref-count) Table2FileRef ongoing_files_; // table id mapping to (file id mapping to ongoing ref-count)
}; };
} // namespace engine } // namespace engine

View File

@ -50,8 +50,10 @@ struct VectorsData {
IDNumbers id_array_; IDNumbers id_array_;
}; };
using File2ErrArray = std::map<std::string, std::vector<std::string>>;
using Table2FileErr = std::map<std::string, File2ErrArray>;
using File2RefCount = std::map<std::string, int64_t>; using File2RefCount = std::map<std::string, int64_t>;
using Table2Files = std::map<std::string, File2RefCount>; using Table2FileRef = std::map<std::string, File2RefCount>;
} // namespace engine } // namespace engine
} // namespace milvus } // namespace milvus

View File

@ -128,30 +128,30 @@ TEST(DBMiscTest, CHECKER_TEST) {
milvus::engine::meta::TableFileSchema schema; milvus::engine::meta::TableFileSchema schema;
schema.table_id_ = "aaa"; schema.table_id_ = "aaa";
schema.file_id_ = "5000"; schema.file_id_ = "5000";
checker.MarkFailedIndexFile(schema); checker.MarkFailedIndexFile(schema, "5000 fail");
schema.table_id_ = "bbb"; schema.table_id_ = "bbb";
schema.file_id_ = "5001"; schema.file_id_ = "5001";
checker.MarkFailedIndexFile(schema); checker.MarkFailedIndexFile(schema, "5001 fail");
std::vector<std::string> failed_files; std::string err_msg;
checker.GetFailedIndexFileOfTable("aaa", failed_files); checker.GetErrMsgForTable("aaa", err_msg);
ASSERT_EQ(failed_files.size(), 1UL); ASSERT_EQ(err_msg, "5000 fail");
schema.table_id_ = "bbb"; schema.table_id_ = "bbb";
schema.file_id_ = "5002"; schema.file_id_ = "5002";
checker.MarkFailedIndexFile(schema); checker.MarkFailedIndexFile(schema, "5002 fail");
checker.MarkFailedIndexFile(schema); checker.MarkFailedIndexFile(schema, "5002 fail");
milvus::engine::meta::TableFilesSchema table_files = {schema}; milvus::engine::meta::TableFilesSchema table_files = {schema};
checker.IgnoreFailedIndexFiles(table_files); checker.IgnoreFailedIndexFiles(table_files);
ASSERT_TRUE(table_files.empty()); ASSERT_TRUE(table_files.empty());
checker.GetFailedIndexFileOfTable("bbb", failed_files); checker.GetErrMsgForTable("bbb", err_msg);
ASSERT_EQ(failed_files.size(), 2UL); ASSERT_EQ(err_msg, "5001 fail");
checker.MarkSucceedIndexFile(schema); checker.MarkSucceedIndexFile(schema);
checker.GetFailedIndexFileOfTable("bbb", failed_files); checker.GetErrMsgForTable("bbb", err_msg);
ASSERT_EQ(failed_files.size(), 1UL); ASSERT_EQ(err_msg, "5001 fail");
} }
{ {