diff --git a/src/common/dss_defs.h b/src/common/dss_defs.h index 3da3ffb013b2064c8945aad8934e724c2e18dc4e..eddd5479d55e3b54f6dcfdc257fb718292bce86f 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 b8769f836b38f832b91eba38bb18e51572299e7a..78b54b1f6f632ce05ad8b8b57eaec5f33de2de93 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 8c470919c7e252f65ca6dda0cd4285827b9e5e74..8b5e289158945f32f4ade39b8169799e47dc1ea8 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.",