diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/SemiTransactionalHiveMetastore.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/SemiTransactionalHiveMetastore.java index 274641269dcc6..5f4015494c93c 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/SemiTransactionalHiveMetastore.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/SemiTransactionalHiveMetastore.java @@ -238,9 +238,11 @@ public SemiTransactionalHiveMetastore( this.tableInvalidationCallback = requireNonNull(tableInvalidationCallback, "tableInvalidationCallback is null"); } - public synchronized List getAllDatabases() + public List getAllDatabases() { - checkReadable(); + synchronized (this) { + checkReadable(); + } return delegate.getAllDatabases(); } @@ -259,11 +261,13 @@ public synchronized Optional getDatabase(String databaseName) return delegate.getDatabase(databaseName); } - public synchronized List getTables(String databaseName) + public List 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); }