fix savepoint is not synchronized between servers

This commit is contained in:
obdev
2023-03-20 17:23:49 +08:00
committed by ob-robot
parent ec988d25b2
commit c6bbafe473
13 changed files with 155 additions and 43 deletions

View File

@ -73,7 +73,7 @@ int ObCreateSavePointExecutor::execute(ObExecContext &ctx,
if (OB_ISNULL(session)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("invalid param", K(ret), K(session));
} else if (OB_FAIL(ObSqlTransControl::create_savepoint(ctx, stmt.get_sp_name()))) {
} else if (OB_FAIL(ObSqlTransControl::create_savepoint(ctx, stmt.get_sp_name(), true))) {
LOG_WARN("fail create savepoint", K(ret), K(stmt.get_sp_name()));
} else if (!session->has_explicit_start_trans()) {
if (OB_FAIL(session->get_autocommit(ac))) {

View File

@ -722,7 +722,8 @@ int ObSqlTransControl::stmt_setup_savepoint_(ObSQLSessionInfo *session,
K(session->get_txn_free_route_ctx()), KPC(session)); \
}
int ObSqlTransControl::create_savepoint(ObExecContext &exec_ctx,
const ObString &sp_name)
const ObString &sp_name,
const bool user_create)
{
int ret = OB_SUCCESS;
ObSQLSessionInfo *session = GET_MY_SESSION(exec_ctx);
@ -734,7 +735,7 @@ int ObSqlTransControl::create_savepoint(ObExecContext &exec_ctx,
OZ (acquire_tx_if_need_(txs, *session));
bool start_hook = false;
OZ(start_hook_if_need_(*session, txs, start_hook));
OZ (txs->create_explicit_savepoint(*session->get_tx_desc(), sp_name, get_real_session_id(*session)), sp_name);
OZ (txs->create_explicit_savepoint(*session->get_tx_desc(), sp_name, get_real_session_id(*session), user_create), sp_name);
if (start_hook) {
int tmp_ret = txs->sql_stmt_end_hook(session->get_xid(), *session->get_tx_desc());
if (OB_SUCCESS != tmp_ret) {

View File

@ -220,7 +220,7 @@ public:
using namespace oceanbase::transaction;
return kill_tx(session, static_cast<int>(ObTxAbortCause::SESSION_DISCONNECT));
}
static int create_savepoint(ObExecContext &exec_ctx, const common::ObString &sp_name);
static int create_savepoint(ObExecContext &exec_ctx, const common::ObString &sp_name, const bool user_create = false);
static int rollback_savepoint(ObExecContext &exec_ctx, const common::ObString &sp_name);
static int release_savepoint(ObExecContext &exec_ctx, const common::ObString &sp_name);
static int xa_rollback_all_changes(ObExecContext &exec_ctx);