[BUGFIX] fix allocator not reuse when refresh full table schema
This commit is contained in:
parent
01b518b9c7
commit
a4945c7460
@ -112,18 +112,36 @@ public:
|
||||
index_(0),
|
||||
table_(&table),
|
||||
tmp_table_(NULL),
|
||||
table_array_(NULL)
|
||||
table_array_(NULL),
|
||||
current_allocator_("ScheRetri"),
|
||||
another_allocator_("ScheRetri"),
|
||||
current_schema_(¤t_allocator_),
|
||||
another_schema_(&another_allocator_)
|
||||
{}
|
||||
ObSchemaRetrieveHelper(common::ObArray<TABLE_SCHEMA *> &tables)
|
||||
: mode_(Mode::MULTIPLE_TABLE),
|
||||
index_(0),
|
||||
table_(NULL),
|
||||
tmp_table_(NULL),
|
||||
table_array_(&tables)
|
||||
table_array_(&tables),
|
||||
current_allocator_("ScheRetri"),
|
||||
another_allocator_("ScheRetri"),
|
||||
current_schema_(¤t_allocator_),
|
||||
another_schema_(&another_allocator_)
|
||||
{}
|
||||
|
||||
~ObSchemaRetrieveHelper() {}
|
||||
SCHEMA &get_current() { return schemas_[index_]; }
|
||||
SCHEMA &get_and_reset_current()
|
||||
{
|
||||
if (0 == index_) {
|
||||
current_schema_.reset();
|
||||
current_allocator_.reuse();
|
||||
} else {
|
||||
another_schema_.reset();
|
||||
another_allocator_.reuse();
|
||||
}
|
||||
return 0 == index_ ? current_schema_ : another_schema_;
|
||||
}
|
||||
int64_t get_curr_schema_id();
|
||||
void rotate() { index_ = 1 - index_; }
|
||||
int get_table(const uint64_t table_id, TABLE_SCHEMA *&table);
|
||||
@ -142,7 +160,10 @@ private:
|
||||
//for multi table
|
||||
TABLE_SCHEMA *tmp_table_;
|
||||
ObArray<TABLE_SCHEMA *> *table_array_;
|
||||
SCHEMA schemas_[2];
|
||||
ObArenaAllocator current_allocator_;
|
||||
ObArenaAllocator another_allocator_;
|
||||
SCHEMA current_schema_;
|
||||
SCHEMA another_schema_;
|
||||
};
|
||||
|
||||
|
||||
@ -163,7 +184,11 @@ public:
|
||||
tmp_table_(NULL),
|
||||
table_array_(NULL),
|
||||
partition_(NULL),
|
||||
is_subpart_template_(is_subpart_template)
|
||||
is_subpart_template_(is_subpart_template),
|
||||
current_allocator_("SubScheRetri"),
|
||||
another_allocator_("SubScheRetri"),
|
||||
current_schema_(¤t_allocator_),
|
||||
another_schema_(&another_allocator_)
|
||||
{}
|
||||
ObSubPartSchemaRetrieveHelper(common::ObArray<TABLE_SCHEMA *> &tables,
|
||||
const bool is_subpart_template = true)
|
||||
@ -173,11 +198,25 @@ public:
|
||||
tmp_table_(NULL),
|
||||
table_array_(&tables),
|
||||
partition_(NULL),
|
||||
is_subpart_template_(is_subpart_template)
|
||||
is_subpart_template_(is_subpart_template),
|
||||
current_allocator_("SubScheRetri"),
|
||||
another_allocator_("SubScheRetri"),
|
||||
current_schema_(¤t_allocator_),
|
||||
another_schema_(&another_allocator_)
|
||||
{}
|
||||
|
||||
~ObSubPartSchemaRetrieveHelper() {}
|
||||
ObSubPartition &get_current() { return schemas_[index_]; }
|
||||
ObSubPartition &get_and_reset_current()
|
||||
{
|
||||
if (0 == index_) {
|
||||
current_schema_.reset();
|
||||
current_allocator_.reuse();
|
||||
} else {
|
||||
another_schema_.reset();
|
||||
another_allocator_.reuse();
|
||||
}
|
||||
return 0 == index_ ? current_schema_ : another_schema_;
|
||||
}
|
||||
int64_t get_curr_schema_id();
|
||||
void rotate() { index_ = 1 - index_; }
|
||||
int get_table(const uint64_t table_id, TABLE_SCHEMA *&table);
|
||||
@ -197,10 +236,13 @@ private:
|
||||
//for multi table
|
||||
TABLE_SCHEMA *tmp_table_;
|
||||
ObArray<TABLE_SCHEMA *> *table_array_;
|
||||
ObSubPartition schemas_[2];
|
||||
// for is_subpart_template = false
|
||||
ObPartition *partition_;
|
||||
bool is_subpart_template_;
|
||||
ObArenaAllocator current_allocator_;
|
||||
ObArenaAllocator another_allocator_;
|
||||
ObSubPartition current_schema_;
|
||||
ObSubPartition another_schema_;
|
||||
};
|
||||
|
||||
struct VersionHisVal;
|
||||
|
@ -139,8 +139,7 @@ int ObSchemaRetrieveUtils::retrieve_schema(
|
||||
ObSchemaRetrieveHelper<TABLE_SCHEMA, SCHEMA> helper(table_schema_array);
|
||||
while (OB_SUCC(ret) && common::OB_SUCCESS == (ret = result.next())) {
|
||||
bool is_deleted = false;
|
||||
SCHEMA ¤t = helper.get_current();
|
||||
current.reset();
|
||||
SCHEMA ¤t = helper.get_and_reset_current();
|
||||
if (OB_FAIL(helper.fill_current(tenant_id, check_deleted, result, current, is_deleted))) {
|
||||
SHARE_SCHEMA_LOG(WARN, "fill schema failed", K(ret));
|
||||
} else if (current.get_table_id() == last_table_id
|
||||
@ -213,13 +212,17 @@ int ObSchemaRetrieveUtils::retrieve_column_group_schema(const uint64_t tenant_id
|
||||
// store current_schema and last_schema
|
||||
bool is_last_deleted = false;
|
||||
ObColumnGroupSchema *last_schema = NULL;
|
||||
ObColumnGroupSchema tmp_schemas[2]; // to avoid full copy
|
||||
ObArenaAllocator current_allocator("ColGroScheRetri");
|
||||
ObArenaAllocator another_allocator("ColGroScheRetri");
|
||||
ObColumnGroupSchema tmp_schemas[2] = {ObColumnGroupSchema(¤t_allocator),
|
||||
ObColumnGroupSchema(&another_allocator)};
|
||||
int64_t tmp_idx = 0;
|
||||
while (OB_SUCC(ret) && OB_SUCC(result.next())) {
|
||||
bool is_deleted = false;
|
||||
uint64_t cur_table_id = common::OB_INVALID_ID;
|
||||
ObColumnGroupSchema ¤t = tmp_schemas[tmp_idx];
|
||||
current.reset();
|
||||
0 == tmp_idx ? current_allocator.reuse() : another_allocator.reuse();
|
||||
|
||||
if (OB_FAIL(ObSchemaRetrieveUtils::fill_column_group_info(check_deleted, result, current, cur_table_id, is_deleted))) {
|
||||
SHARE_SCHEMA_LOG(WARN, "fail to fill column_group schema", KR(ret));
|
||||
@ -586,7 +589,7 @@ int ObSubPartSchemaRetrieveHelper<TABLE_SCHEMA>::add(ObSubPartition &p)
|
||||
template<typename TABLE_SCHEMA>
|
||||
int64_t ObSubPartSchemaRetrieveHelper<TABLE_SCHEMA>::get_curr_schema_id()
|
||||
{
|
||||
return schemas_[index_].get_sub_part_id();
|
||||
return index_ == 0 ? current_schema_.get_sub_part_id() : another_schema_.get_sub_part_id();
|
||||
}
|
||||
|
||||
template<typename TABLE_SCHEMA>
|
||||
@ -665,7 +668,7 @@ int ObSchemaRetrieveHelper<TABLE_SCHEMA, SCHEMA>::add(SCHEMA &p)
|
||||
template<typename TABLE_SCHEMA, typename SCHEMA>
|
||||
int64_t ObSchemaRetrieveHelper<TABLE_SCHEMA, SCHEMA>::get_curr_schema_id()
|
||||
{
|
||||
return ObSchemaRetrieveHelperBase<TABLE_SCHEMA, SCHEMA>::get_schema_id(schemas_[index_]);
|
||||
return ObSchemaRetrieveHelperBase<TABLE_SCHEMA, SCHEMA>::get_schema_id(index_ == 0 ? current_schema_ : another_schema_);
|
||||
}
|
||||
|
||||
template<typename TABLE_SCHEMA, typename SCHEMA>
|
||||
@ -698,8 +701,7 @@ int ObSchemaRetrieveUtils::retrieve_schema(const uint64_t tenant_id,
|
||||
ObSchemaRetrieveHelper<TABLE_SCHEMA, SCHEMA> helper(*table_schema);
|
||||
while (OB_SUCC(ret) && common::OB_SUCCESS == (ret = result.next())) {
|
||||
bool is_deleted = false;
|
||||
SCHEMA ¤t = helper.get_current();
|
||||
current.reset();
|
||||
SCHEMA ¤t = helper.get_and_reset_current();
|
||||
if (OB_FAIL(helper.fill_current(tenant_id, check_deleted, result, current, is_deleted))) {
|
||||
SHARE_SCHEMA_LOG(WARN, "fill schema fail", K(ret));
|
||||
} else if (table_id != current.get_table_id()) {
|
||||
@ -839,8 +841,7 @@ int ObSchemaRetrieveUtils::retrieve_subpart_schema(
|
||||
is_subpart_template);
|
||||
while (OB_SUCC(ret) && OB_SUCC(result.next())) {
|
||||
bool is_deleted = false;
|
||||
ObSubPartition ¤t = helper.get_current();
|
||||
current.reset();
|
||||
ObSubPartition ¤t = helper.get_and_reset_current();
|
||||
if (OB_FAIL(helper.fill_current(tenant_id, check_deleted,
|
||||
result, current, is_deleted))) {
|
||||
SHARE_SCHEMA_LOG(WARN, "fill schema fail", K(ret));
|
||||
@ -889,8 +890,7 @@ int ObSchemaRetrieveUtils::retrieve_subpart_schema(
|
||||
is_subpart_template);
|
||||
while (OB_SUCC(ret) && OB_SUCC(result.next())) {
|
||||
bool is_deleted = false;
|
||||
ObSubPartition ¤t = helper.get_current();
|
||||
current.reset();
|
||||
ObSubPartition ¤t = helper.get_and_reset_current();
|
||||
if (OB_FAIL(helper.fill_current(tenant_id, check_deleted,
|
||||
result, current, is_deleted))) {
|
||||
SHARE_SCHEMA_LOG(WARN, "fill schema fail", K(ret));
|
||||
|
Loading…
x
Reference in New Issue
Block a user