fix gi split task randomly bug

This commit is contained in:
sdc
2023-10-18 07:09:55 +00:00
committed by ob-robot
parent 9df202077d
commit 7de3b4472a
11 changed files with 90 additions and 48 deletions

View File

@ -21,6 +21,7 @@
#include "share/schema/ob_part_mgr_util.h"
#include "sql/engine/dml/ob_table_modify_op.h"
#include "sql/engine/ob_engine_op_traits.h"
#include "sql/engine/px/ob_px_sqc_handler.h"
namespace oceanbase
{
@ -1045,15 +1046,18 @@ int ObAffinitizeGranuleSplitter::split_tasks_affinity(ObExecContext &ctx,
int ret = OB_SUCCESS;
ObSchemaGetterGuard schema_guard;
const ObTableSchema *table_schema = NULL;
ObPxAffinityByRandom affinitize_rule;
ObSQLSessionInfo *my_session = NULL;
ObPxTabletInfo partition_row_info;
ObTabletIdxMap idx_map;
if (OB_ISNULL(my_session = GET_MY_SESSION(ctx))) {
bool qc_order_gi_tasks = false;
if (OB_ISNULL(my_session = GET_MY_SESSION(ctx)) || OB_ISNULL(ctx.get_sqc_handler())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("fail to get my session", K(ret));
LOG_WARN("fail to get my session", K(ret), K(my_session), K(ctx.get_sqc_handler()));
} else {
qc_order_gi_tasks = ctx.get_sqc_handler()->get_sqc_init_arg().qc_order_gi_tasks_;
}
int64_t cur_idx = -1;
ObPxAffinityByRandom affinitize_rule(qc_order_gi_tasks);
ARRAY_FOREACH_X(taskset.gi_task_set_, idx, cnt, OB_SUCC(ret)) {
if (cur_idx != taskset.gi_task_set_.at(idx).idx_) {
cur_idx = taskset.gi_task_set_.at(idx).idx_; // get all different parition key in Affinitize
@ -1096,6 +1100,7 @@ int ObAffinitizeGranuleSplitter::split_tasks_affinity(ObExecContext &ctx,
} else if (OB_FAIL(affinitize_rule.add_partition(tablet_loc.tablet_id_.id(),
tablet_idx,
parallelism,
my_session->get_effective_tenant_id(),
partition_row_info))) {
LOG_WARN("Failed to get affinitize taskid" , K(ret));
}