shouweikun commented on a change in pull request #18114: URL: https://github.com/apache/flink/pull/18114#discussion_r774988544
########## File path: flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/connectors/hive/HiveDynamicTableFactory.java ########## @@ -70,13 +72,18 @@ public DynamicTableSink createDynamicTableSink(Context context) { // we don't support temporary hive tables yet if (!isHiveTable || context.isTemporary()) { - return FactoryUtil.createDynamicTableSink( - null, - context.getObjectIdentifier(), - context.getCatalogTable(), - context.getConfiguration(), - context.getClassLoader(), - context.isTemporary()); + DynamicTableSink sink = + FactoryUtil.createDynamicTableSink( + null, + context.getObjectIdentifier(), + context.getCatalogTable(), + context.getConfiguration(), + context.getClassLoader(), + context.isTemporary()); + if (sink instanceof RequireCatalogLock) { + ((RequireCatalogLock) sink).setLockFactory(HiveCatalogLock.createFactory(hiveConf)); Review comment: For now we have to check and call `RequireCatalogLock#setLockFactory` manually in every `DynamicTableFactory` if necessary. Shall we lift this to `Planner`? ########## File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogLock.java ########## @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.catalog; + +import org.apache.flink.annotation.Internal; + +import java.io.Closeable; +import java.io.Serializable; +import java.util.concurrent.Callable; + +/** + * An interface that allows source and sink to use global lock to some transaction-related things. + */ +@Internal +public interface CatalogLock extends Closeable { + + /** Run with catalog lock. The caller should tell catalog the database and table name. */ + <T> T runWithLock(String database, String table, Callable<T> callable) throws Exception; Review comment: I have a question about this. Shall we also add `String catalogName` as a parameter too? Maybe only databaseName and TableName can not avoid clash? eg: catalog_b.db.tb and catalog_b.db.tb -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org