forked from oceanbase/oceanbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathob_end_trans_callback.cpp
More file actions
99 lines (86 loc) · 2.95 KB
/
Copy pathob_end_trans_callback.cpp
File metadata and controls
99 lines (86 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#define USING_LOG_PREFIX SQL
#include "ob_end_trans_callback.h"
#include "lib/ob_name_id_def.h"
#include "lib/profile/ob_perf_event.h"
#include "sql/ob_sql_utils.h"
#include "sql/session/ob_sql_session_info.h"
using namespace oceanbase::transaction;
using namespace oceanbase::common;
namespace oceanbase
{
namespace sql
{
ObSharedEndTransCallback::ObSharedEndTransCallback()
{
}
ObSharedEndTransCallback::~ObSharedEndTransCallback()
{
}
ObExclusiveEndTransCallback::ObExclusiveEndTransCallback()
{
reset();
}
ObExclusiveEndTransCallback::~ObExclusiveEndTransCallback()
{
}
///////////////// Async Callback Impl /////////////
ObEndTransAsyncCallback::ObEndTransAsyncCallback() :
ObExclusiveEndTransCallback(),
mysql_end_trans_cb_()
{
}
ObEndTransAsyncCallback::~ObEndTransAsyncCallback()
{
}
void ObEndTransAsyncCallback::callback(int cb_param, const transaction::ObTransID &trans_id)
{
UNUSED(trans_id);
callback(cb_param);
}
void ObEndTransAsyncCallback::callback(int cb_param)
{
sql::ObSQLSessionInfo *session_info = mysql_end_trans_cb_.get_sess_info_ptr();
// Add ASH flags to async commit of transactions
// In the start of async commit in func named ` ObSqlTransControl::do_end_trans_() `,
// set the ash flag named `in_committing_` to true.
if (NULL != session_info) {
ObActiveSessionGuard::setup_ash(session_info->get_ash_stat());
ObActiveSessionGuard::get_stat().in_committing_ = false;
ObActiveSessionGuard::get_stat().in_sql_execution_ = true;
}
bool need_disconnect = false;
if (OB_UNLIKELY(!has_set_need_rollback_)) {
LOG_ERROR_RET(OB_ERR_UNEXPECTED, "is_need_rollback_ has not been set",
K(has_set_need_rollback_),
K(is_need_rollback_));
} else if (OB_UNLIKELY(ObExclusiveEndTransCallback::END_TRANS_TYPE_INVALID == end_trans_type_)) {
LOG_ERROR_RET(OB_INVALID_ARGUMENT, "end trans type is invalid", K(cb_param), K(end_trans_type_));
} else {
ObSQLUtils::check_if_need_disconnect_after_end_trans(
cb_param, is_need_rollback_,
ObExclusiveEndTransCallback::END_TRANS_TYPE_EXPLICIT == end_trans_type_,
need_disconnect);
}
mysql_end_trans_cb_.set_need_disconnect(need_disconnect);
this->handin();
CHECK_BALANCE("[async callback]");
if (OB_SUCCESS == this->last_err_) {
mysql_end_trans_cb_.callback(cb_param);
} else {
cb_param = this->last_err_;
mysql_end_trans_cb_.callback(cb_param);
}
}
}/* ns sql*/
}/* ns oceanbase */