Fix direct load thread local variables destruct

This commit is contained in:
obdev
2023-01-29 16:17:28 +08:00
committed by ob-robot
parent b87473dac2
commit d7d52691d0
3 changed files with 61 additions and 62 deletions

View File

@ -7,11 +7,12 @@
#include "observer/table_load/ob_table_load_task_scheduler.h"
#include "common/ob_timeout_ctx.h"
#include "lib/stat/ob_session_stat.h"
#include "observer/omt/ob_tenant.h"
#include "observer/table_load/ob_table_load_stat.h"
#include "observer/table_load/ob_table_load_task.h"
#include "share/ob_share_util.h"
#include "share/rc/ob_tenant_base.h"
#include "observer/omt/ob_tenant.h"
#include "storage/direct_load/ob_direct_load_table_builder_allocator.h"
namespace oceanbase
{
@ -19,6 +20,7 @@ namespace observer
{
using namespace common;
using namespace share;
using namespace storage;
void ObTableLoadTaskThreadPoolScheduler::MyThreadPool::run1()
{
@ -237,6 +239,9 @@ void ObTableLoadTaskThreadPoolScheduler::run(uint64_t thread_idx)
state_ = STATE_STOPPING;
}
// clear thread local variables
get_table_builder_allocator()->reset();
LOG_INFO("table load task thread stopped", KP(this), "pid", get_tid_cache(), K(thread_idx));
}

View File

@ -445,6 +445,7 @@ void ObDDLKV::reset()
{
FLOG_INFO("ddl kv reset", KP(this), K(*this));
is_inited_ = false;
ObSSTable::reset();
ls_id_.reset();
tablet_id_.reset();
ddl_start_scn_ = SCN::min_scn();
@ -469,7 +470,6 @@ void ObDDLKV::reset()
sstable_index_builder_ = nullptr;
}
block_meta_tree_.destroy();
ObSSTable::reset();
arena_allocator_.reset();
}

View File

@ -13,33 +13,19 @@ namespace oceanbase
namespace storage
{
class ObDirectLoadTableBuilderAllocator
class ObDirectLoadTableBuilderAllocator final
{
public:
ObDirectLoadTableBuilderAllocator();
~ObDirectLoadTableBuilderAllocator();
template <typename T, typename... Args>
T *alloc(Args &&... args);
void free(ObIDirectLoadPartitionTableBuilder *table_builder);
void assert_in_own_thread();
private:
struct Item : public common::ObDLinkBase<Item>
{
char buf_[];
};
private:
int64_t tid_;
ObDList<Item> using_list_;
};
ObDirectLoadTableBuilderAllocator::ObDirectLoadTableBuilderAllocator()
ObDirectLoadTableBuilderAllocator()
{
tid_ = get_tid_cache();
}
ObDirectLoadTableBuilderAllocator::~ObDirectLoadTableBuilderAllocator()
~ObDirectLoadTableBuilderAllocator()
{
assert_in_own_thread();
OB_ASSERT(using_list_.is_empty());
}
void reset()
{
assert_in_own_thread();
Item *item = nullptr;
@ -52,9 +38,8 @@ ObDirectLoadTableBuilderAllocator::~ObDirectLoadTableBuilderAllocator()
}
OB_ASSERT(using_list_.is_empty());
}
template <typename T, typename... Args>
T *ObDirectLoadTableBuilderAllocator::alloc(Args &&... args)
T *alloc(Args &&... args)
{
assert_in_own_thread();
T *t = nullptr;
@ -69,8 +54,7 @@ T *ObDirectLoadTableBuilderAllocator::alloc(Args &&... args)
}
return t;
}
void ObDirectLoadTableBuilderAllocator::free(ObIDirectLoadPartitionTableBuilder *table_builder)
void free(ObIDirectLoadPartitionTableBuilder *table_builder)
{
assert_in_own_thread();
if (OB_NOT_NULL(table_builder)) {
@ -81,13 +65,23 @@ void ObDirectLoadTableBuilderAllocator::free(ObIDirectLoadPartitionTableBuilder
ob_free(item);
}
}
void ObDirectLoadTableBuilderAllocator::assert_in_own_thread()
OB_INLINE void assert_in_own_thread()
{
const int64_t tid = get_tid_cache();
OB_ASSERT(tid == tid_);
}
private:
struct Item : public common::ObDLinkBase<Item>
{
char buf_[];
};
private:
int64_t tid_;
ObDList<Item> using_list_;
};
OB_INLINE ObDirectLoadTableBuilderAllocator *get_table_builder_allocator()
{
RLOCAL_INLINE(ObDirectLoadTableBuilderAllocator, allcator);