Skip to content

Commit

Permalink
Reduce synchronization for metadata calls in SemiTransactionalHiveMet…
Browse files Browse the repository at this point in the history
…astore

We don't need to hold lock on SemiTransactionalHiveMetastore object for remote calls
which just read metadata. Listing views/tables/databases on metastore can be potentially
slow. Holding lock blocks cleanupQuery, which prevents QueryTracker#enforceTimeLimits
from failing queries which exceed time limit.
  • Loading branch information
raunaqmorarka committed Oct 24, 2024
1 parent 08bc940 commit ab76e55
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,11 @@ public SemiTransactionalHiveMetastore(
this.tableInvalidationCallback = requireNonNull(tableInvalidationCallback, "tableInvalidationCallback is null");
}

public synchronized List<String> getAllDatabases()
public List<String> getAllDatabases()
{
checkReadable();
synchronized (this) {
checkReadable();
}
return delegate.getAllDatabases();
}

Expand All @@ -259,11 +261,13 @@ public synchronized Optional<Database> getDatabase(String databaseName)
return delegate.getDatabase(databaseName);
}

public synchronized List<TableInfo> getTables(String databaseName)
public List<TableInfo> getTables(String databaseName)
{
checkReadable();
if (!tableActions.isEmpty()) {
throw new UnsupportedOperationException("Listing all tables after adding/dropping/altering tables/views in a transaction is not supported");
synchronized (this) {
checkReadable();
if (!tableActions.isEmpty()) {
throw new UnsupportedOperationException("Listing all tables after adding/dropping/altering tables/views in a transaction is not supported");
}
}
return delegate.getTables(databaseName);
}
Expand Down

0 comments on commit ab76e55

Please sign in to comment.