[FEAT MERGE] implement mysql dblink and read consistency

Co-authored-by: xianyu-w <707512433@qq.com>
Co-authored-by: sdc <njucssdc@gmail.com>
Co-authored-by: seuwebber <webber_code@163.com>
This commit is contained in:
cqliang1995
2023-05-09 18:32:03 +00:00
committed by ob-robot
parent 38b78ad442
commit 4108e781d4
132 changed files with 2726 additions and 818 deletions

View File

@ -17236,10 +17236,10 @@ static const _error _error_OB_ERR_DBLINK_REMOTE_ECODE = {
.mysql_errno = -1,
.sqlstate = "HY000",
.str_error = "Unknown errorcode: %d",
.str_user_error = "dblink remote ora error code: %d",
.str_user_error = "Unknown errorcode: %d",
.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, dblink remote ora error code: %d"
.oracle_str_user_error = "ORA-00600: internal error code, arguments: -5975, Unknown errorcode: %d"
};
static const _error _error_OB_ERR_DBLINK_NO_LIB = {
.error_name = "OB_ERR_DBLINK_NO_LIB",
@ -26987,6 +26987,26 @@ inline const _error *get_error(int index)
return _errors[index];
}
int get_oracle_errno(int index)
{
return get_error(index)->oracle_errno;
}
int get_mysql_errno(int index)
{
return get_error(index)->mysql_errno;
}
const char* get_oracle_str_error(int index)
{
return get_error(index)->oracle_str_error;
}
const char* get_mysql_str_error(int index)
{
return get_error(index)->str_error;
}
namespace oceanbase
{
namespace common
@ -27107,57 +27127,6 @@ int g_all_ob_errnos[2072] = {0, -4000, -4001, -4002, -4003, -4004, -4005, -4006,
}
return ret;
}
#ifndef __ERROR_CODE_PARSER_
int get_ob_errno_from_oracle_errno(const int error_no, const char *error_msg, int &ob_errno) {
const int orcl_errno = abs(error_no);
ob_errno = error_no;
int64_t edit_dist = 0x7fffffffffffffff;
int64_t min_edit_dist = 0x7fffffffffffffff;
if (-4016 == error_no || // error_no mayby oceanbase inner errro number sometimes, need skip it
-4013 == error_no ||
-4012 == error_no ||
-4007 == error_no ||
-4002 == error_no) {
} else if (-2013 == error_no || // error_no mayby mysql inner errro number sometimes
-2006 == error_no) {
ob_errno = OB_ERR_UNEXPECTED;
LOG_USER_ERROR(OB_ERR_UNEXPECTED, "local server's dblink can not connect to remote sever by mysqlclient(interal error code: 2006 or 2013)");
} else if (nullptr == error_msg) { // error_no maybe oracle inner error number at most times.
for (int i = 0; i < OB_MAX_ERROR_CODE; ++i) {
if (orcl_errno == get_error(i)->oracle_errno) {
ob_errno = -i;
break;
}
}
} else {
ObEditDistance ed;
for (int i = 0; i < OB_MAX_ERROR_CODE; ++i) {
if (orcl_errno == get_error(i)->oracle_errno) {
const char *orcl_str_error = get_error(i)->oracle_str_user_error;
if (nullptr == orcl_str_error) {
// In the case of a null pointer boundary,
// the reason for setting edit_distance to 0x7ffffffffffffffe is to deal with the situation where
// error_msg does not match ORACLE_STR_USER_ERROR[i] but orcl_errno == ORACLE_ERRNO[i].
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(error_msg, orcl_str_error, STRLEN(error_msg), STRLEN(orcl_str_error), edit_dist);
}
if (edit_dist < min_edit_dist) {
ob_errno = -i;
min_edit_dist = edit_dist;
if (0 == min_edit_dist) {
break;
}
}
}
}
}
LOG_TRACE("trace the ob_errno and oracle_errno.", K(ob_errno), K(error_no), K(min_edit_dist));
return OB_SUCCESS;
}
#endif
int ob_oracle_errno(const int err)
{
int ret = -1;