add for the standby database to intercept write stmt
This commit is contained in:
@ -5661,17 +5661,17 @@ static const _error _error_OB_NO_DISK_NEED_REBUILD = {
|
|||||||
.oracle_str_error = "ORA-00600: internal error code, arguments: -4687, no disk need rebuild",
|
.oracle_str_error = "ORA-00600: internal error code, arguments: -4687, no disk need rebuild",
|
||||||
.oracle_str_user_error = "ORA-00600: internal error code, arguments: -4687, no disk need rebuild"
|
.oracle_str_user_error = "ORA-00600: internal error code, arguments: -4687, no disk need rebuild"
|
||||||
};
|
};
|
||||||
static const _error _error_OB_STANDBY_WEAK_READ_ONLY = {
|
static const _error _error_OB_STANDBY_READ_ONLY = {
|
||||||
.error_name = "OB_STANDBY_WEAK_READ_ONLY",
|
.error_name = "OB_STANDBY_READ_ONLY",
|
||||||
.error_cause = "Internal Error",
|
.error_cause = "Internal Error",
|
||||||
.error_solution = "Contact OceanBase Support",
|
.error_solution = "Contact OceanBase Support",
|
||||||
.mysql_errno = -1,
|
.mysql_errno = -1,
|
||||||
.sqlstate = "HY000",
|
.sqlstate = "HY000",
|
||||||
.str_error = "standby cluster support weak read only",
|
.str_error = "standby tenant is read only",
|
||||||
.str_user_error = "standby cluster support weak read only",
|
.str_user_error = "standby tenant is read only",
|
||||||
.oracle_errno = 16000,
|
.oracle_errno = 16000,
|
||||||
.oracle_str_error = "ORA-16000: standby cluster support weak read only",
|
.oracle_str_error = "ORA-16000: standby tenant is read only",
|
||||||
.oracle_str_user_error = "ORA-16000: standby cluster support weak read only"
|
.oracle_str_user_error = "ORA-16000: standby tenant is read only"
|
||||||
};
|
};
|
||||||
static const _error _error_OB_INVALD_WEB_SERVICE_CONTENT = {
|
static const _error _error_OB_INVALD_WEB_SERVICE_CONTENT = {
|
||||||
.error_name = "OB_INVALD_WEB_SERVICE_CONTENT",
|
.error_name = "OB_INVALD_WEB_SERVICE_CONTENT",
|
||||||
@ -22446,7 +22446,7 @@ struct ObStrErrorInit
|
|||||||
_errors[-OB_ACTIVE_MEMTBALE_NOT_EXSIT] = &_error_OB_ACTIVE_MEMTBALE_NOT_EXSIT;
|
_errors[-OB_ACTIVE_MEMTBALE_NOT_EXSIT] = &_error_OB_ACTIVE_MEMTBALE_NOT_EXSIT;
|
||||||
_errors[-OB_USE_DUP_FOLLOW_AFTER_DML] = &_error_OB_USE_DUP_FOLLOW_AFTER_DML;
|
_errors[-OB_USE_DUP_FOLLOW_AFTER_DML] = &_error_OB_USE_DUP_FOLLOW_AFTER_DML;
|
||||||
_errors[-OB_NO_DISK_NEED_REBUILD] = &_error_OB_NO_DISK_NEED_REBUILD;
|
_errors[-OB_NO_DISK_NEED_REBUILD] = &_error_OB_NO_DISK_NEED_REBUILD;
|
||||||
_errors[-OB_STANDBY_WEAK_READ_ONLY] = &_error_OB_STANDBY_WEAK_READ_ONLY;
|
_errors[-OB_STANDBY_READ_ONLY] = &_error_OB_STANDBY_READ_ONLY;
|
||||||
_errors[-OB_INVALD_WEB_SERVICE_CONTENT] = &_error_OB_INVALD_WEB_SERVICE_CONTENT;
|
_errors[-OB_INVALD_WEB_SERVICE_CONTENT] = &_error_OB_INVALD_WEB_SERVICE_CONTENT;
|
||||||
_errors[-OB_PRIMARY_CLUSTER_EXIST] = &_error_OB_PRIMARY_CLUSTER_EXIST;
|
_errors[-OB_PRIMARY_CLUSTER_EXIST] = &_error_OB_PRIMARY_CLUSTER_EXIST;
|
||||||
_errors[-OB_ARRAY_BINDING_SWITCH_ITERATOR] = &_error_OB_ARRAY_BINDING_SWITCH_ITERATOR;
|
_errors[-OB_ARRAY_BINDING_SWITCH_ITERATOR] = &_error_OB_ARRAY_BINDING_SWITCH_ITERATOR;
|
||||||
|
|||||||
@ -562,7 +562,7 @@ DEFINE_ERROR(OB_TOO_MANY_TENANT_PARTITIONS_ERROR, -4684, -1, "HY000", "Too many
|
|||||||
DEFINE_ERROR(OB_ACTIVE_MEMTBALE_NOT_EXSIT, -4685, -1, "HY000", "active memtable not exist");
|
DEFINE_ERROR(OB_ACTIVE_MEMTBALE_NOT_EXSIT, -4685, -1, "HY000", "active memtable not exist");
|
||||||
DEFINE_ERROR(OB_USE_DUP_FOLLOW_AFTER_DML, -4686, -1, "HY000", "Should use leader replica for duplicate table after DML operator");
|
DEFINE_ERROR(OB_USE_DUP_FOLLOW_AFTER_DML, -4686, -1, "HY000", "Should use leader replica for duplicate table after DML operator");
|
||||||
DEFINE_ERROR(OB_NO_DISK_NEED_REBUILD, -4687, -1, "HY000", "no disk need rebuild");
|
DEFINE_ERROR(OB_NO_DISK_NEED_REBUILD, -4687, -1, "HY000", "no disk need rebuild");
|
||||||
DEFINE_ORACLE_ERROR(OB_STANDBY_WEAK_READ_ONLY, -4688, -1, "HY000", "standby cluster support weak read only", 16000, "standby cluster support weak read only");
|
DEFINE_ORACLE_ERROR(OB_STANDBY_READ_ONLY, -4688, -1, "HY000", "standby tenant is read only", 16000, "standby tenant is read only");
|
||||||
DEFINE_ERROR(OB_INVALD_WEB_SERVICE_CONTENT, -4689, -1, "HY000", "web service content not valid");
|
DEFINE_ERROR(OB_INVALD_WEB_SERVICE_CONTENT, -4689, -1, "HY000", "web service content not valid");
|
||||||
DEFINE_ERROR(OB_PRIMARY_CLUSTER_EXIST, -4690, -1, "HY000", "other primary cluster already exist, can not start as primary");
|
DEFINE_ERROR(OB_PRIMARY_CLUSTER_EXIST, -4690, -1, "HY000", "other primary cluster already exist, can not start as primary");
|
||||||
DEFINE_ERROR(OB_ARRAY_BINDING_SWITCH_ITERATOR, -4691, -1, "HY000", "array binding needs to switch iterator");
|
DEFINE_ERROR(OB_ARRAY_BINDING_SWITCH_ITERATOR, -4691, -1, "HY000", "array binding needs to switch iterator");
|
||||||
|
|||||||
@ -378,7 +378,7 @@ constexpr int OB_TOO_MANY_TENANT_PARTITIONS_ERROR = -4684;
|
|||||||
constexpr int OB_ACTIVE_MEMTBALE_NOT_EXSIT = -4685;
|
constexpr int OB_ACTIVE_MEMTBALE_NOT_EXSIT = -4685;
|
||||||
constexpr int OB_USE_DUP_FOLLOW_AFTER_DML = -4686;
|
constexpr int OB_USE_DUP_FOLLOW_AFTER_DML = -4686;
|
||||||
constexpr int OB_NO_DISK_NEED_REBUILD = -4687;
|
constexpr int OB_NO_DISK_NEED_REBUILD = -4687;
|
||||||
constexpr int OB_STANDBY_WEAK_READ_ONLY = -4688;
|
constexpr int OB_STANDBY_READ_ONLY = -4688;
|
||||||
constexpr int OB_INVALD_WEB_SERVICE_CONTENT = -4689;
|
constexpr int OB_INVALD_WEB_SERVICE_CONTENT = -4689;
|
||||||
constexpr int OB_PRIMARY_CLUSTER_EXIST = -4690;
|
constexpr int OB_PRIMARY_CLUSTER_EXIST = -4690;
|
||||||
constexpr int OB_ARRAY_BINDING_SWITCH_ITERATOR = -4691;
|
constexpr int OB_ARRAY_BINDING_SWITCH_ITERATOR = -4691;
|
||||||
@ -2070,7 +2070,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
|
|||||||
#define OB_ACTIVE_MEMTBALE_NOT_EXSIT__USER_ERROR_MSG "active memtable not exist"
|
#define OB_ACTIVE_MEMTBALE_NOT_EXSIT__USER_ERROR_MSG "active memtable not exist"
|
||||||
#define OB_USE_DUP_FOLLOW_AFTER_DML__USER_ERROR_MSG "Should use leader replica for duplicate table after DML operator"
|
#define OB_USE_DUP_FOLLOW_AFTER_DML__USER_ERROR_MSG "Should use leader replica for duplicate table after DML operator"
|
||||||
#define OB_NO_DISK_NEED_REBUILD__USER_ERROR_MSG "no disk need rebuild"
|
#define OB_NO_DISK_NEED_REBUILD__USER_ERROR_MSG "no disk need rebuild"
|
||||||
#define OB_STANDBY_WEAK_READ_ONLY__USER_ERROR_MSG "standby cluster support weak read only"
|
#define OB_STANDBY_READ_ONLY__USER_ERROR_MSG "standby tenant is read only"
|
||||||
#define OB_INVALD_WEB_SERVICE_CONTENT__USER_ERROR_MSG "web service content not valid"
|
#define OB_INVALD_WEB_SERVICE_CONTENT__USER_ERROR_MSG "web service content not valid"
|
||||||
#define OB_PRIMARY_CLUSTER_EXIST__USER_ERROR_MSG "other primary cluster already exist, can not start as primary"
|
#define OB_PRIMARY_CLUSTER_EXIST__USER_ERROR_MSG "other primary cluster already exist, can not start as primary"
|
||||||
#define OB_ARRAY_BINDING_SWITCH_ITERATOR__USER_ERROR_MSG "array binding needs to switch iterator"
|
#define OB_ARRAY_BINDING_SWITCH_ITERATOR__USER_ERROR_MSG "array binding needs to switch iterator"
|
||||||
@ -3902,7 +3902,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
|
|||||||
#define OB_ACTIVE_MEMTBALE_NOT_EXSIT__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4685, active memtable not exist"
|
#define OB_ACTIVE_MEMTBALE_NOT_EXSIT__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4685, active memtable not exist"
|
||||||
#define OB_USE_DUP_FOLLOW_AFTER_DML__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4686, Should use leader replica for duplicate table after DML operator"
|
#define OB_USE_DUP_FOLLOW_AFTER_DML__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4686, Should use leader replica for duplicate table after DML operator"
|
||||||
#define OB_NO_DISK_NEED_REBUILD__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4687, no disk need rebuild"
|
#define OB_NO_DISK_NEED_REBUILD__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4687, no disk need rebuild"
|
||||||
#define OB_STANDBY_WEAK_READ_ONLY__ORA_USER_ERROR_MSG "ORA-16000: standby cluster support weak read only"
|
#define OB_STANDBY_READ_ONLY__ORA_USER_ERROR_MSG "ORA-16000: standby tenant is read only"
|
||||||
#define OB_INVALD_WEB_SERVICE_CONTENT__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4689, web service content not valid"
|
#define OB_INVALD_WEB_SERVICE_CONTENT__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4689, web service content not valid"
|
||||||
#define OB_PRIMARY_CLUSTER_EXIST__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4690, other primary cluster already exist, can not start as primary"
|
#define OB_PRIMARY_CLUSTER_EXIST__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4690, other primary cluster already exist, can not start as primary"
|
||||||
#define OB_ARRAY_BINDING_SWITCH_ITERATOR__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4691, array binding needs to switch iterator"
|
#define OB_ARRAY_BINDING_SWITCH_ITERATOR__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -4691, array binding needs to switch iterator"
|
||||||
|
|||||||
@ -1053,6 +1053,14 @@ int ObResolver::resolve(IsPrepared if_prepared, const ParseNode &parse_tree, ObS
|
|||||||
}
|
}
|
||||||
} // end switch
|
} // end switch
|
||||||
|
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
if (ObStmt::is_write_stmt(stmt->get_stmt_type(), stmt->has_global_variable())
|
||||||
|
&& !MTL_IS_PRIMARY_TENANT()) {
|
||||||
|
ret = OB_STANDBY_READ_ONLY;
|
||||||
|
TRANS_LOG(WARN, "standby tenant support read only", K(ret), K(stmt));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (OB_SUCC(ret) && stmt->is_dml_write_stmt()) {
|
if (OB_SUCC(ret) && stmt->is_dml_write_stmt()) {
|
||||||
// todo yanli:检查主备库
|
// todo yanli:检查主备库
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,6 +38,7 @@
|
|||||||
#include "storage/tx_storage/ob_ls_handle.h"
|
#include "storage/tx_storage/ob_ls_handle.h"
|
||||||
#include "storage/ls/ob_ls.h"
|
#include "storage/ls/ob_ls.h"
|
||||||
#include "ob_xa_service.h"
|
#include "ob_xa_service.h"
|
||||||
|
#include "rootserver/ob_tenant_recovery_reportor.h"
|
||||||
|
|
||||||
/* interface(s) */
|
/* interface(s) */
|
||||||
namespace oceanbase {
|
namespace oceanbase {
|
||||||
@ -2003,8 +2004,13 @@ int ObTransService::refresh_location_cache(const share::ObLSID ls)
|
|||||||
int ObTransService::gen_trans_id_(ObTransID &trans_id)
|
int ObTransService::gen_trans_id_(ObTransID &trans_id)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
const int MAX_RETRY_TIMES = 50;
|
|
||||||
int retry_times = 0;
|
int retry_times = 0;
|
||||||
|
if (!MTL_IS_PRIMARY_TENANT()) {
|
||||||
|
ret = OB_STANDBY_READ_ONLY;
|
||||||
|
TRANS_LOG(WARN, "standby tenant support read only", K(ret));
|
||||||
|
} else {
|
||||||
|
const int MAX_RETRY_TIMES = 50;
|
||||||
int64_t tx_id = 0;
|
int64_t tx_id = 0;
|
||||||
do {
|
do {
|
||||||
if (OB_SUCC(gti_source_->get_trans_id(tx_id))) {
|
if (OB_SUCC(gti_source_->get_trans_id(tx_id))) {
|
||||||
@ -2022,6 +2028,7 @@ int ObTransService::gen_trans_id_(ObTransID &trans_id)
|
|||||||
if (OB_SUCC(ret)) {
|
if (OB_SUCC(ret)) {
|
||||||
trans_id = ObTransID(tx_id);
|
trans_id = ObTransID(tx_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
TRANS_LOG(TRACE, "gen trans id", K(ret), K(trans_id), K(retry_times));
|
TRANS_LOG(TRACE, "gen trans id", K(ret), K(trans_id), K(retry_times));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user