From 0e3a5dede94d599343196cdf7b971533d656748a Mon Sep 17 00:00:00 2001 From: chinaxing Date: Fri, 12 Apr 2024 07:51:27 +0000 Subject: [PATCH] [tx-route] fix extra state isolation field verify failed --- src/sql/ob_sql_trans_control.cpp | 10 ++++++++-- src/storage/tx/ob_tx_free_route_state.cpp | 11 ++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/sql/ob_sql_trans_control.cpp b/src/sql/ob_sql_trans_control.cpp index 8914ff4fe6..a0aa06dcdf 100644 --- a/src/sql/ob_sql_trans_control.cpp +++ b/src/sql/ob_sql_trans_control.cpp @@ -1590,8 +1590,14 @@ int ObSqlTransControl::check_ls_readable(const uint64_t tenant_id, int ObSqlTransControl::cmp_txn_##name##_state(const char* cur_buf, int64_t cur_len, const char* last_buf, int64_t last_len) \ { return transaction::ObTransService::txn_free_route__cmp_##name##_state(cur_buf, cur_len, last_buf, last_len); } \ void ObSqlTransControl::display_txn_##name##_state(ObSQLSessionInfo &sess, const char* local_buf, const int64_t local_len, const char* remote_buf, const int64_t remote_len) \ - { transaction::ObTransService::txn_free_route__display_##name##_state("LOAL", local_buf, local_len); \ - transaction::ObTransService::txn_free_route__display_##name##_state("REMOTE", remote_buf, remote_len); } + { \ + transaction::ObTransService::txn_free_route__display_##name##_state("LOAL", local_buf, local_len); \ + transaction::ObTransService::txn_free_route__display_##name##_state("REMOTE", remote_buf, remote_len); \ + ObTxDesc *tx = sess.get_tx_desc(); \ + if (OB_NOT_NULL(tx)) { \ + tx->print_trace(); \ + } \ + } DELEGATE_TO_TXN(static); DELEGATE_TO_TXN(dynamic); diff --git a/src/storage/tx/ob_tx_free_route_state.cpp b/src/storage/tx/ob_tx_free_route_state.cpp index 42416f8f30..2a2890fc7b 100644 --- a/src/storage/tx/ob_tx_free_route_state.cpp +++ b/src/storage/tx/ob_tx_free_route_state.cpp @@ -21,6 +21,15 @@ namespace transaction { FLAG flags_ = { .v_ = 0 }; \ bool can_elr_ = false; \ int abort_cause_ = 0; + +// only serialize isolation_ when Repeatable Read or SERIALIZABLE +#define PRE_ENCODE_EXTRA_FOR_VERIFY \ + ObTxIsolationLevel isolation_ = ObTxIsolationLevel::INVALID; \ + if (this->isolation_ == ObTxIsolationLevel::RR \ + || this->isolation_ == ObTxIsolationLevel::SERIAL) { \ + isolation_ = this->isolation_; \ + } + #define PRE_STATIC_DECODE #define POST_STATIC_DECODE // bookkeep the original before update, then after receive the update, @@ -136,7 +145,7 @@ TXN_FREE_ROUTE_MEMBERS(parts,,,, // the fields 'dup with static' are required when preceding of txn is of query like // savepoint or read only stmt with isolation of SERIALIZABLE / REPEATABLE READ // because such type of query caused the txn into 'start' in perspective of proxy -TXN_FREE_ROUTE_MEMBERS(extra, , PRE_EXTRA_DECODE, POST_EXTRA_DECODE, +TXN_FREE_ROUTE_MEMBERS(extra, PRE_ENCODE_EXTRA_FOR_VERIFY, PRE_EXTRA_DECODE, POST_EXTRA_DECODE, tx_id_, // dup with static sess_id_, // dup with static addr_, // dup with static