[to #50044838]remove piece need session lock

This commit is contained in:
LiuYoung00
2023-05-31 07:17:25 +00:00
committed by ob-robot
parent 3b5335b164
commit a09b9617bc
2 changed files with 23 additions and 21 deletions

View File

@ -1847,12 +1847,10 @@ int ObMPStmtExecute::process()
} }
session.check_and_reset_retry_info(*cur_trace_id, THIS_WORKER.need_retry()); session.check_and_reset_retry_info(*cur_trace_id, THIS_WORKER.need_retry());
session.set_last_trace_id(ObCurTraceId::get_trace_id()); session.set_last_trace_id(ObCurTraceId::get_trace_id());
}
// whether the previous error was reported, a cleanup is to be done here // whether the previous error was reported, a cleanup is to be done here
if (NULL != sess && !async_resp_used) { if (!async_resp_used) {
// async remove in ObSqlEndTransCb // async remove in ObSqlEndTransCb
ObPieceCache *piece_cache = static_cast<ObPieceCache*>(sess->get_piece_cache()); ObPieceCache *piece_cache = static_cast<ObPieceCache*>(session.get_piece_cache());
if (OB_ISNULL(piece_cache)) { if (OB_ISNULL(piece_cache)) {
// do nothing // do nothing
// piece_cache not be null in piece data protocol // piece_cache not be null in piece data protocol
@ -1860,7 +1858,7 @@ int ObMPStmtExecute::process()
for (uint64_t i = 0; OB_SUCC(ret) && i < params_num_; i++) { for (uint64_t i = 0; OB_SUCC(ret) && i < params_num_; i++) {
if (OB_FAIL(piece_cache->remove_piece( if (OB_FAIL(piece_cache->remove_piece(
piece_cache->get_piece_key(stmt_id_, i), piece_cache->get_piece_key(stmt_id_, i),
*sess))) { session))) {
if (OB_HASH_NOT_EXIST == ret) { if (OB_HASH_NOT_EXIST == ret) {
ret = OB_SUCCESS; ret = OB_SUCCESS;
} else { } else {
@ -1870,6 +1868,7 @@ int ObMPStmtExecute::process()
} }
} }
} }
}
if (OB_NOT_NULL(sess) && !sess->get_in_transaction()) { if (OB_NOT_NULL(sess) && !sess->get_in_transaction()) {
// transcation ends, end trace // transcation ends, end trace

View File

@ -488,17 +488,20 @@ int ObPieceCache::close_all(ObSQLSessionInfo &session)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (is_inited()) { if (is_inited()) {
common::ObSEArray<int64_t, 32> piece_keys;
for (PieceMap::iterator iter = piece_map_.begin(); //ignore ret for (PieceMap::iterator iter = piece_map_.begin(); //ignore ret
iter != piece_map_.end(); iter != piece_map_.end();
++iter) { ++iter) {
ObPiece *piece = iter->second; ObPiece *piece = iter->second;
int64_t key = get_piece_key(piece->get_stmt_id(), piece->get_param_id()); piece_keys.push_back(get_piece_key(piece->get_stmt_id(), piece->get_param_id()));
}
for (int64_t i = 0; i < piece_keys.count(); i++) {
int64_t key = piece_keys.at(i);
int64_t tmp_ret = remove_piece(key, session); int64_t tmp_ret = remove_piece(key, session);
// only save first error ret // only save first error ret
ret = ret == OB_SUCCESS ? tmp_ret : ret; ret = ret == OB_SUCCESS ? tmp_ret : ret;
if (OB_SUCCESS != tmp_ret) { if (OB_SUCCESS != tmp_ret) {
LOG_WARN("remove piece fail.", K(piece->get_stmt_id()), LOG_WARN("remove piece fail.", K(key), K(tmp_ret));
K(piece->get_param_id()), K(tmp_ret));
} }
} }
} }