This is an automated email from the ASF dual-hosted git repository.

stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git


The following commit(s) were added to refs/heads/master by this push:
     new f092646f8 IMPALA-13993: waitForHmsEvent should check table events 
under missing dbs
f092646f8 is described below

commit f092646f840a0ffe087051479a2948ef425e376d
Author: stiga-huang <[email protected]>
AuthorDate: Fri Apr 25 21:04:29 2025 +0800

    IMPALA-13993: waitForHmsEvent should check table events under missing dbs
    
    When a db is missing in the catalog cache, waitForHmsEvent request
    currently just check if there are pending database events on it,
    assuming processing the CREATE_DATABASE event will add the db with
    the table list. However, that's wrong since processing CREATE_DATABASE
    event just adds the db with an empty table list. We should still wait
    for pending events on underlying tables.
    
    Tests:
     - Added e2e test which consistenly fails when running concurrently with
       other tests in TestEventSyncWaiting without the fix.
    
    Change-Id: I3fe74fcf0bf4dbac4a3584f6603279c0a2730b0c
    Reviewed-on: http://gerrit.cloudera.org:8080/22817
    Reviewed-by: Impala Public Jenkins <[email protected]>
    Tested-by: Quanlong Huang <[email protected]>
---
 .../impala/catalog/events/MetastoreEventsProcessor.java     | 10 +++-------
 tests/metadata/test_event_processing.py                     | 13 +++++++++++++
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git 
a/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEventsProcessor.java
 
b/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEventsProcessor.java
index b24b741e7..ba4223f54 100644
--- 
a/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEventsProcessor.java
+++ 
b/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEventsProcessor.java
@@ -1679,15 +1679,11 @@ public class MetastoreEventsProcessor implements 
ExternalEventsProcessor {
         } else if (catalogObject.isSetTable()) {
           TTable table = catalogObject.getTable();
           if (catalog_.getDb(table.db_name) == null) {
-            // We will check existence of missing dbs. Once the missing db is 
added,
-            // the underlying tables are also added (as IncompleteTables). So 
don't
-            // need to check table events. I.e. there are no stale metadata on 
those
-            // tables.
+            // We will check existence of missing dbs.
             dbNames.add(table.db_name);
-          } else {
-            db2Tables.computeIfAbsent(table.db_name, k -> new ArrayList<>())
-                .add(table.tbl_name);
           }
+          db2Tables.computeIfAbsent(table.db_name, k -> new ArrayList<>())
+              .add(table.tbl_name);
         }
       }
       // Step 2: Check DB events
diff --git a/tests/metadata/test_event_processing.py 
b/tests/metadata/test_event_processing.py
index f04a4ccfb..51bf2cf49 100644
--- a/tests/metadata/test_event_processing.py
+++ b/tests/metadata/test_event_processing.py
@@ -599,3 +599,16 @@ class TestEventSyncWaiting(ImpalaTestSuite):
         "alter table {} partition(p=0)compact 'minor' and wait".format(tbl))
     res = self.execute_query_expect_success(client, "show files in " + tbl)
     assert len(res.data) == 1
+
+  def test_hms_event_sync_on_missing_db(self, vector, unique_name):
+    client = self.create_impala_client_from_vector(vector)
+    db = unique_name + "_db"
+    try:
+      self.run_stmt_in_hive("""create database {0};
+          create table {0}.tbl(i int);
+          create table {0}.tbl_2(i int);""".format(db))
+      self.execute_query_expect_success(
+          client, "insert into {0}.tbl values (0)".format(db))
+    finally:
+      self.run_stmt_in_hive(
+          "drop database if exists {0} cascade".format(db))

Reply via email to