This is an automated email from the ASF dual-hosted git repository. dbecker pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
commit 9672312015be959360795a8af0843fdf386b557c Author: Sai Hemanth Gantasala <[email protected]> AuthorDate: Fri Mar 22 10:03:48 2024 -0700 IMPALA-11735: Handle CREATE_TABLE event when the db is invisible to the impala server user It's possible that some dbs are invisible to Impala cluster due to authorization restrictions. However, the CREATE_TABLE events in such dbs will lead the event-processor into ERROR state. Event processor should ignore such CREAT_TABLE events when database is not found. note: This is an incorrect setup, where 'impala' super user is denied access on the metadata object database but given access to fetch events from notification log table of metastore. Testing: - Manually verified this on local cluster. - Added automated unit test to verify the same. Change-Id: I90275bb8c065fc5af61186901ac7e9839a68c43b Reviewed-on: http://gerrit.cloudera.org:8080/21188 Reviewed-by: Impala Public Jenkins <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- .../apache/impala/catalog/events/MetastoreEvents.java | 5 +++++ .../catalog/events/MetastoreEventsProcessorTest.java | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEvents.java b/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEvents.java index 0ef8d79ee..ee054e44f 100644 --- a/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEvents.java +++ b/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEvents.java @@ -1458,6 +1458,11 @@ public class MetastoreEvents { debugLog("Incremented skipped metric to " + metrics_ .getCounter(MetastoreEventsProcessor.EVENTS_SKIPPED_METRIC).getCount()); } + } catch (DatabaseNotFoundException ex) { + // This is an incorrect setup where DB is not found in cache for a table event. + // Don't put the event processor into error state, instead ignore this event. + errorLog("Create table {}.{} failed because the database does not exist cache." + + " Ignoring the CREATE_TABLE event", dbName_, tblName_, ex); } catch (CatalogException e) { // if a DatabaseNotFoundException is caught here it means either we incorrectly // determined that the event needs to be processed instead of skipped, or we diff --git a/fe/src/test/java/org/apache/impala/catalog/events/MetastoreEventsProcessorTest.java b/fe/src/test/java/org/apache/impala/catalog/events/MetastoreEventsProcessorTest.java index 157663c5f..c54c04f26 100644 --- a/fe/src/test/java/org/apache/impala/catalog/events/MetastoreEventsProcessorTest.java +++ b/fe/src/test/java/org/apache/impala/catalog/events/MetastoreEventsProcessorTest.java @@ -3909,6 +3909,24 @@ public class MetastoreEventsProcessorTest { } } + @Test + public void testCreateTblOnUnloadedDB() throws Exception { + eventsProcessor_.pause(); + createDatabase(TEST_DB_NAME, null); + eventsProcessor_.processEvents(); + assertEquals(EventProcessorStatus.PAUSED, eventsProcessor_.getStatus()); + assertNull( + "Test database should not be in catalog when event processing is stopped", + catalog_.getDb(TEST_DB_NAME)); + long currentEventId = eventsProcessor_.getCurrentEventId(); + eventsProcessor_.start(currentEventId); + assertEquals(EventProcessorStatus.ACTIVE, eventsProcessor_.getStatus()); + String tblName = "test_create_tbl"; + createTable(tblName, false); + eventsProcessor_.processEvents(); + assertEquals(EventProcessorStatus.ACTIVE, eventsProcessor_.getStatus()); + } + private void insertIntoTable(String dbName, String tableName) throws Exception { try (MetaStoreClient client = catalog_.getMetaStoreClient()) { org.apache.hadoop.hive.metastore.api.Table msTable =
