[Bug](catalog) Fix fetching information_schema table timed out(#17692) (#17694)

Co-authored-by: hugoluo <hugoluo@tencent.com>
This commit is contained in:
yuxuan-luo
2023-03-15 09:56:24 +08:00
committed by GitHub
parent 16a4dc0a85
commit 45fcdaabc7
2 changed files with 16 additions and 0 deletions

View File

@ -49,6 +49,8 @@ public interface CatalogIf<T extends DatabaseIf> {
List<String> getDbNames();
// Will be used when querying the information_schema table
// Unable to get db for uninitialized catalog to avoid query timeout
default List<String> getDbNamesOrEmpty() {
try {
return getDbNames();

View File

@ -240,6 +240,20 @@ public abstract class ExternalCatalog implements CatalogIf<ExternalDatabase>, Wr
return listDatabaseNames(null);
}
@Override
public List<String> getDbNamesOrEmpty() {
if (initialized) {
try {
return getDbNames();
} catch (Exception e) {
LOG.warn("failed to get db names in catalog {}", getName(), e);
return Lists.newArrayList();
}
} else {
return Lists.newArrayList();
}
}
@Override
public String getResource() {
return catalogProperty.getResource();