Commit b3837488 authored by chen qingxiang's avatar chen qingxiang Committed by 李盛俊
Browse files

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: default avatargodchen0212 <qingxiang.chen@zilliz.com>

* change the log level to error

Signed-off-by: default avatargodchen0212 <qingxiang.chen@zilliz.com>

* fix cpp lint problem

Signed-off-by: default avatargodchen0212 <qingxiang.chen@zilliz.com>
Signed-off-by: default avatarshengjun.li <shengjun.li@zilliz.com>
parent b29954cd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+13 −3
Original line number Diff line number Diff line
@@ -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