Claudenw opened a new issue, #13343: URL: https://github.com/apache/iceberg/issues/13343
### Apache Iceberg version 1.9.0 ### Query engine Kafka Connect ### Please describe the bug 🐞 If Kafka Connect is started with 2 or more Iceberg sink connectors that are using JDBC catalog and the JDBC is slow the some of the connectors will throw: ``` org.apache.iceberg.jdbc.UncheckedSQLException: Cannot initialize JDBC catalog at org.apache.iceberg.jdbc.JdbcCatalog.initializeCatalogTables(JdbcCatalog.java:206) at org.apache.iceberg.jdbc.JdbcCatalog.initialize(JdbcCatalog.java:147) at org.apache.iceberg.CatalogUtil.loadCatalog(CatalogUtil.java:277) at org.apache.iceberg.CatalogUtil.buildIcebergCatalog(CatalogUtil.java:331) at org.apache.iceberg.connect.CatalogUtils.loadCatalog(CatalogUtils.java:44) at org.apache.iceberg.connect.IcebergSinkTask.start(IcebergSinkTask.java:48) at org.apache.kafka.connect.runtime.WorkerSinkTask.initializeAndStart(WorkerSinkTask.java:323) at org.apache.kafka.connect.runtime.WorkerTask.doStart(WorkerTask.java:175) at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:224) at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:280) at org.apache.kafka.connect.runtime.isolation.Plugins.lambda$withClassLoader$1(Plugins.java:237) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:840) Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "pg_type_typname_nsp_index" Detail: Key (typname, typnamespace)=(iceberg_tables, 2200) already exists. at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2733) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2420) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:372) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:517) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:434) at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:194) at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:180) at org.apache.iceberg.jdbc.JdbcCatalog.lambda$initializeCatalogTables$0(JdbcCatalog.java:178) at org.apache.iceberg.ClientPoolImpl.run(ClientPoolImpl.java:72) at org.apache.iceberg.ClientPoolImpl.run(ClientPoolImpl.java:65) at org.apache.iceberg.jdbc.JdbcCatalog.initializeCatalogTables(JdbcCatalog.java:162) ... 15 more ``` This is caused because the `JdbcCatalog` checks to see if the table exists and if not creates it. However this leaves a window where another thread can create the table before the create is called. I have a test and fix for this bug and will submit same. ### Willingness to contribute - [x] I can contribute a fix for this bug independently - [ ] I would be willing to contribute a fix for this bug with guidance from the Iceberg community - [ ] I cannot contribute a fix for this bug at this time -- 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...@iceberg.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org