fix dblink unknown error code

This commit is contained in:
zzg19950727 2023-09-08 12:43:14 +08:00 committed by ob-robot
parent 5504290af5
commit 659402ae32
5 changed files with 21 additions and 40 deletions

View File

@ -12,6 +12,7 @@
#define USING_LOG_PREFIX LIB_MYSQLC
#include "lib/mysqlclient/ob_dblink_error_trans.h"
#include "share/ob_errno.h"
int __attribute__((weak)) get_oracle_errno(int index)
{
@ -56,39 +57,19 @@ int sqlclient::ObDblinkErrorTrans::external_errno_to_ob_errno(bool is_oracle_err
std::min(STRLEN(oracle_msg_prefix), STRLEN(external_errmsg)))))) {
ob_errno = external_errno; // do not map, show user client errno directly.
} else {
ob_errno = OB_ERR_DBLINK_REMOTE_ECODE; // default ob_errno, if external_errno can not map to any valid ob_errno
if (OB_ISNULL(external_errmsg) || 0 == STRLEN(external_errmsg)) {
for (int i = 0; i < oceanbase::common::OB_MAX_ERROR_CODE; ++i) {
if (external_errno == (is_oracle_err ? get_oracle_errno(i) : get_mysql_errno(i))) {
ob_errno = -i;
break;
}
}
} else {
ObEditDistance ed;
int64_t edit_dist = 0x7fffffffffffffff;
int64_t min_edit_dist = 0x7fffffffffffffff;
for (int i = 0; i < oceanbase::common::OB_MAX_ERROR_CODE; ++i) {
if (external_errno == (is_oracle_err ? get_oracle_errno(i) : get_mysql_errno(i))) {
const char *external_errstr = (is_oracle_err ? get_oracle_str_error(i) : get_mysql_str_error(i));
if (OB_ISNULL(external_errstr)) {
// In the case of a null pointer boundary
edit_dist = 0x7ffffffffffffffe;
} else {
// The edit distance between the strings is used to measure their similarity.
// The smaller the edit distance, the greater the similarity, so as to find the most similar error message.
ObEditDistance::cal_edit_distance(external_errmsg, external_errstr, STRLEN(external_errmsg), STRLEN(external_errstr), edit_dist);
}
if (edit_dist < min_edit_dist) {
ob_errno = -i;
min_edit_dist = edit_dist;
if (0 == min_edit_dist) {
break;
}
}
}
int64_t match_count = 0;
for (int i = 0; i < oceanbase::common::OB_MAX_ERROR_CODE; ++i) {
if (external_errno == (is_oracle_err ? get_oracle_errno(i) : get_mysql_errno(i))) {
ob_errno = -i;
++match_count;
}
}
if (1 != match_count) {
// default ob_errno, if external_errno can not map to any valid ob_errno
ob_errno = OB_ERR_DBLINK_REMOTE_ECODE;
int msg_len = STRLEN(external_errmsg);
LOG_USER_ERROR(OB_ERR_DBLINK_REMOTE_ECODE, external_errno, msg_len, external_errmsg);
}
}
}
return ret;

View File

@ -560,8 +560,8 @@ int ObMySQLConnection::execute_read(const uint64_t tenant_id, const char *sql,
LOG_WARN("create statement failed", KCSTRING(sql), K(ret));
} else if (OB_ISNULL(read_ctx->result_ = read_ctx->stmt_.execute_query(res.is_enable_use_result()))) {
ret = get_last_error();
const int ER_LOCK_WAIT_TIMEOUT = -1205;
if (ER_LOCK_WAIT_TIMEOUT == ret) {
//const int ER_LOCK_WAIT_TIMEOUT = -1205;
if (-1205 == ret) {
LOG_INFO("query failed", K(get_server()), KCSTRING(sql), K(ret));
} else {
LOG_WARN("query failed", K(get_server()), KCSTRING(sql), K(ret));

View File

@ -17583,11 +17583,11 @@ static const _error _error_OB_ERR_DBLINK_REMOTE_ECODE = {
.error_solution = "Contact OceanBase Support",
.mysql_errno = -1,
.sqlstate = "HY000",
.str_error = "Unknown errorcode: %d",
.str_user_error = "Unknown errorcode: %d",
.str_error = "\ndblink remote error code: %d,\nremote error msg: %.*s",
.str_user_error = "\ndblink remote error code: %d,\nremote error msg: %.*s",
.oracle_errno = 600,
.oracle_str_error = "ORA-00600: internal error code, arguments: -5975, Unknown errorcode: %d",
.oracle_str_user_error = "ORA-00600: internal error code, arguments: -5975, Unknown errorcode: %d"
.oracle_str_error = "ORA-00600: internal error code, arguments: -5975, \ndblink remote error code: %d,\nremote error msg: %.*s",
.oracle_str_user_error = "ORA-00600: internal error code, arguments: -5975, \ndblink remote error code: %d,\nremote error msg: %.*s"
};
static const _error _error_OB_ERR_DBLINK_NO_LIB = {
.error_name = "OB_ERR_DBLINK_NO_LIB",

View File

@ -1612,7 +1612,7 @@ DEFINE_ORACLE_ERROR_EXT(OB_ERR_CHECK_OPTION_VIOLATED, -5971, ER_VIEW_CHECK_FAILE
DEFINE_ERROR_EXT(OB_ERR_CHECK_OPTION_ON_NONUPDATABLE_VIEW, -5972, ER_VIEW_NONUPD_CHECK, "HY000", "CHECK OPTION on non-updatable view", "CHECK OPTION on non-updatable view '%.*s.%.*s'");
DEFINE_ORACLE_ERROR(OB_ERR_NO_DESC_FOR_POS, -5973, -1, "HY000", "no descriptor for this position", 24334, "no descriptor for this position");
DEFINE_ORACLE_ERROR(OB_ERR_ILL_OBJ_FLAG, -5974, -1, "HY000", "object specified is incompatible with the flag specified", 4047, "object specified is incompatible with the flag specified");
DEFINE_ERROR_DEP(OB_ERR_DBLINK_REMOTE_ECODE, -5975, -1, "HY000", "Unknown errorcode: %d", "dblink remote ora error code: %d");
DEFINE_ERROR_DEP(OB_ERR_DBLINK_REMOTE_ECODE, -5975, -1, "HY000", "\ndblink remote error code: %d,\nremote error msg: %.*s", "\ndblink remote error code: %d,\nremote error msg: %.*s");
DEFINE_ERROR_DEP(OB_ERR_DBLINK_NO_LIB, -5976, -1, "HY000", "oci lib not founded");
DEFINE_ORACLE_ERROR(OB_ERR_PARTITION_EXTENDED_ON_VIEW, -5977, -1, "HY000", "partition-extended object names may only be used with tables and editioning views", 14109, "partition-extended object names may only be used with tables and editioning views");
DEFINE_ORACLE_ERROR(OB_ERR_NOT_ALL_VARIABLE_BIND, -5978, -1, "HY000", "not all variables bound", 1008, "not all variables bound");

View File

@ -3251,7 +3251,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ERR_CHECK_OPTION_ON_NONUPDATABLE_VIEW__USER_ERROR_MSG "CHECK OPTION on non-updatable view '%.*s.%.*s'"
#define OB_ERR_NO_DESC_FOR_POS__USER_ERROR_MSG "no descriptor for this position"
#define OB_ERR_ILL_OBJ_FLAG__USER_ERROR_MSG "object specified is incompatible with the flag specified"
#define OB_ERR_DBLINK_REMOTE_ECODE__USER_ERROR_MSG "Unknown errorcode: %d"
#define OB_ERR_DBLINK_REMOTE_ECODE__USER_ERROR_MSG "\ndblink remote error code: %d,\nremote error msg: %.*s"
#define OB_ERR_DBLINK_NO_LIB__USER_ERROR_MSG "oci lib not founded"
#define OB_ERR_PARTITION_EXTENDED_ON_VIEW__USER_ERROR_MSG "partition-extended object names may only be used with tables and editioning views"
#define OB_ERR_NOT_ALL_VARIABLE_BIND__USER_ERROR_MSG "not all variables bound"
@ -5379,7 +5379,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ERR_CHECK_OPTION_ON_NONUPDATABLE_VIEW__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5972, CHECK OPTION on non-updatable view '%.*s.%.*s'"
#define OB_ERR_NO_DESC_FOR_POS__ORA_USER_ERROR_MSG "ORA-24334: no descriptor for this position"
#define OB_ERR_ILL_OBJ_FLAG__ORA_USER_ERROR_MSG "ORA-04047: object specified is incompatible with the flag specified"
#define OB_ERR_DBLINK_REMOTE_ECODE__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5975, Unknown errorcode: %d"
#define OB_ERR_DBLINK_REMOTE_ECODE__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5975, \ndblink remote error code: %d,\nremote error msg: %.*s"
#define OB_ERR_DBLINK_NO_LIB__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5976, oci lib not founded"
#define OB_ERR_PARTITION_EXTENDED_ON_VIEW__ORA_USER_ERROR_MSG "ORA-14109: partition-extended object names may only be used with tables and editioning views"
#define OB_ERR_NOT_ALL_VARIABLE_BIND__ORA_USER_ERROR_MSG "ORA-01008: not all variables bound"