fix external table bug

This commit is contained in:
SevenJ-swj
2023-12-22 08:13:31 +00:00
committed by ob-robot
parent 8ed5d9afef
commit 2bbae19623
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;