Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't follow why this change is necessary. client.getDatabases(".*") should return list containing both TEST_DB1_NAME & TEST_DB2_NAME

Copy link
Contributor

@InvisibleProgrammer InvisibleProgrammer Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about the same. 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:

  @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);
  }
  @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;
  }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, seems cache is not the cause. Nondex appears to be changing the pattern matching behavior. We are still investigating why Nondex breaks this test.

assertNotNull("first database is not " + TEST_DB1_NAME, verifyDb1);

Database verifyDb2 = client.getDatabase(TEST_DB2_NAME);
assertNotNull("second database is not " + TEST_DB2_NAME, verifyDb2);

client.dropDatabase(TEST_DB1_NAME);
client.dropDatabase(TEST_DB2_NAME);
Expand Down