fix external table bug

This commit is contained in:
obdev 2024-02-08 05:53:37 +00:00 committed by ob-robot
parent 3b7101919f
commit 372e310f39
3 changed files with 22 additions and 12 deletions

View File

@ -282,12 +282,23 @@ int ObExternalTableUtils::prepare_single_scan_range(const uint64_t tenant_id,
int ret = OB_SUCCESS;
ObSEArray<ObExternalFileInfo, 16> file_urls;
ObSEArray<ObNewRange *, 4> tmp_ranges;
if (OB_FAIL(tmp_ranges.assign(ranges))) {
ObSEArray<ObAddr, 16> all_locations;
if (OB_ISNULL(GCTX.location_service_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected error", K(ret));
} else if (OB_FAIL(tmp_ranges.assign(ranges))) {
LOG_WARN("failed to assign array", K(ret));
} else if (OB_FAIL(ObExternalTableFileManager::get_instance().get_external_files(tenant_id,
table_id, is_file_on_disk, range_allocator, file_urls,
tmp_ranges.empty() ? NULL : &tmp_ranges))) {
LOG_WARN("get external table file error", K(ret));
} else if (OB_FAIL(GCTX.location_service_->external_table_get(tenant_id, table_id, all_locations))) {
LOG_WARN("fail to get external table location", K(ret));
} else if (is_file_on_disk
&& OB_FAIL(ObExternalTableUtils::filter_files_in_locations(file_urls,
all_locations))) {
//For recovered cluster, the file addr may not in the cluster. Then igore it.
LOG_WARN("filter files in location failed", K(ret));
} else {
new_range.reset();
}
@ -422,8 +433,7 @@ int ObExternalTableUtils::calc_assigned_files_to_sqcs(
}
int ObExternalTableUtils::filter_files_in_locations(common::ObIArray<share::ObExternalFileInfo> &files,
common::ObIArray<common::ObAddr> &locations,
common::ObIArray<share::ObExternalFileInfo> &res)
common::ObIArray<common::ObAddr> &locations)
{
int ret = OB_SUCCESS;
for (int64_t i = 0; OB_SUCC(ret) && i < files.count(); i++) {
@ -434,8 +444,10 @@ int ObExternalTableUtils::filter_files_in_locations(common::ObIArray<share::ObEx
found = true;
}
}
if (OB_SUCC(ret) && found) {
ret = res.push_back(table_info);
if (OB_SUCC(ret) && !found) {
std::swap(files.at(i), files.at(files.count() - 1));
files.pop_back();
i--;
}
}
return ret;

View File

@ -101,8 +101,7 @@ class ObExternalTableUtils {
int64_t sqc_count);
static int filter_files_in_locations(common::ObIArray<share::ObExternalFileInfo> &files,
common::ObIArray<common::ObAddr> &locations,
common::ObIArray<share::ObExternalFileInfo> &res);
common::ObIArray<common::ObAddr> &locations);
private:
static bool is_left_edge(const common::ObObj &value);
static bool is_right_edge(const common::ObObj &value);

View File

@ -160,18 +160,17 @@ int ObPXServerAddrUtil::get_external_table_loc(
// ret = OB_NOT_SUPPORTED;
// LOG_WARN("Has dynamic params in external table or empty range is not supported", K(ret),
// K(pre_query_range.has_exec_param()), K(pre_query_range.get_column_count()));
ObArray<ObExternalFileInfo> tmp_ext_file_urls;
if (OB_FAIL(ObSQLUtils::extract_pre_query_range(
pre_query_range, ctx.get_allocator(), ctx, ranges,
ObBasicSessionInfo::create_dtc_params(ctx.get_my_session())))) {
LOG_WARN("failed to extract external file fiter", K(ret));
} else if (OB_FAIL(ObExternalTableFileManager::get_instance().get_external_files(
tenant_id, ref_table_id, is_external_files_on_disk,
ctx.get_allocator(), tmp_ext_file_urls, ranges.empty() ? NULL : &ranges))) {
ctx.get_allocator(), ext_file_urls, ranges.empty() ? NULL : &ranges))) {
LOG_WARN("fail to get external files", K(ret));
} else if (OB_FAIL(ObExternalTableUtils::filter_files_in_locations(tmp_ext_file_urls,
all_locations,
ext_file_urls))) {
} else if (is_external_files_on_disk
&& OB_FAIL(ObExternalTableUtils::filter_files_in_locations(ext_file_urls,
all_locations))) {
//For recovered cluster, the file addr may not in the cluster. Then igore it.
LOG_WARN("filter files in location failed", K(ret));
}