mirror of https://github.com/milvus-io/milvus.git
Support error code in segcore
Signed-off-by: FluorineDog <guilin.gou@zilliz.com>pull/4973/head^2
parent
ab2385147c
commit
f39dcdb8f3
|
@ -76,11 +76,11 @@ timeout(time: "${regressionTimeout}", unit: 'MINUTES') {
|
|||
|
||||
sh "mkdir -p ${env.DEV_TEST_ARTIFACTS_PATH}"
|
||||
sh "kubectl cp -n ${env.HELM_RELEASE_NAMESPACE} \$(kubectl get pod -n ${env.HELM_RELEASE_NAMESPACE} -l ${milvusLabels} -o jsonpath='{range.items[0]}{.metadata.name}'):logs ${env.DEV_TEST_ARTIFACTS_PATH}"
|
||||
sh "kubectl logs -n ${env.HELM_RELEASE_NAMESPACE} \$(kubectl get pod -n ${env.HELM_RELEASE_NAMESPACE} -l ${etcdLabels} -o jsonpath='{range.items[*]}{.metadata.name} ') > ${env.DEV_TEST_ARTIFACTS_PATH}/etcd-${REGRESSION_SERVICE_TYPE}.log"
|
||||
sh "kubectl logs -n ${env.HELM_RELEASE_NAMESPACE} \$(kubectl get pod -n ${env.HELM_RELEASE_NAMESPACE} -l ${minioLables} -o jsonpath='{range.items[*]}{.metadata.name} ') > ${env.DEV_TEST_ARTIFACTS_PATH}/minio-${REGRESSION_SERVICE_TYPE}.log"
|
||||
// if ("${REGRESSION_SERVICE_TYPE}" == "distributed") {
|
||||
// sh "kubectl logs -n ${env.HELM_RELEASE_NAMESPACE} \$(kubectl get pod -n ${env.HELM_RELEASE_NAMESPACE} -l ${pulsarLabels} -o jsonpath='{range.items[*]}{.metadata.name} ') > ${env.DEV_TEST_ARTIFACTS_PATH}/pulsar-${REGRESSION_SERVICE_TYPE}.log"
|
||||
// }
|
||||
sh "kubectl logs --all-containers=true -n ${env.HELM_RELEASE_NAMESPACE} -l ${etcdLabels} > ${env.DEV_TEST_ARTIFACTS_PATH}/etcd-${REGRESSION_SERVICE_TYPE}.log"
|
||||
sh "kubectl logs --all-containers=true -n ${env.HELM_RELEASE_NAMESPACE} -l ${minioLables} > ${env.DEV_TEST_ARTIFACTS_PATH}/minio-${REGRESSION_SERVICE_TYPE}.log"
|
||||
if ("${REGRESSION_SERVICE_TYPE}" == "distributed") {
|
||||
sh "kubectl logs --all-containers=true -n ${env.HELM_RELEASE_NAMESPACE} -l ${pulsarLabels} > ${env.DEV_TEST_ARTIFACTS_PATH}/pulsar-${REGRESSION_SERVICE_TYPE}.log"
|
||||
}
|
||||
archiveArtifacts artifacts: "${env.DEV_TEST_ARTIFACTS_PATH}/**", allowEmptyArchive: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ IndexBuilder_build(benchmark::State& state) {
|
|||
|
||||
for (auto _ : state) {
|
||||
auto index =
|
||||
std::make_unique<milvus::indexbuilder::IndexWrapper>(type_params_str.c_str(), index_params_str.c_str());
|
||||
std::make_unique<milvus::indexbuilder::IndexWrapper>(type_params_str.c_str(), index_params_str.c_str());
|
||||
index->BuildWithoutIds(xb_dataset);
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ IndexBuilder_build_and_codec(benchmark::State& state) {
|
|||
|
||||
for (auto _ : state) {
|
||||
auto index =
|
||||
std::make_unique<milvus::indexbuilder::IndexWrapper>(type_params_str.c_str(), index_params_str.c_str());
|
||||
std::make_unique<milvus::indexbuilder::IndexWrapper>(type_params_str.c_str(), index_params_str.c_str());
|
||||
|
||||
index->BuildWithoutIds(xb_dataset);
|
||||
index->Serialize();
|
||||
|
|
|
@ -23,6 +23,7 @@ foreach (DIR ${INDEX_INCLUDE_DIRS})
|
|||
endforeach ()
|
||||
|
||||
|
||||
add_subdirectory( exceptions )
|
||||
add_subdirectory( utils )
|
||||
add_subdirectory( log )
|
||||
add_subdirectory( pb )
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#pragma once
|
||||
#include "common/Types.h"
|
||||
#include "utils/Status.h"
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <optional>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
// or implied. See the License for the specific language governing permissions and limitations under the License
|
||||
|
||||
#include "common/SystemProperty.h"
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include <yaml-cpp/yaml.h>
|
||||
#include "common/Types.h"
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
//
|
||||
#include "common/Types.h"
|
||||
#include <knowhere/index/vector_index/helpers/IndexParameter.h>
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include <boost/bimap.hpp>
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
// or implied. See the License for the specific language governing permissions and limitations under the License
|
||||
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -26,7 +27,8 @@ typedef enum SegmentType SegmentType;
|
|||
|
||||
enum ErrorCode {
|
||||
Success = 0,
|
||||
UnexpectedException = 1,
|
||||
UnexpectedError = 1,
|
||||
IllegalArgument = 5,
|
||||
};
|
||||
|
||||
typedef struct CStatus {
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
set(exceptions_files
|
||||
EasyAssert.cpp
|
||||
)
|
||||
|
||||
add_library(milvus_exceptions ${exceptions_files})
|
||||
target_link_libraries(milvus_exceptions milvus_proto)
|
|
@ -30,8 +30,13 @@ EasyStackTrace() {
|
|||
}
|
||||
|
||||
void
|
||||
EasyAssertInfo(
|
||||
bool value, std::string_view expr_str, std::string_view filename, int lineno, std::string_view extra_info) {
|
||||
EasyAssertInfo(bool value,
|
||||
std::string_view expr_str,
|
||||
std::string_view filename,
|
||||
int lineno,
|
||||
std::string_view extra_info,
|
||||
ErrorCodeEnum error_code) {
|
||||
// enable error code
|
||||
if (!value) {
|
||||
std::string info;
|
||||
info += "Assert \"" + std::string(expr_str) + "\"";
|
||||
|
@ -40,17 +45,17 @@ EasyAssertInfo(
|
|||
info += " => " + std::string(extra_info);
|
||||
}
|
||||
|
||||
throw std::runtime_error(info + "\n" + EasyStackTrace());
|
||||
throw SegcoreError(error_code, info + "\n" + EasyStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
[[noreturn]] void
|
||||
ThrowWithTrace(const std::exception& exception) {
|
||||
if (typeid(exception) == typeid(WrappedRuntimeError)) {
|
||||
if (typeid(exception) == typeid(SegcoreError)) {
|
||||
throw exception;
|
||||
}
|
||||
auto err_msg = exception.what() + std::string("\n") + EasyStackTrace();
|
||||
throw WrappedRuntimeError(err_msg);
|
||||
throw SegcoreError(ErrorCodeEnum::UnexpectedError, err_msg);
|
||||
}
|
||||
|
||||
} // namespace milvus::impl
|
|
@ -15,22 +15,39 @@
|
|||
#include <exception>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include "pb/common.pb.h"
|
||||
|
||||
/* Paste this on the file you want to debug. */
|
||||
|
||||
namespace milvus {
|
||||
using ErrorCodeEnum = proto::common::ErrorCode;
|
||||
namespace impl {
|
||||
void
|
||||
EasyAssertInfo(
|
||||
bool value, std::string_view expr_str, std::string_view filename, int lineno, std::string_view extra_info);
|
||||
EasyAssertInfo(bool value,
|
||||
std::string_view expr_str,
|
||||
std::string_view filename,
|
||||
int lineno,
|
||||
std::string_view extra_info,
|
||||
ErrorCodeEnum error_code = ErrorCodeEnum::UnexpectedError);
|
||||
|
||||
[[noreturn]] void
|
||||
ThrowWithTrace(const std::exception& exception);
|
||||
|
||||
} // namespace impl
|
||||
|
||||
class WrappedRuntimeError : public std::runtime_error {
|
||||
using std::runtime_error::runtime_error;
|
||||
class SegcoreError : public std::runtime_error {
|
||||
public:
|
||||
SegcoreError(ErrorCodeEnum error_code, const std::string& error_msg)
|
||||
: error_code_(error_code), std::runtime_error(error_msg) {
|
||||
}
|
||||
|
||||
ErrorCodeEnum
|
||||
get_error_code() {
|
||||
return error_code_;
|
||||
}
|
||||
|
||||
private:
|
||||
ErrorCodeEnum error_code_;
|
||||
};
|
||||
|
||||
} // namespace milvus
|
||||
|
@ -50,3 +67,9 @@ class WrappedRuntimeError : public std::runtime_error {
|
|||
milvus::impl::EasyAssertInfo(false, (info), __FILE__, __LINE__, ""); \
|
||||
__builtin_unreachable(); \
|
||||
} while (0)
|
||||
|
||||
#define PanicCodeInfo(errcode, info) \
|
||||
do { \
|
||||
milvus::impl::EasyAssertInfo(false, (info), __FILE__, __LINE__, "", errcode); \
|
||||
__builtin_unreachable(); \
|
||||
} while (0)
|
|
@ -16,7 +16,7 @@
|
|||
#include "pb/index_cgo_msg.pb.h"
|
||||
#include "knowhere/index/vector_index/VecIndexFactory.h"
|
||||
#include "knowhere/index/vector_index/helpers/IndexParameter.h"
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "IndexWrapper.h"
|
||||
#include "indexbuilder/utils.h"
|
||||
#include "index/knowhere/knowhere/index/vector_index/ConfAdapterMgr.h"
|
||||
|
|
|
@ -36,7 +36,7 @@ CreateIndex(const char* serialized_type_params, const char* serialized_index_par
|
|||
status.error_code = Success;
|
||||
status.error_msg = "";
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
}
|
||||
return status;
|
||||
|
@ -60,7 +60,7 @@ BuildFloatVecIndexWithoutIds(CIndex index, int64_t float_value_num, const float*
|
|||
status.error_code = Success;
|
||||
status.error_msg = "";
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
}
|
||||
return status;
|
||||
|
@ -78,7 +78,7 @@ BuildBinaryVecIndexWithoutIds(CIndex index, int64_t data_size, const uint8_t* ve
|
|||
status.error_code = Success;
|
||||
status.error_msg = "";
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
}
|
||||
return status;
|
||||
|
@ -96,7 +96,7 @@ SerializeToSlicedBuffer(CIndex index, CBinary* c_binary) {
|
|||
status.error_code = Success;
|
||||
status.error_msg = "";
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
}
|
||||
return status;
|
||||
|
@ -138,7 +138,7 @@ LoadFromSlicedBuffer(CIndex index, const char* serialized_sliced_blob_buffer, in
|
|||
status.error_code = Success;
|
||||
status.error_msg = "";
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
}
|
||||
return status;
|
||||
|
@ -158,7 +158,7 @@ QueryOnFloatVecIndex(CIndex index, int64_t float_value_num, const float* vectors
|
|||
status.error_code = Success;
|
||||
status.error_msg = "";
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
}
|
||||
return status;
|
||||
|
@ -182,7 +182,7 @@ QueryOnFloatVecIndexWithParam(CIndex index,
|
|||
status.error_code = Success;
|
||||
status.error_msg = "";
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
}
|
||||
return status;
|
||||
|
@ -202,7 +202,7 @@ QueryOnBinaryVecIndex(CIndex index, int64_t data_size, const uint8_t* vectors, C
|
|||
status.error_code = Success;
|
||||
status.error_msg = "";
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
}
|
||||
return status;
|
||||
|
@ -226,7 +226,7 @@ QueryOnBinaryVecIndexWithParam(CIndex index,
|
|||
status.error_code = Success;
|
||||
status.error_msg = "";
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
}
|
||||
return status;
|
||||
|
@ -242,7 +242,7 @@ CreateQueryResult(CIndexQueryResult* res) {
|
|||
status.error_code = Success;
|
||||
status.error_msg = "";
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
}
|
||||
return status;
|
||||
|
@ -288,7 +288,7 @@ DeleteIndexQueryResult(CIndexQueryResult res) {
|
|||
status.error_code = Success;
|
||||
status.error_msg = "";
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
}
|
||||
return status;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "query/PlanNode.h"
|
||||
#include "query/ExprImpl.h"
|
||||
#include "utils/Json.h"
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "pb/milvus.pb.h"
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "Plan.h"
|
||||
#include "utils/Json.h"
|
||||
#include "PlanNode.h"
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "pb/milvus.pb.h"
|
||||
#include <memory>
|
||||
#include <map>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License
|
||||
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "query/SubQueryResult.h"
|
||||
#include "segcore/Reduce.h"
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// Generated File
|
||||
// DO NOT EDIT
|
||||
#include "query/Plan.h"
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "utils/Json.h"
|
||||
#include <utility>
|
||||
#include "ExprVisitor.h"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#pragma once
|
||||
// Generated File
|
||||
// DO NOT EDIT
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "utils/Json.h"
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
// or implied. See the License for the specific language governing permissions and limitations under the License
|
||||
|
||||
#include "query/Plan.h"
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "utils/Json.h"
|
||||
#include <utility>
|
||||
#include "query/generated/ShowExprVisitor.h"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License
|
||||
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "utils/Json.h"
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
|
|
@ -58,7 +58,7 @@ InferIndexType(const Json& search_params) {
|
|||
return key_list.at(key);
|
||||
}
|
||||
}
|
||||
PanicInfo("failed to infer index type");
|
||||
PanicCodeInfo(ErrorCodeEnum::IllegalArgument, "failed to infer index type");
|
||||
}
|
||||
|
||||
static knowhere::IndexType
|
||||
|
@ -85,7 +85,9 @@ VerifyPlanNodeVisitor::visit(FloatVectorANNS& node) {
|
|||
|
||||
// NOTE: the second parameter is not checked in knowhere, may be redundant
|
||||
auto passed = adapter->CheckSearch(params_copy, inferred_type, index_mode);
|
||||
AssertInfo(passed, "invalid search params");
|
||||
if (!passed) {
|
||||
PanicCodeInfo(ErrorCodeEnum::IllegalArgument, "invalid search params");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -101,7 +103,9 @@ VerifyPlanNodeVisitor::visit(BinaryVectorANNS& node) {
|
|||
|
||||
// NOTE: the second parameter is not checked in knowhere, may be redundant
|
||||
auto passed = adapter->CheckSearch(params_copy, inferred_type, index_mode);
|
||||
AssertInfo(passed, "invalid search params");
|
||||
if (!passed) {
|
||||
PanicCodeInfo(ErrorCodeEnum::IllegalArgument, "invalid search params");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace milvus::query
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <shared_mutex>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "utils/tools.h"
|
||||
#include <boost/container/vector.hpp>
|
||||
#include "common/Types.h"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <utility>
|
||||
#include <memory>
|
||||
#include <tbb/concurrent_hash_map.h>
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "knowhere/index/vector_index/VecIndex.h"
|
||||
#include "common/Types.h"
|
||||
|
||||
|
|
|
@ -96,10 +96,10 @@ SegcoreConfig::parse_from(const std::string& config_path) {
|
|||
result.table_[metric_type] = conf;
|
||||
}
|
||||
}
|
||||
} catch (const WrappedRuntimeError& e) {
|
||||
} catch (const SegcoreError& e) {
|
||||
// re-throw
|
||||
throw e;
|
||||
} catch (std::exception& e) {
|
||||
} catch (const std::exception& e) {
|
||||
PanicInfo(std::string("Invalid Yaml:\n") + e.what());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "query/deprecated/GeneralQuery.h"
|
||||
#include "utils/Status.h"
|
||||
#include "segcore/DeletedRecord.h"
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "FieldIndexing.h"
|
||||
#include "InsertRecord.h"
|
||||
#include <utility>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "query/deprecated/GeneralQuery.h"
|
||||
#include "utils/Status.h"
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
#include "segcore/SegmentBase.h"
|
||||
#include "segcore/AckResponder.h"
|
||||
#include "segcore/ConcurrentVector.h"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "index/knowhere/knowhere/index/vector_index/VecIndexFactory.h"
|
||||
#include "segcore/load_index_c.h"
|
||||
#include "common/LoadInfo.h"
|
||||
#include "utils/EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
|
||||
CStatus
|
||||
NewLoadIndexInfo(CLoadIndexInfo* c_load_index_info) {
|
||||
|
@ -26,7 +26,7 @@ NewLoadIndexInfo(CLoadIndexInfo* c_load_index_info) {
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ AppendIndexParam(CLoadIndexInfo c_load_index_info, const char* c_index_key, cons
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ AppendFieldInfo(CLoadIndexInfo c_load_index_info, int64_t field_id) {
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ AppendIndex(CLoadIndexInfo c_load_index_info, CBinarySet c_binary_set) {
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ NewBinarySet(CBinarySet* c_binary_set) {
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ AppendBinaryIndex(CBinarySet c_binary_set, void* index_binary, int64_t index_siz
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -26,9 +26,15 @@ CreatePlan(CCollection c_col, const char* dsl, CPlan* res_plan) {
|
|||
auto plan = (CPlan)res.release();
|
||||
*res_plan = plan;
|
||||
return status;
|
||||
} catch (milvus::SegcoreError& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = e.get_error_code();
|
||||
status.error_msg = strdup(e.what());
|
||||
*res_plan = nullptr;
|
||||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
*res_plan = nullptr;
|
||||
return status;
|
||||
|
@ -54,7 +60,7 @@ ParsePlaceholderGroup(CPlan c_plan,
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
*res_placeholder_group = nullptr;
|
||||
return status;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
// or implied. See the License for the specific language governing permissions and limitations under the License
|
||||
|
||||
#include <vector>
|
||||
#include <utils/EasyAssert.h>
|
||||
#include <exceptions/EasyAssert.h>
|
||||
#include "segcore/reduce_c.h"
|
||||
|
||||
#include "segcore/Reduce.h"
|
||||
|
@ -155,7 +155,7 @@ ReduceQueryResults(CQueryResult* c_search_results, int64_t num_segments, bool* i
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ ReorganizeQueryResults(CMarshaledHits* c_marshaled_hits,
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
*c_marshaled_hits = nullptr;
|
||||
return status;
|
||||
|
|
|
@ -88,7 +88,7 @@ Search(CSegmentInterface c_segment,
|
|||
status.error_code = Success;
|
||||
status.error_msg = "";
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ FillTargetEntry(CSegmentInterface c_segment, CPlan c_plan, CQueryResult c_result
|
|||
status.error_code = Success;
|
||||
status.error_msg = "";
|
||||
} catch (std::runtime_error& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
}
|
||||
return status;
|
||||
|
@ -166,7 +166,7 @@ Insert(CSegmentInterface c_segment,
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ PreInsert(CSegmentInterface c_segment, int64_t size, int64_t* offset) {
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ Delete(CSegmentInterface c_segment,
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ LoadFieldData(CSegmentInterface c_segment, CLoadFieldDataInfo load_field_data_in
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ UpdateSealedSegmentIndex(CSegmentInterface c_segment, CLoadIndexInfo c_load_inde
|
|||
status.error_msg = "";
|
||||
return status;
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ DropFieldData(CSegmentInterface c_segment, int64_t field_id) {
|
|||
return status;
|
||||
} catch (std::exception& e) {
|
||||
auto status = CStatus();
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ DropSealedSegmentIndex(CSegmentInterface c_segment, int64_t field_id) {
|
|||
status.error_msg = "";
|
||||
return status;
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ UpdateSegmentIndex(CSegmentInterface c_segment, CLoadIndexInfo c_load_index_info
|
|||
status.error_msg = "";
|
||||
return status;
|
||||
} catch (std::exception& e) {
|
||||
status.error_code = UnexpectedException;
|
||||
status.error_code = UnexpectedError;
|
||||
status.error_msg = strdup(e.what());
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -15,4 +15,4 @@ aux_source_directory( ${MILVUS_ENGINE_SRC}/utils UTILS_FILES )
|
|||
|
||||
add_library( milvus_utils STATIC ${UTILS_FILES} )
|
||||
|
||||
target_link_libraries( milvus_utils PRIVATE fiu )
|
||||
target_link_libraries( milvus_utils PRIVATE fiu milvus_exceptions)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include "EasyAssert.h"
|
||||
#include "exceptions/EasyAssert.h"
|
||||
namespace milvus {
|
||||
inline int64_t
|
||||
upper_align(int64_t value, int64_t align) {
|
||||
|
|
|
@ -415,8 +415,8 @@ func (colReplica *collectionReplica) removeSegmentPrivate(segmentID UniqueID) er
|
|||
return err
|
||||
}
|
||||
|
||||
partition, err := colReplica.getPartitionByIDPrivate(segment.partitionID)
|
||||
if err != nil {
|
||||
partition, err2 := colReplica.getPartitionByIDPrivate(segment.partitionID)
|
||||
if err2 != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package querynode
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -I${SRCDIR}/../core/output/include
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../core/output/lib -lmilvus_segcore -Wl,-rpath=${SRCDIR}/../core/output/lib
|
||||
|
||||
#include <malloc.h>
|
||||
#include "common/type_c.h"
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/zilliztech/milvus-distributed/internal/log"
|
||||
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func HandleCStatus(status *C.CStatus, extraInfo string) error {
|
||||
if status.error_code == 0 {
|
||||
return nil
|
||||
}
|
||||
errorCode := status.error_code
|
||||
errorName, ok := commonpb.ErrorCode_name[int32(errorCode)]
|
||||
if !ok {
|
||||
errorName = "UnknownError"
|
||||
}
|
||||
errorMsg := C.GoString(status.error_msg)
|
||||
defer C.free(unsafe.Pointer(status.error_msg))
|
||||
|
||||
finalMsg := fmt.Sprintf("[%s] %s", errorName, errorMsg)
|
||||
logMsg := fmt.Sprintf("%s, C Runtime Exception: %s\n", extraInfo, finalMsg)
|
||||
log.Error(logMsg)
|
||||
return errors.New(finalMsg)
|
||||
}
|
|
@ -10,7 +10,6 @@ package querynode
|
|||
*/
|
||||
import "C"
|
||||
import (
|
||||
"strconv"
|
||||
"unsafe"
|
||||
|
||||
"errors"
|
||||
|
@ -25,12 +24,8 @@ func createPlan(col Collection, dsl string) (*Plan, error) {
|
|||
var cPlan C.CPlan
|
||||
status := C.CreatePlan(col.collectionPtr, cDsl, &cPlan)
|
||||
|
||||
errorCode := status.error_code
|
||||
|
||||
if errorCode != 0 {
|
||||
errorMsg := C.GoString(status.error_msg)
|
||||
defer C.free(unsafe.Pointer(status.error_msg))
|
||||
return nil, errors.New("Create plan failed, C runtime error detected, error code = " + strconv.Itoa(int(errorCode)) + ", error msg = " + errorMsg)
|
||||
if err := HandleCStatus(&status, "Create Plan failed"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var newPlan = &Plan{cPlan: cPlan}
|
||||
|
@ -66,12 +61,8 @@ func parserPlaceholderGroup(plan *Plan, placeHolderBlob []byte) (*PlaceholderGro
|
|||
var cPlaceholderGroup C.CPlaceholderGroup
|
||||
status := C.ParsePlaceholderGroup(plan.cPlan, blobPtr, blobSize, &cPlaceholderGroup)
|
||||
|
||||
errorCode := status.error_code
|
||||
|
||||
if errorCode != 0 {
|
||||
errorMsg := C.GoString(status.error_msg)
|
||||
defer C.free(unsafe.Pointer(status.error_msg))
|
||||
return nil, errors.New("Parser placeholder group failed, C runtime error detected, error code = " + strconv.Itoa(int(errorCode)) + ", error msg = " + errorMsg)
|
||||
if err := HandleCStatus(&status, "parser placeholder group failed"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var newPlaceholderGroup = &PlaceholderGroup{cPlaceholderGroup: cPlaceholderGroup}
|
||||
|
|
Loading…
Reference in New Issue