IMPALA-12082: Fix db not found error of INVALIDATE METADATA under unloaded db

INVALIDATE METADATA can be executed on tables under unloaded db. It will
bring up the metadata of the db by the way. However, this feature is
broken after IMPALA-11808 in which we try to get the table from catalog
cache assuming it's loaded. This causes the above use case failed by
DatabaseNotFoundException.

This patch fixes the regression by not getting the table from catalog
cache for INVALIDATE METADATA commands. We only do so for REFRESH
commands. After the INVALIDATE METADATA command succeeds, if we need to
fire reload events, we get the table from catalog cache.

Tests:
 - Add e2e tests for event-processor is disabled and enabled.

Change-Id: Ifd0a9e87f06c38f569c32bd10cc2668403681fd4
Reviewed-on: http://gerrit.cloudera.org:8080/19786
Reviewed-by: Michael Smith <michael.smith@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
stiga-huang
2023-04-23 12:17:45 +08:00
committed by Impala Public Jenkins
parent 0a42185d17
commit f68986d452
3 changed files with 37 additions and 5 deletions

View File

@@ -296,3 +296,17 @@ class TestMetadataNoEventsProcessing(CustomClusterTestSuite):
result = self.client.execute("show partitions %s" % tbl)
assert result.get_data().startswith("1\t1\t2"),\
"Incorrect partition stats %s" % result.get_data()
@CustomClusterTestSuite.with_args(catalogd_args="--hms_event_polling_interval_s=0")
def test_invalidate_metadata(self, unique_name):
"""Verify invalidate metadata on tables under unloaded db won't fail"""
db = unique_name + "_db"
tbl = db + "." + unique_name + "_tbl"
try:
self.run_stmt_in_hive("create database " + db)
self.run_stmt_in_hive("create table %s (i int)" % tbl)
self.client.execute("invalidate metadata %s" % tbl)
res = self.client.execute("describe %s" % tbl)
assert res.data == ["i\tint\t"]
finally:
self.run_stmt_in_hive("drop database %s cascade" % db)