I'm trying (and failing) to get Flink, Iceberg, an...
# troubleshooting
r
I'm trying (and failing) to get Flink, Iceberg, and Hive Metastore to work together. Details here in case anyone has suggestions πŸ™‚ https://stackoverflow.com/questions/77916045/flink-with-iceberg-catalog-and-hive-metastore-org-apache-hadoop-fs-s3a-s3afiles
p
Sounds silly but have you tried adding inside
/lib
only without the aws sub dir? I had a similar issue one of those days
d
You may need to add
aws-java-sdk-bundle
to the classpath as well. Hadoop AWS has a dependency on it. The error may be misleading.
You may also need
hadoop-common
with the exact version of
hadoop-aws
https://hadoop.apache.org/docs/stable/hadoop-aws/tools/hadoop-aws/index.html#Other_S3_Connectors
r
@Pedro MΓ‘zala I have tried that, but thanks.
@D S ok let me try that tomorrow. thanks.
@D S no luck, same error 😞
unfortunately, still no dice. I've tried the suggestions, and included an update on my post https://stackoverflow.com/questions/77916045/flink-with-iceberg-catalog-and-hive-metastore-org-apache-hadoop-fs-s3a-s3afiles even though
hadoop-aws
is in the classpath, it's not getting picked up, would there be a reason for that?
a
was
hadoop-aws
added to
lib
or
plugins/s3-fs-hadoop
directory?
r
lib
a
In this case hadoop plugin might not be able to find it. Would you be able to check if putting it in plugins directory helps?
r
let me try it
unfortunately no luck 😞
Copy code
Flink SQL> [ERROR] Could not execute SQL statement. Reason:
MetaException(message:java.lang.RuntimeException: java.lang.ClassNotFoundException: Class org.apache.hadoop.fs.s3a.S3AFileSystem not found)

Shutting down the session...
done.
❯ ls -l plugins/s3-fs-hadoop
total 62952
-rw-r--r--@ 1 rmoff  staff  31263021  1 Feb 14:55 flink-s3-fs-hadoop-1.18.1.jar
-rw-r--r--  1 rmoff  staff    962685  1 Feb 14:56 hadoop-aws-3.3.4.jar
a
Interesting, actually there should be no need including additional jars since
flink-s3-fs-hadoop
already includes required class:
Copy code
~ jar tvf flink-s3-fs-hadoop-1.18.1.jar| grep "S3AFileSystem"
   478 Tue Dec 19 22:35:58 GMT 2023 org/apache/flink/fs/s3hadoop/S3AFileSystemFactory.class
  2311 Fri Jul 29 13:29:24 BST 2022 org/apache/hadoop/fs/s3a/S3AFileSystem$ContextAccessorsImpl.class
  1714 Fri Jul 29 13:29:24 BST 2022 org/apache/hadoop/fs/s3a/S3AFileSystem$DelegationOperationsImpl.class
  1289 Fri Jul 29 13:29:24 BST 2022 org/apache/hadoop/fs/s3a/S3AFileSystem$1.class
  6425 Fri Jul 29 13:29:24 BST 2022 org/apache/hadoop/fs/s3a/S3AFileSystem$CopyFromLocalCallbacksImpl.class
  1687 Fri Jul 29 13:29:24 BST 2022 org/apache/hadoop/fs/s3a/S3AFileSystem$MkdirOperationCallbacksImpl.class
  1921 Fri Jul 29 13:29:24 BST 2022 org/apache/hadoop/fs/s3a/S3AFileSystem$GetContentSummaryCallbacksImpl.class
   734 Fri Jul 29 13:29:24 BST 2022 org/apache/hadoop/fs/s3a/S3AFileSystem$2.class
161511 Fri Jul 29 13:29:24 BST 2022 org/apache/hadoop/fs/s3a/S3AFileSystem.class
  6017 Fri Jul 29 13:29:24 BST 2022 org/apache/hadoop/fs/s3a/S3AFileSystem$ListingOperationCallbacksImpl.class
  3036 Fri Jul 29 13:29:24 BST 2022 org/apache/hadoop/fs/s3a/S3AFileSystem$InputStreamCallbacksImpl.class
 10516 Fri Jul 29 13:29:24 BST 2022 org/apache/hadoop/fs/s3a/S3AFileSystem$OperationCallbacksImpl.class
  2045 Fri Jul 29 13:29:24 BST 2022 org/apache/hadoop/fs/s3a/S3AFileSystem$HeaderProcessingCallbacksImpl.class
r
Yes, and if I don't use Iceberg it works just fine (e..g writing Parquet to S3). It's with Iceberg that things stop working 😞
a
Is there a more detailed stacktrace for
ClassNotFound
? Which part of the job tries to load this class?
a
Not really, information I’m looking for is which part of the code tries to reference S3AFileSystem. E.g. like this:
Copy code
java.lang.ClassNotFoundException: org.apache.flink.shaded.guava18.com.google.common.collect.Lists
    at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at org.apache.flink.runtime.execution.librarycache.FlinkUserCodeClassLoaders$ChildFirstClassLoader.loadClass(FlinkUserCodeClassLoaders.java:124)
This way it should be easier to track down which classloader tries to find it. One thing I’ve noticed in your question - you specify
HADOOP_CLASSPATH
, wonder if something may try and look there? But this is just guessing
r
Ahh. Here you go:
Copy code
Caused by: org.apache.flink.table.gateway.service.utils.SqlExecutionException: Failed to execute the operation b685c995-3280-4a9e-b6c0-18ab9369d790.                                       β”‚
β”‚       at org.apache.flink.table.gateway.service.operation.OperationManager$Operation.processThrowable(OperationManager.java:414)                                                          β”‚
β”‚       at org.apache.flink.table.gateway.service.operation.OperationManager$Operation.lambda$run$0(OperationManager.java:267)                                                              β”‚
β”‚       at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)                                                                                                β”‚
β”‚       at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)                                                                                                               β”‚
β”‚       at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)                                                                                                β”‚
β”‚       at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)                                                                                                               β”‚
β”‚       at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)                                                                                        β”‚
β”‚       at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)                                                                                        β”‚
β”‚       ... 1 more                                                                                                                                                                          β”‚
β”‚Caused by: org.apache.flink.table.api.TableException: Could not execute CREATE DATABASE: (catalogDatabase: [{}], catalogName: [c_iceberg_hive], databaseName: [db_rmoff], ignoreIfExists: [β”‚
β”‚       at org.apache.flink.table.operations.ddl.CreateDatabaseOperation.execute(CreateDatabaseOperation.java:90)                                                                           β”‚
β”‚       at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeInternal(TableEnvironmentImpl.java:1092)                                                                         β”‚
β”‚       at org.apache.flink.table.gateway.service.operation.OperationExecutor.callOperation(OperationExecutor.java:556)                                                                     β”‚
β”‚       at org.apache.flink.table.gateway.service.operation.OperationExecutor.executeOperation(OperationExecutor.java:444)                                                                  β”‚
β”‚       at org.apache.flink.table.gateway.service.operation.OperationExecutor.executeStatement(OperationExecutor.java:207)                                                                  β”‚
β”‚       at org.apache.flink.table.gateway.service.SqlGatewayServiceImpl.lambda$executeStatement$1(SqlGatewayServiceImpl.java:212)                                                           β”‚
β”‚       at org.apache.flink.table.gateway.service.operation.OperationManager.lambda$submitOperation$1(OperationManager.java:119)                                                            β”‚
β”‚       at org.apache.flink.table.gateway.service.operation.OperationManager$Operation.lambda$run$0(OperationManager.java:258)                                                              β”‚
β”‚       ... 7 more                                                                                                                                                                          β”‚
β”‚Caused by: java.lang.RuntimeException: Failed to create namespace db_rmoff in Hive Metastore                                                                                               β”‚
β”‚       at org.apache.iceberg.hive.HiveCatalog.createNamespace(HiveCatalog.java:294)                                                                                                        β”‚
β”‚       at org.apache.iceberg.flink.FlinkCatalog.createDatabase(FlinkCatalog.java:222)                                                                                                      β”‚
β”‚       at org.apache.iceberg.flink.FlinkCatalog.createDatabase(FlinkCatalog.java:213)                                                                                                      β”‚
β”‚       at org.apache.flink.table.catalog.CatalogManager.createDatabase(CatalogManager.java:1381)                                                                                           β”‚
β”‚       at org.apache.flink.table.operations.ddl.CreateDatabaseOperation.execute(CreateDatabaseOperation.java:84)                                                                           β”‚
β”‚       ... 14 more                                                                                                                                                                         β”‚
β”‚Caused by: MetaException(message:java.lang.RuntimeException: java.lang.ClassNotFoundException: Class org.apache.hadoop.fs.s3a.S3AFileSystem not found)                                     β”‚
β”‚       at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$create_database_result$create_database_resultStandardScheme.read(ThriftHiveMetastore.java:39343)                        β”‚
β”‚       at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$create_database_result$create_database_resultStandardScheme.read(ThriftHiveMetastore.java:39311)                        β”‚
β”‚       at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$create_database_result.read(ThriftHiveMetastore.java:39245)                                                             β”‚
β”‚       at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:86)                                                                                                             β”‚
β”‚       at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.recv_create_database(ThriftHiveMetastore.java:1106)                                                              β”‚
β”‚       at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.create_database(ThriftHiveMetastore.java:1093)                                                                   β”‚
β”‚       at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.createDatabase(HiveMetaStoreClient.java:811)                                                                                β”‚
β”‚       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                                                                   β”‚
β”‚       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)                                                                                 β”‚
β”‚       at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)                                                                         β”‚
β”‚       at java.base/java.lang.reflect.Method.invoke(Method.java:566)                                                                                                                       β”‚
β”‚       at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.invoke(RetryingMetaStoreClient.java:208)                                                                                β”‚
β”‚       at com.sun.proxy.$Proxy35.createDatabase(Unknown Source)                                                                                                                            β”‚
β”‚       at org.apache.iceberg.hive.HiveCatalog.lambda$createNamespace$8(HiveCatalog.java:283)                                                                                               β”‚
β”‚       at org.apache.iceberg.ClientPoolImpl.run(ClientPoolImpl.java:58)                                                                                                                    β”‚
β”‚       at org.apache.iceberg.ClientPoolImpl.run(ClientPoolImpl.java:51)                                                                                                                    β”‚
β”‚       at org.apache.iceberg.hive.CachedClientPool.run(CachedClientPool.java:122)                                                                                                          β”‚
β”‚       at org.apache.iceberg.hive.HiveCatalog.createNamespace(HiveCatalog.java:281)                                                                                                        β”‚
β”‚       ... 18 more
FWIW I have experimented with and without using the full Hadoop distro. Currently I've unset
HADOOP_CLASSPATH
and just including the handful of JARs that it does need directly under
./lib
a
Could this actually originate from hive side?
ThriftHiveMetastore
seems to me like something outside of Flink
Copy code
Caused by: MetaException(message:java.lang.RuntimeException: java.lang.ClassNotFoundException: Class org.apache.hadoop.fs.s3a.S3AFileSystem not found)                                     β”‚
β”‚       at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$create_database_result$create_database_resultStandardScheme.read(ThriftHiveMetastore.java:39343)
This part specifically
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:86)
r
how would I go about fixing that? and also why would it only break when I use iceberg, but be fine when writing with Parquet?
(thank you, btw, for your help so far with this!)
a
I would assume that s3 with parquet does not rely on hive πŸ™‚ > how would I go about fixing that? I’d check Hive config and see if
hadoop-aws
is in the relevant classpath. I’m not familiar with hive unfortunatelly, so can’t propose anything more specific.
r
hmm. for s3 and parquet I'm still using hive as the catalog/metastore
let me check the hive config though, thank you
a
In this case it looks like iceberg also use hive, so mechanism may be different.
r
🀯
a
At least based on this: (lots of trust in data from stacktrace πŸ™‚ )
Copy code
β”‚       at org.apache.iceberg.hive.HiveCatalog.lambda$createNamespace$8(HiveCatalog.java:283)                                                                                               β”‚
β”‚       at org.apache.iceberg.ClientPoolImpl.run(ClientPoolImpl.java:58)
r
still no luck, btw - in case you have any more ideas πŸ™‚
a
looks like image that you’re using for hive includes base hadoop dependency
I may be able to try and reproduce it in a few hours, but I’d try to add
hadoop-aws
to the image (unless you already tried that)
r
OMG I think you're onto something @Aleksandr Pilipenko
I follow what you mean now
let me see if I can add it
@Aleksandr Pilipenko OK, I've found this error being thrown on the HMS, so I think you've got to the root of the issue. Thank you so much πŸ™ Now I'll see about adding in the deps etc, but hopefully it'll be plain sailing from here… hopefully πŸ˜‰
a
This may help https://github.com/naushadh/hive-metastore/blob/main/Dockerfile however there is more that just s3 added to this image
r
yeah I found that one. thanks.
πŸ‘ 1
😁
πŸŽ‰ 1
d
Which dependency was it in the end?
r
@D S it was the ones you said, but they needed to be added to the hive metastore, which is running in a separate container
πŸ‘ 1
i didn't realise the error was being thrown over thrift from HMS, hence my puzzlement in all this
d
Fun. Glad you figured it out.