mirror of https://github.com/milvus-io/milvus.git
Fix the bug of file not close when check sum failed. (#3783)
* Fix the bug of file not close when check sum failed. Signed-off-by: godchen0212 <qingxiang.chen@zilliz.com> * change the log level to error Signed-off-by: godchen0212 <qingxiang.chen@zilliz.com> * fix cpp lint problem Signed-off-by: godchen0212 <qingxiang.chen@zilliz.com> Signed-off-by: shengjun.li <shengjun.li@zilliz.com>pull/3640/head
parent
b29954cd9e
commit
b383748870
|
@ -42,6 +42,7 @@ Please mark all changes in change log and use the issue from GitHub
|
|||
- \#3533 Scheduler/Selector needs to judge the index type
|
||||
- \#3621 Fix crash where getting octets information
|
||||
- \#3626 Server crashed during search with index pq on dataset: sift-50m
|
||||
- \#3642 Fix the bug of file not close when check sum failed.
|
||||
- \#3652 Proto of C++ sdk is different from milvus server
|
||||
- \#3668 Docker exit without any logs
|
||||
- \#3672 0.11.0 docker image is 200M larger due to the un-expected installation of openblas
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "codecs/ExtraFileInfo.h"
|
||||
#include "crc32c/crc32c.h"
|
||||
#include "utils/Log.h"
|
||||
|
||||
const char* MAGIC = "Milvus";
|
||||
const int64_t MAGIC_SIZE = 6;
|
||||
|
@ -41,7 +42,12 @@ CheckMagic(const storage::FSHandlerPtr& fs_ptr) {
|
|||
magic.resize(MAGIC_SIZE);
|
||||
fs_ptr->reader_ptr_->Read(magic.data(), MAGIC_SIZE);
|
||||
|
||||
return !strncmp(magic.data(), MAGIC, MAGIC_SIZE);
|
||||
if (strncmp(magic.data(), MAGIC, MAGIC_SIZE)) {
|
||||
LOG_ENGINE_ERROR_ << "Check magic failed. Record is " << magic.data() << " while magic is Milvus";
|
||||
fs_ptr->reader_ptr_->Close();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::string>
|
||||
|
@ -118,8 +124,12 @@ CheckSum(const storage::FSHandlerPtr& fs_ptr) {
|
|||
fs_ptr->reader_ptr_->Read(&record, SUM_SIZE);
|
||||
|
||||
uint32_t result = CalculateSum(fs_ptr, true);
|
||||
|
||||
return record == result;
|
||||
if (record != result) {
|
||||
LOG_ENGINE_ERROR_ << "CheckSum failed. Record is " << record << ". Calculate sum is " << result;
|
||||
fs_ptr->reader_ptr_->Close();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Loading…
Reference in New Issue