[CP] [to #53858480, #54677465] free pieces in piece_cache_ synchrounously

This commit is contained in:
obdev
2024-02-20 09:15:50 +00:00
committed by ob-robot
parent d1d2c34d47
commit 661031247f
9 changed files with 46 additions and 42 deletions

View File

@ -639,11 +639,10 @@ void ObSQLSessionInfo::destroy(bool skip_sys_var)
}
if (OB_SUCC(ret) && NULL != piece_cache_) {
if (OB_FAIL((static_cast<observer::ObPieceCache*>(piece_cache_))
->close_all(*this))) {
if (OB_FAIL(piece_cache_->close_all(*this))) {
LOG_WARN("failed to close all piece", K(ret));
}
static_cast<observer::ObPieceCache*>(piece_cache_)->~ObPieceCache();
piece_cache_->~ObPieceCache();
get_session_allocator().free(piece_cache_);
piece_cache_ = NULL;
}
@ -2860,15 +2859,14 @@ int ObSQLSessionInfo::ps_use_stream_result_set(bool &use_stream) {
return ret;
}
void* ObSQLSessionInfo::get_piece_cache(bool need_init) {
observer::ObPieceCache* ObSQLSessionInfo::get_piece_cache(bool need_init) {
if (NULL == piece_cache_ && need_init) {
void *buf = get_session_allocator().alloc(sizeof(observer::ObPieceCache));
if (NULL != buf) {
MEMSET(buf, 0, sizeof(observer::ObPieceCache));
piece_cache_ = new (buf) observer::ObPieceCache();
if (OB_SUCCESS != (static_cast<observer::ObPieceCache*>(piece_cache_))->init(
get_effective_tenant_id())) {
static_cast<observer::ObPieceCache*>(piece_cache_)->~ObPieceCache();
if (OB_SUCCESS != piece_cache_->init(get_effective_tenant_id())) {
piece_cache_->~ObPieceCache();
get_session_allocator().free(piece_cache_);
piece_cache_ = NULL;
LOG_WARN_RET(OB_ERR_UNEXPECTED, "init piece cache fail");

View File

@ -53,6 +53,7 @@ namespace observer
{
class ObQueryDriver;
class ObSqlEndTransCb;
class ObPieceCache;
}
namespace pl
{
@ -1318,7 +1319,7 @@ public:
bool is_ignore_stmt() const { return is_ignore_stmt_; }
// piece
void *get_piece_cache(bool need_init = false);
observer::ObPieceCache *get_piece_cache(bool need_init = false);
void set_load_data_exec_session(bool v) { is_load_data_exec_session_ = v; }
bool is_load_data_exec_session() const { return is_load_data_exec_session_; }
@ -1472,7 +1473,7 @@ private:
bool is_ignore_stmt_;
ObSessionDDLInfo ddl_info_;
bool is_table_name_hidden_;
void *piece_cache_;
observer::ObPieceCache* piece_cache_;
bool is_load_data_exec_session_;
ObSqlString pl_exact_err_msg_;
bool is_varparams_sql_prepare_;