修复复制表在列存副本场景下副本选择错误问题

This commit is contained in:
zzg19950727
2025-02-16 17:16:40 +00:00
committed by ob-robot
parent 7ebad4f9f3
commit 8fd515bb25
4 changed files with 22 additions and 7 deletions

View File

@ -489,9 +489,12 @@ int ObBasicStatsEstimator::get_tablet_locations(ObExecContext &ctx,
int ret = OB_SUCCESS;
ObDASLocationRouter &loc_router = ctx.get_das_ctx().get_location_router();
ObSQLSessionInfo *session = ctx.get_my_session();
int64_t route_policy = 0;
if (OB_ISNULL(session) || OB_UNLIKELY(tablet_ids.count() != partition_ids.count())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get unexpected null", K(ret), K(session), K(tablet_ids.count()), K(partition_ids.count()));
} else if (OB_FAIL(session->get_sys_variable(SYS_VAR_OB_ROUTE_POLICY, route_policy))) {
LOG_WARN("get route policy failed", K(ret));
} else {
candi_tablet_locs.reset();
if (OB_FAIL(candi_tablet_locs.prepare_allocate(tablet_ids.count()))) {
@ -504,6 +507,7 @@ int ObBasicStatsEstimator::get_tablet_locations(ObExecContext &ctx,
loc_meta.ref_table_id_ = ref_table_id;
loc_meta.table_loc_id_ = ref_table_id;
loc_meta.select_leader_ = 0;
loc_meta.route_policy_ = route_policy;
if (OB_FAIL(loc_router.nonblock_get_candi_tablet_locations(loc_meta,
tablet_ids,
partition_ids,

View File

@ -1017,7 +1017,8 @@ int ObDASLocationRouter::nonblock_get_candi_tablet_locations(const ObDASTableLoc
if (OB_FAIL(candi_tablet_loc.set_part_loc_with_only_readable_replica(partition_ids.at(i),
first_level_part_id,
tablet_ids.at(i),
location))) {
location,
static_cast<ObRoutePolicyType>(loc_meta.route_policy_)))) {
LOG_WARN("fail to set partition location with only readable replica",
K(ret),K(i), K(location), K(candi_tablet_locs), K(tablet_ids), K(partition_ids));
}

View File

@ -59,7 +59,8 @@ int ObOptTabletLoc::assign(const ObOptTabletLoc &other)
int ObOptTabletLoc::assign_with_only_readable_replica(const ObObjectID &partition_id,
const ObObjectID &first_level_part_id,
const common::ObTabletID &tablet_id,
const ObLSLocation &ls_location)
const ObLSLocation &ls_location,
const ObRoutePolicyType route_policy)
{
int ret = OB_SUCCESS;
reset();
@ -81,7 +82,12 @@ int ObOptTabletLoc::assign_with_only_readable_replica(const ObObjectID &partitio
} else if (OB_FAIL(ObBLService::get_instance().check_in_black_list(bl_key, in_black_list))) {
LOG_WARN("check in black list failed", K(ret));
} else if (!in_black_list) {
if (OB_FAIL(replica_locations_.push_back(replica_loc))) {
if ((route_policy == COLUMN_STORE_ONLY && replica_loc.get_replica_type() != REPLICA_TYPE_COLUMNSTORE) ||
(route_policy != COLUMN_STORE_ONLY && replica_loc.get_replica_type() == REPLICA_TYPE_COLUMNSTORE) ||
(route_policy == FORCE_READONLY_ZONE && replica_loc.get_replica_type() != REPLICA_TYPE_READONLY)) {
// skip the tmp_replica_loc
LOG_TRACE("skip the replica due to the replica policy.", K(ret), K(replica_loc));
} else if (OB_FAIL(replica_locations_.push_back(replica_loc))) {
LOG_WARN("Failed to push back replica locations",
K(ret), K(i), K(replica_loc), K(replica_locations_));
}
@ -343,7 +349,8 @@ int ObCandiTabletLoc::get_selected_replica(ObRoutePolicy::CandidateReplica &repl
int ObCandiTabletLoc::set_part_loc_with_only_readable_replica(const ObObjectID &partition_id,
const ObObjectID &first_level_part_id,
const common::ObTabletID &tablet_id,
const ObLSLocation &partition_location)
const ObLSLocation &partition_location,
const ObRoutePolicyType route_policy)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(has_selected_replica())) {
@ -353,7 +360,8 @@ int ObCandiTabletLoc::set_part_loc_with_only_readable_replica(const ObObjectID &
} else if (OB_FAIL(opt_tablet_loc_.assign_with_only_readable_replica(partition_id,
first_level_part_id,
tablet_id,
partition_location))) {
partition_location,
route_policy))) {
LOG_WARN("fail to assign partition location with only readable replica",
K(ret), K(partition_location));
}

View File

@ -38,7 +38,8 @@ public:
int assign_with_only_readable_replica(const ObObjectID &partition_id,
const ObObjectID &first_level_part_id,
const common::ObTabletID &tablet_id,
const share::ObLSLocation &partition_location);
const share::ObLSLocation &partition_location,
const ObRoutePolicyType route_policy);
bool is_valid() const;
bool operator==(const ObOptTabletLoc &other) const;
@ -105,7 +106,8 @@ public:
int set_part_loc_with_only_readable_replica(const ObObjectID &partition_id,
const ObObjectID &first_level_part_id,
const common::ObTabletID &tablet_id,
const share::ObLSLocation &partition_location);
const share::ObLSLocation &partition_location,
const ObRoutePolicyType route_policy);
const ObOptTabletLoc &get_partition_location() const { return opt_tablet_loc_; }
ObOptTabletLoc &get_partition_location() { return opt_tablet_loc_; }
const common::ObIArray<int64_t> &get_priority_replica_idxs() const { return priority_replica_idxs_; }