fix order autoinc cache retry code logical

This commit is contained in:
obdev
2023-07-08 11:11:58 +00:00
committed by ob-robot
parent ad5aa42e83
commit 810d4a8ecd
7 changed files with 48 additions and 7 deletions

View File

@ -611,6 +611,21 @@ private:
}
};
class ObAutoincCacheNotEqualRetryPolicy: public ObRetryPolicy
{
public:
ObAutoincCacheNotEqualRetryPolicy() = default;
~ObAutoincCacheNotEqualRetryPolicy() = default;
virtual void test(ObRetryParam &v) const override
{
if (v.stmt_retry_times_ < ObQueryRetryCtrl::MAX_SCHEMA_ERROR_LOCAL_RETRY_TIMES) {
v.retry_type_ = RETRY_TYPE_LOCAL;
} else {
try_packet_retry(v);
}
}
};
////////// end of policies ////////////
@ -698,6 +713,14 @@ void ObQueryRetryCtrl::schema_error_proc(ObRetryParam &v)
retry_obj.test(schema_update_policy);
}
void ObQueryRetryCtrl::autoinc_cache_not_equal_retry_proc(ObRetryParam &v)
{
ObRetryObject retry_obj(v);
ObAutoincCacheNotEqualRetryPolicy autoinc_retry_policy;
ObCommonRetryLinearShortWaitPolicy retry_short_wait;
retry_obj.test(autoinc_retry_policy).test(retry_short_wait);
}
void ObQueryRetryCtrl::snapshot_discard_proc(ObRetryParam &v)
{
if (ObQueryRetryCtrl::is_isolation_RR_or_SE(v.session_.get_tx_isolation())) {
@ -935,6 +958,7 @@ int ObQueryRetryCtrl::init()
ERR_RETRY_FUNC("SCHEMA", OB_SCHEMA_EAGAIN, schema_error_proc, inner_schema_error_proc, nullptr);
ERR_RETRY_FUNC("SCHEMA", OB_SCHEMA_NOT_UPTODATE, schema_error_proc, inner_schema_error_proc, nullptr);
ERR_RETRY_FUNC("SCHEMA", OB_ERR_PARALLEL_DDL_CONFLICT, schema_error_proc, inner_schema_error_proc, nullptr);
ERR_RETRY_FUNC("SCHEMA", OB_AUTOINC_CACHE_NOT_EQUAL, autoinc_cache_not_equal_retry_proc, autoinc_cache_not_equal_retry_proc, nullptr);
/* location */
ERR_RETRY_FUNC("LOCATION", OB_LOCATION_LEADER_NOT_EXIST, location_error_nothing_readable_proc, inner_location_error_nothing_readable_proc, ObDASRetryCtrl::tablet_location_retry_proc);

View File

@ -303,6 +303,7 @@ private:
static void force_local_retry_proc(ObRetryParam &v);
static void switch_consumer_group_retry_proc(ObRetryParam &v);
static void timeout_proc(ObRetryParam &v);
static void autoinc_cache_not_equal_retry_proc(ObRetryParam &v);
// processors for inner SQL error codes only

View File

@ -877,7 +877,7 @@ int ObAutoincrementService::get_table_node(const AutoincParam &param, TableNode
table_node->autoinc_version_ = autoinc_version;
// old request cannot get table node, it should retry
} else if (OB_UNLIKELY(autoinc_version < table_node->autoinc_version_)) {
ret = OB_SCHEMA_ERROR;
ret = OB_AUTOINC_CACHE_NOT_EQUAL;
LOG_WARN("old reqeust can not get table node, it should retry", KR(ret), K(autoinc_version), K(table_node->autoinc_version_));
}
table_node->alloc_mutex_.unlock();
@ -1780,7 +1780,7 @@ int ObAutoIncInnerTableProxy::check_inner_autoinc_version(const int64_t &request
K(inner_autoinc_version), K(request_autoinc_version));
// old request
} else if (OB_UNLIKELY(inner_autoinc_version > request_autoinc_version)) {
ret = OB_SCHEMA_ERROR;
ret = OB_AUTOINC_CACHE_NOT_EQUAL;
LOG_WARN("inner_autoinc_version is greater than autoinc_version, request needs retry", KR(ret), K(key),
K(inner_autoinc_version), K(request_autoinc_version));
}

File diff suppressed because one or more lines are too long

View File

@ -451,6 +451,7 @@ DEFINE_ERROR_DEP(OB_ERR_THREAD_PANIC, -4396, -1, "HY000", "Worker thread panic,
DEFINE_ERROR(OB_ENCODING_EST_SIZE_OVERFLOW, -4397, -1, "HY000", "Encoding estimated size overflow");
DEFINE_ORACLE_ERROR(OB_INVALID_SUB_PARTITION_TYPE, -4398, 1500, "HY000", "It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning", 14020, "this physical attribute may not be specified for a table partition");
DEFINE_ERROR(OB_ERR_UNEXPECTED_UNIT_STATUS, -4399, -1, "HY000", "Unit status is not expected");
DEFINE_ERROR(OB_AUTOINC_CACHE_NOT_EQUAL, -4400, -1, "HY000", "Autoinc cache's autoinc version is not equal to request's autoinc version");
////////////////////////////////////////////////////////////////
//error code for root server & server management -4500 ---- -5000

View File

@ -265,6 +265,7 @@ constexpr int OB_ERR_OBSERVICE_START = -4395;
constexpr int OB_ENCODING_EST_SIZE_OVERFLOW = -4397;
constexpr int OB_INVALID_SUB_PARTITION_TYPE = -4398;
constexpr int OB_ERR_UNEXPECTED_UNIT_STATUS = -4399;
constexpr int OB_AUTOINC_CACHE_NOT_EQUAL = -4400;
constexpr int OB_IMPORT_NOT_IN_SERVER = -4505;
constexpr int OB_CONVERT_ERROR = -4507;
constexpr int OB_BYPASS_TIMEOUT = -4510;
@ -4217,6 +4218,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ENCODING_EST_SIZE_OVERFLOW__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4397, Encoding estimated size overflow"
#define OB_INVALID_SUB_PARTITION_TYPE__ORA_USER_ERROR_MSG "ORA-14020: this physical attribute may not be specified for a table partition"
#define OB_ERR_UNEXPECTED_UNIT_STATUS__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4399, Unit status is not expected"
#define OB_OB_AUTOINC_CACHE_NOT_EQUAL__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4400, Autoinc cache's autoinc version is not equal to request's autoinc version"
#define OB_IMPORT_NOT_IN_SERVER__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4505, Import not in service"
#define OB_CONVERT_ERROR__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4507, Convert error"
#define OB_BYPASS_TIMEOUT__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4510, Bypass timeout"
@ -5952,7 +5954,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ERR_DATA_TOO_LONG_MSG_FMT_V2__ORA_USER_ERROR_MSG "ORA-12899: value too large for column %.*s (actual: %ld, maximum: %ld)"
#define OB_ERR_INVALID_DATE_MSG_FMT_V2__ORA_USER_ERROR_MSG "ORA-01861: Incorrect datetime value for column '%.*s' at row %ld"
extern int g_all_ob_errnos[2092];
extern int g_all_ob_errnos[2093];
const char *ob_error_name(const int oberr);
const char* ob_error_cause(const int oberr);

View File

@ -211,7 +211,7 @@ int ObGlobalAutoIncService::handle_next_autoinc_request(
cache_node.reset();
OZ(fetch_next_node_(request, cache_node));
} else if (OB_UNLIKELY(request_version < cache_node.autoinc_version_)) {
ret = OB_SCHEMA_ERROR;
ret = OB_AUTOINC_CACHE_NOT_EQUAL;
LOG_WARN("request autoinc_version is less than autoinc_version_ in table_node, it should retry", KR(ret), K(tenant_id), K(table_id),
K(request_version), K(cache_node.autoinc_version_));
}
@ -352,13 +352,13 @@ int ObGlobalAutoIncService::handle_push_autoinc_request(
if (OB_FAIL(autoinc_map_.erase_refactored(key))) {
LOG_WARN("fail to erase autoinc cache map key", K(ret));
} else {
ret = OB_SCHEMA_ERROR;
ret = OB_AUTOINC_CACHE_NOT_EQUAL;
LOG_WARN("request autoinc_version is bigger than cache_node autoinc_version, erase key", KR(ret), K(tenant_id), K_(key.table_id),
K(request_version), K(cache_node.autoinc_version_));
}
// old request just ignore
} else if (OB_UNLIKELY(request_version < cache_node.autoinc_version_)) {
ret = OB_SCHEMA_ERROR;
ret = OB_AUTOINC_CACHE_NOT_EQUAL;
LOG_WARN("request autoinc_version is less than cache_node autoinc_version", KR(ret), K(tenant_id), K_(key.table_id),
K(request_version), K(cache_node.autoinc_version_));
} else if (OB_LIKELY(request_version == cache_node.autoinc_version_)) {