[SUPPORT] DeltaStreamer sync hive-table called NPE when adding patition(s)
Tips before filing an issue
-
Have you gone through our FAQs? ✔️
-
Join the mailing list to engage in conversations and get faster support at [email protected]. ✔️
-
If you have triaged this as a bug, then file an issue directly. ✔️
Describe the problem you faced
Using Hudi-Tool DeltaStreamer ingestion data from Kafka, and writing hudi-table successfully.
But there was some error when I expected sync hive-tables and add patition in them.
On top of that weirdness, hive-table can be created but the patition adding process called NullPointerException !!
To Reproduce
Steps to reproduce the behavior:
- Using Debezium capture MySQL data into Kafka and enabling Kafka-Connector with Confluent Schema Registry managing the schema;
- Prepare the Environment including
deploy Spark-Master/Worker,start Hive-MetaStore Server. - Run the Spark Job via spark-submit script:
spark-submit \
--jars "/home/hadoop/app/spark/ex_jar/hudi-utilities-bundle_2.12-0.12.0.jar,/home/hadoop/app/spark/ex_jar/spark-avro_2.12-3.2.2.jar" \
--master spark://web-65:7077 \
--deploy-mode cluster \
--driver-memory 1g \
--driver-cores 2 \
--executor-memory 1g \
--total-executor-cores 2 \
--class org.apache.hudi.utilities.deltastreamer.HoodieDeltaStreamer \
/home/hadoop/app/spark/ex_jar/hudi-utilities-bundle_2.12-0.12.0.jar \
--table-type COPY_ON_WRITE \
--op UPSERT \
--target-base-path cosn://bigdata-1252394470/hudi/cdc/mysql/table2 \
--target-table table2 \
--continuous \
--min-sync-interval-seconds 60 \
--source-class org.apache.hudi.utilities.sources.debezium.MysqlDebeziumSource \
--payload-class org.apache.hudi.common.model.debezium.MySqlDebeziumAvroPayload \
--source-ordering-field id \
--hoodie-conf schema.registry.url=http://web-65:8181 \
--hoodie-conf hoodie.deltastreamer.schemaprovider.registry.url=http://web-65:8181/subjects/debezium-cdc-server-mysql2.test_db.table2-value/versions/latest \
--hoodie-conf hoodie.deltastreamer.source.kafka.value.deserializer.class=io.confluent.kafka.serializers.KafkaAvroDeserializer \
--hoodie-conf hoodie.deltastreamer.source.kafka.topic=debezium-cdc-server-mysql2.test_db.table2 \
--hoodie-conf bootstrap.servers=web-65:9092 \
--hoodie-conf auto.offset.reset=earliest \
--hoodie-conf hoodie.datasource.write.recordkey.field=id \
--hoodie-conf hoodie.datasource.write.partitionpath.field=u_name \
--enable-sync \
--sync-tool-classes org.apache.hudi.hive.HiveSyncTool \
--hoodie-conf hoodie.datasource.hive_sync.partition_extractor_class=org.apache.hudi.hive.MultiPartKeysValueExtractor \
--hoodie-conf hoodie.datasource.write.hive_style_partitioning=true \
--hoodie-conf hoodie.datasource.hive_sync.enable=true \
--hoodie-conf hoodie.datasource.hive_sync.database=default \
--hoodie-conf hoodie.datasource.hive_sync.table=hudi_mysql_table2 \
--hoodie-conf hoodie.datasource.hive_sync.partition_fields=u_name \
--hoodie-conf hoodie.datasource.hive_sync.use_jdbc=false \
--hoodie-conf hoodie.datasource.hive_sync.metastore.uris=thrift://web-65:9083 \
--hoodie-conf hoodie.datasource.hive_sync.mode=hms
my hostname is web-65, all component deployed on this machine except ZK\KAFKA.
Expected behavior
Hive table could be created and patition(s) be added.
Environment Description
-
Hudi version : 0.12.0
-
Spark version : 3.2.2
-
Hive version : 2.3.9
-
Hadoop version : 2.7.5 (Useless, only for starting hive-metastore process)
-
Storage (HDFS/S3/GCS..) : Tencent COS
-
Running on Docker? (yes/no) : no
Additional context
Stacktrace
22/09/02 11:13:15 INFO HoodieMergedLogRecordScanner: Size of file spilled to disk => 0
22/09/02 11:13:15 INFO HoodieBackedTableMetadata: Opened 3 metadata log files (dataset instant=20220902111141862, metadata instant=20220902111141862) in 1986 ms
22/09/02 11:13:15 INFO BaseTableMetadata: Listed partitions from metadata: #partitions=3
22/09/02 11:13:15 INFO HiveSyncTool: Storage partitions scan complete. Found 3
22/09/02 11:13:15 INFO HiveSyncTool: New Partitions [u_name=A, u_name=B, u_name=C]
22/09/02 11:13:15 INFO HMSDDLExecutor: Adding partitions 3 to table hudi_mysql_table2
22/09/02 11:13:15 ERROR HMSDDLExecutor: default.hudi_mysql_table2 add partition failed
MetaException(message:java.io.IOException: Got exception: java.io.IOException java.lang.NullPointerException)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$add_partitions_req_result$add_partitions_req_resultStandardScheme.read(ThriftHiveMetastore.java)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$add_partitions_req_result$add_partitions_req_resultStandardScheme.read(ThriftHiveMetastore.java)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$add_partitions_req_result.read(ThriftHiveMetastore.java)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:88)
...
...
Caused by: org.apache.hudi.hive.HoodieHiveSyncException: Failed to sync partitions for table hudi_mysql_table2
at org.apache.hudi.hive.HiveSyncTool.syncPartitions(HiveSyncTool.java:340)
at org.apache.hudi.hive.HiveSyncTool.syncHoodieTable(HiveSyncTool.java:232)
at org.apache.hudi.hive.HiveSyncTool.doSync(HiveSyncTool.java:153)
at org.apache.hudi.hive.HiveSyncTool.syncHoodieTable(HiveSyncTool.java:141)
... 9 more
Caused by: org.apache.hudi.hive.HoodieHiveSyncException: default.hudi_mysql_table2 add partition failed
at org.apache.hudi.hive.ddl.HMSDDLExecutor.addPartitionsToTable(HMSDDLExecutor.java:209)
at org.apache.hudi.hive.HoodieHiveSyncClient.addPartitionsToTable(HoodieHiveSyncClient.java:101)
at org.apache.hudi.hive.HiveSyncTool.syncPartitions(HiveSyncTool.java:323)
... 12 more
Caused by: MetaException(message:java.io.IOException: Got exception: java.io.IOException java.lang.NullPointerException)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$add_partitions_req_result$add_partitions_req_resultStandardScheme.read(ThriftHiveMetastore.java)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$add_partitions_req_result$add_partitions_req_resultStandardScheme.read(ThriftHiveMetastore.java)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$add_partitions_req_result.read(ThriftHiveMetastore.java)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:88)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.recv_add_partitions_req(ThriftHiveMetastore.java:1911)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.add_partitions_req(ThriftHiveMetastore.java:1898)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.add_partitions(HiveMetaStoreClient.java:625)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.invoke(RetryingMetaStoreClient.java:173)
at com.sun.proxy.$Proxy40.add_partitions(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient$SynchronizedHandler.invoke(HiveMetaStoreClient.java:2327)
at com.sun.proxy.$Proxy40.add_partitions(Unknown Source)
at org.apache.hudi.hive.ddl.HMSDDLExecutor.addPartitionsToTable(HMSDDLExecutor.java:206)
... 14 more
When I switch the sycn_mode to jdbc, I got the same Exception. However, I can run the HQL below which caught from spark logs to complete the hive table.
ALTER TABLE `default`.`hudi_mysql_table2`
ADD IF NOT EXISTS
PARTITION (`u_name`='A') LOCATION 'cosn://bigdata-1252394470/hudi/cdc/mysql/table2_001/u_name=A'
PARTITION (`u_name`='B') LOCATION 'cosn://bigdata-1252394470/hudi/cdc/mysql/table2_001/u_name=B'
PARTITION (`u_name`='C') LOCATION 'cosn://bigdata-1252394470/hudi/cdc/mysql/table2_001/u_name=C' ;
After the HQL, everything goes smoothly! (i.e. Query the hudi-table by Presto...)
↓↓ The core logs syncing as jdbc mode ↓↓
22/09/02 16:57:27 INFO HiveSyncTool: Storage partitions scan complete. Found 3
22/09/02 16:57:27 INFO HiveSyncTool: New Partitions [u_name=A, u_name=B, u_name=C]
22/09/02 16:57:27 INFO QueryBasedDDLExecutor: Adding partitions 3 to table hudi_mysql_table001
22/09/02 16:57:27 INFO QueryBasedDDLExecutor: Executing SQL ALTER TABLE `default`.`hudi_mysql_table001` ADD IF NOT EXISTS PARTITION (`u_name`='A') LOCATION 'cosn://bigdata-1252394470/hudi/cdc/mysql/table2_001/u_name=A' PARTITION (`u_name`='B') LOCATION 'cosn://bigdata-1252394470/hudi/cdc/mysql/table2_001/u_name=B' PARTITION (`u_name`='C') LOCATION 'cosn://bigdata-1252394470/hudi/cdc/mysql/table2_001/u_name=C'
22/09/02 16:57:28 INFO metastore: Closed a connection to metastore, current connections: 0
22/09/02 16:57:28 ERROR HoodieDeltaStreamer: Shutting down delta-sync due to exception
org.apache.hudi.exception.HoodieException: Could not sync using the meta sync class org.apache.hudi.hive.HiveSyncTool
at org.apache.hudi.sync.common.util.SyncUtilHelpers.runHoodieMetaSync(SyncUtilHelpers.java:58)
at org.apache.hudi.utilities.deltastreamer.DeltaSync.runMetaSync(DeltaSync.java:716)
at org.apache.hudi.utilities.deltastreamer.DeltaSync.writeToSink(DeltaSync.java:634)
at org.apache.hudi.utilities.deltastreamer.DeltaSync.syncOnce(DeltaSync.java:335)
at org.apache.hudi.utilities.deltastreamer.HoodieDeltaStreamer$DeltaSyncService.lambda$startService$0(HoodieDeltaStreamer.java:687)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.hudi.exception.HoodieException: Got runtime exception when hive syncing hudi_mysql_table001
at org.apache.hudi.hive.HiveSyncTool.syncHoodieTable(HiveSyncTool.java:144)
at org.apache.hudi.sync.common.util.SyncUtilHelpers.runHoodieMetaSync(SyncUtilHelpers.java:56)
... 8 more
Caused by: org.apache.hudi.hive.HoodieHiveSyncException: Failed to sync partitions for table hudi_mysql_table001
at org.apache.hudi.hive.HiveSyncTool.syncPartitions(HiveSyncTool.java:340)
at org.apache.hudi.hive.HiveSyncTool.syncHoodieTable(HiveSyncTool.java:232)
at org.apache.hudi.hive.HiveSyncTool.doSync(HiveSyncTool.java:153)
at org.apache.hudi.hive.HiveSyncTool.syncHoodieTable(HiveSyncTool.java:141)
... 9 more
...
...
Caused by: MetaException(message:java.io.IOException: Got exception: java.io.IOException java.lang.NullPointerException)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$add_partitions_req_result$add_partitions_req_resultStandardScheme.read(ThriftHiveMetastore.java)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$add_partitions_req_result$add_partitions_req_resultStandardScheme.read(ThriftHiveMetastore.java)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$add_partitions_req_result.read(ThriftHiveMetastore.java)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:86)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.recv_add_partitions_req(ThriftHiveMetastore.java:1911)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.add_partitions_req(ThriftHiveMetastore.java:1898)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.add_partitions(HiveMetaStoreClient.java:625)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.invoke(RetryingMetaStoreClient.java:173)
at com.sun.proxy.$Proxy26.add_partitions(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient$SynchronizedHandler.invoke(HiveMetaStoreClient.java:2327)
at com.sun.proxy.$Proxy26.add_partitions(Unknown Source)
at org.apache.hadoop.hive.ql.metadata.Hive.createPartitions(Hive.java:2103)
... 21 more
@alexeykudinkin could you take a look?
@Archie-selfless I'm unable to reproduce the NPE. Could you share the schema of the source? Does Spark uses the same Hive version as the Hive metastore?
This command works for me. I can see in beeline that the table and partition paths are synced.
export SPARK_HOME=/Users/ethan/Work/lib/spark-3.2.2-bin-hadoop3.2
/Users/ethan/Work/lib/spark-3.2.2-bin-hadoop3.2/bin/spark-submit \
--master local[4] \
--driver-memory 4g --executor-memory 2g --num-executors 4 --executor-cores 1 \
--conf spark.serializer=org.apache.spark.serializer.KryoSerializer \
--conf spark.sql.catalogImplementation=hive \
--conf spark.driver.maxResultSize=1g \
--conf spark.speculation=true \
--conf spark.speculation.multiplier=1.0 \
--conf spark.speculation.quantile=0.5 \
--conf spark.ui.port=6680 \
--conf spark.eventLog.enabled=true \
--conf spark.eventLog.dir=/Users/ethan/Work/data/hudi/spark-logs \
--jars $HUDI_DIR/packaging/hudi-spark-bundle/target/hudi-spark3.2-bundle_2.12-0.12.0.jar \
--class org.apache.hudi.utilities.deltastreamer.HoodieDeltaStreamer \
$HUDI_DIR/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.12-0.12.0.jar \
--props $TEST_BASE_DIR/ds_cow.properties \
--schemaprovider-class org.apache.hudi.utilities.schema.FilebasedSchemaProvider \
--source-class org.apache.hudi.utilities.sources.ParquetDFSSource \
--source-ordering-field ts \
--target-base-path file:$TEST_BASE_DIR/hudi_mysql_table2 \
--target-table hudi_mysql_table2 \
--table-type COPY_ON_WRITE \
--op UPSERT \
--enable-sync \
--sync-tool-classes org.apache.hudi.hive.HiveSyncTool \
--hoodie-conf hoodie.datasource.hive_sync.partition_extractor_class=org.apache.hudi.hive.MultiPartKeysValueExtractor \
--hoodie-conf hoodie.datasource.write.hive_style_partitioning=true \
--hoodie-conf hoodie.datasource.hive_sync.enable=true \
--hoodie-conf hoodie.datasource.hive_sync.database=default \
--hoodie-conf hoodie.datasource.hive_sync.table=hudi_mysql_table2 \
--hoodie-conf hoodie.datasource.hive_sync.partition_fields=u_name \
--hoodie-conf hoodie.datasource.hive_sync.use_jdbc=false \
--hoodie-conf hoodie.datasource.hive_sync.metastore.uris=thrift://localhost:9083 \
--hoodie-conf hoodie.datasource.hive_sync.mode=hms >> ds.log 2>&1
ds_cow.properties
# Key fields, for kafka example
hoodie.datasource.write.recordkey.field=key
hoodie.datasource.write.partitionpath.field=u_name
# Schema provider props (change to absolute path based on your installation)
hoodie.deltastreamer.schemaprovider.source.schema.file=file:/TEST_BASE_DIR/schema.avsc
hoodie.deltastreamer.schemaprovider.target.schema.file=file:/TEST_BASE_DIR/schema.avsc
# DFS Source
hoodie.deltastreamer.source.dfs.root=file:/TEST_BASE_DIR/source
schema.avsc
{
"type" : "record",
"name" : "test_struct",
"namespace" : "test_namespace",
"fields" : [ {
"name" : "key",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "partition",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "ts",
"type" : [ "null", "long" ],
"default" : null
}, {
"name" : "textField",
"type" : [ "null", "string" ],
"default" : null
}, {
"name" : "decimalField",
"type" : [ "null", "float" ],
"default" : null
}, {
"name" : "longField",
"type" : [ "null", "long" ],
"default" : null
}, {
"name" : "arrayField",
"type" : [ "null", {
"type" : "array",
"items" : [ "int", "null" ]
} ],
"default" : null
}, {
"name" : "mapField",
"type" : [ "null", {
"type" : "map",
"values" : [ "int", "null" ]
} ],
"default" : null
}, {
"name" : "round",
"type" : [ "null", "int" ],
"default" : null
}, {
"name" : "u_name",
"type" : [ "null", "string" ],
"default" : null
} ]
}
@Archie-selfless I'm not sure if this is related to the MySqlDebeziumSource and MySqlDebeziumAvroPayload. Could you try a simple ingestion with ParquetDFSSource as above to see if the Hive sync works in your setup?
@yihua I'm really sorry for replying the current issue so late! With the help of my colleagues, I completed the Hive-sync by accessing S3 protocol. I think it's because the org.apache.hudi.hive.HiveSyncTool always fetch the s3\s3a as protocol. My current core-site.xml is here:
<configuration>
<property>
<name>fs.defaultFS</name>
<value>cons://bigdata-1252394470</value>
<description>COS bucket name</description>
</property>
<property>
<name>fs.cosn.userinfo.secretId</name>
<value>XXXXXXXX</value>
<description>Tencent Cloud Secret Id</description>
</property>
<property>
<name>fs.cosn.userinfo.secretKey</name>
<value>XXXXXXXX</value>
<description>Tencent Cloud Secret Key</description>
</property>
<property>
<name>fs.cosn.bucket.region</name>
<value>ap-guangzhou</value>
<description>The region where the bucket is located.</description>
</property>
<property>
<name>fs.cosn.bucket.endpoint_suffix</name>
<value>cos.ap-guangzhou.myqcloud.com</value>
<description>
COS endpoint to connect to.
For public cloud users, it is recommended not to set this option, and only the correct area field is required.
</description>
</property>
<property>
<name>fs.cosn.impl</name>
<value>org.apache.hadoop.fs.CosFileSystem</value>
<description>The implementation class of the CosN Filesystem.</description>
</property>
<property>
<name>fs.AbstractFileSystem.cosn.impl</name>
<value>org.apache.hadoop.fs.CosN</value>
<description>The implementation class of the CosN AbstractFileSystem.</description>
</property>
<!-- ############### If I add below params, everything goes well ############### -->
<property>
<name>fs.s3.impl</name>
<value>org.apache.hadoop.fs.s3a.S3AFileSystem</value>
</property>
<property>
<name>fs.s3a.impl</name>
<value>org.apache.hadoop.fs.s3a.S3AFileSystem</value>
</property>
<property>
<name>fs.s3n.impl</name>
<value>org.apache.hadoop.fs.s3native.NativeS3FileSystem</value>
</property>
<property>
<name>fs.s3.endpoint</name>
<value>cos.ap-guangzhou.myqcloud.com</value>
</property>
<property>
<name>fs.s3a.endpoint</name>
<value>cos.ap-guangzhou.myqcloud.com</value>
</property>
<property>
<name>fs.s3n.endpoint</name>
<value>cos.ap-guangzhou.myqcloud.com</value>
</property>
<property>
<name>fs.s3a.access.key</name>
<value>XXXXXXXX</value>
</property>
<property>
<name>fs.s3a.secret.key</name>
<value>XXXXXXXX</value>
</property>
<property>
<name>fs.s3a.aws.credentials.provider</name>
<value>org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider</value>
</property>
</configuration>
Main Summary: org.apache.hudi.hive.HiveSyncTool always fetch the s3\s3a as protocol.(Based Hudi-0.12.0)