From 37f6d07884ec9be15b900229388f17a97354b8b7 Mon Sep 17 00:00:00 2001 From: 13914885250 Date: Fri, 18 Apr 2025 10:08:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E7=89=88=E6=9C=AC=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/dss_defs.h | 10 ++++++++++ src/common/persist/dss_diskgroup.c | 5 ++--- src/log/dss_log.c | 5 +++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/common/dss_defs.h b/src/common/dss_defs.h index 3da3ffb..eddd547 100644 --- a/src/common/dss_defs.h +++ b/src/common/dss_defs.h @@ -362,6 +362,16 @@ extern "C" { } \ } while (0) +#define DSS_EXIT_LOG(condition, format, ...) \ + do { \ + if (SECUREC_UNLIKELY(!(condition))) { \ + LOG_RUN_ERR(format, ##__VA_ARGS__); \ + LOG_RUN_ERR("Assertion throws an exception at line %u", (uint32)__LINE__); \ + cm_fync_logfile(); \ + exit(-1); \ + } \ + } while (0) + #define DSS_BYTE_BITS_SIZE 8 // if want change the default, compile the dss with set DSS_PAGE_SIZE=page_size_you_want diff --git a/src/common/persist/dss_diskgroup.c b/src/common/persist/dss_diskgroup.c index b8769f8..78b54b1 100644 --- a/src/common/persist/dss_diskgroup.c +++ b/src/common/persist/dss_diskgroup.c @@ -648,9 +648,8 @@ status_t dss_load_vg_ctrl(dss_vg_info_item_t *vg_item, bool32 is_lock) return CM_ERROR; } if (vg_item->id == 0 && vg_item->dss_ctrl->vg_info.proto_version > DSS_PROTO_VERSION) { - LOG_RUN_ERR("Protocol version %u larger than software version %u.", vg_item->dss_ctrl->vg_info.proto_version, - DSS_PROTO_VERSION); - return CM_ERROR; + DSS_EXIT_LOG(DSS_FALSE, "Protocol version %u larger than software version %u.", + vg_item->dss_ctrl->vg_info.proto_version, DSS_PROTO_VERSION); } date_t date = cm_timeval2date(vg_item->dss_ctrl->vg_info.create_time); diff --git a/src/log/dss_log.c b/src/log/dss_log.c index 8c47091..8b5e289 100644 --- a/src/log/dss_log.c +++ b/src/log/dss_log.c @@ -69,7 +69,7 @@ const char *g_dss_error_desc[DSS_ERROR_COUNT] = { [ERR_DSS_FILE_PATH_ILL] = "Path %s decode error %s", [ERR_DSS_FILE_INVALID_SIZE] = "Invalid extend offset %lld, size %d.", [ERR_DSS_DIR_REMOVE_NOT_EMPTY] = "The dir is not empty, can not remove.", - [ERR_DSS_DIR_CREATE_DUPLICATED] = "Make dir or Create file failed, %s has already existed", + [ERR_DSS_DIR_CREATE_DUPLICATED] = "Make dir or Create file failed, %s has already existed.", [ERR_DSS_LINK_READ_NOT_LINK] = "The path %s is not a soft link.", [ERR_DSS_LINK_CREATE] = "Failed to create symbolic link, reason %s", [ERR_DSS_CONFIG_FILE_OVERSIZED] = "The size of config file %s is too large", @@ -110,7 +110,8 @@ const char *g_dss_error_desc[DSS_ERROR_COUNT] = { [ERR_DSS_INIT_LOGGER_FAILED] = "Log init failed.", [ERR_DSS_OUT_OF_MEM] = "Failed to apply for memory.", [ERR_DSS_INVALID_ID] = "Invalid %s id : %llu.", - [ERR_DSS_PROCESS_REMOTE] = "Failed to process remote, errcode: %d, errmsg: %s.", + // Without . at the end, encapsulates error information of other error codes + [ERR_DSS_PROCESS_REMOTE] = "Failed to process remote, errcode: %d, errmsg: %s", [ERR_DSS_CONNECT_FAILED] = "Failed to connect dss server, errcode: %d, errmsg: %s.", [ERR_DSS_VERSION_NOT_MATCH] = "[CHECK_PROTO]Protocol version need be changed, old protocol version is %u, new protocol version is %u.", -- Gitee