InvisibleProgrammer commented on code in PR #6107:
URL: https://github.com/apache/hive/pull/6107#discussion_r2390031864


##########
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java:
##########
@@ -1225,10 +1225,11 @@ public void testDatabase() throws Throwable {
       assertEquals("location of the returned db is different from that of 
inserted db",
           warehouse.getDatabasePath(db2).toString(), db2.getLocationUri());
 
-      List<String> dbs = client.getDatabases(".*");
-
-      assertTrue("first database is not " + TEST_DB1_NAME, 
dbs.contains(TEST_DB1_NAME));
-      assertTrue("second database is not " + TEST_DB2_NAME, 
dbs.contains(TEST_DB2_NAME));
+      Database verifyDb1 = client.getDatabase(TEST_DB1_NAME);

Review Comment:
   The ticket description says: 
   
   > The test asserted database existence using getDatabases(".*") which relies 
on cached database lists that may return stale results when nondex randomizes 
test execution. This led to nondeterministic test outcomes where databases 
existed but were not found in the cached list.
   
   It is interesting. As I see, getDatabase uses cache as well: 
   
   ```java
     @Override public List<String> getDatabases(String catName, String pattern) 
throws MetaException {
       if (!sharedCache.isDatabaseCachePrewarmed() || (canUseEvents && 
rawStore.isActiveTransaction())) {
         return rawStore.getDatabases(catName, pattern);
       }
       return sharedCache.listCachedDatabases(catName, pattern);
     }
   ```
   
   ```java
     @Override public Database getDatabase(String catName, String dbName) 
throws NoSuchObjectException {
       // in case of  event based cache update, cache will be updated during 
commit. So within active transaction, read
       // directly from rawStore to avoid reading stale data as the data 
updated during same transaction will not be
       // updated in the cache.
       if (!sharedCache.isDatabaseCachePrewarmed() || (canUseEvents && 
rawStore.isActiveTransaction())) {
         return rawStore.getDatabase(catName, dbName);
       }
       dbName = dbName.toLowerCase();
       Database db = sharedCache
           .getDatabaseFromCache(StringUtils.normalizeIdentifier(catName), 
StringUtils.normalizeIdentifier(dbName));
       if (db == null) {
         throw new NoSuchObjectException();
       }
       return db;
     }
     ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to