Repository navigation
Closed
Description
Say we have a table test (col1: string).
case class Input(col1: String)
val df = spark.createDataFrame(List(Input("data1"), Input("data2")))
df.write.format("iceberg").mode("overwrite").option("write-format", "parquet").save("default.test")
2019-09-04 05:35:13 ERROR TaskResultGetter:91 - Exception while getting task result
com.esotericsoftware.kryo.KryoException: java.lang.UnsupportedOperationException
Serialization trace:
splitOffsets (org.apache.iceberg.GenericDataFile)
files (org.apache.iceberg.spark.source.Writer$TaskCommit)
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:144)
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:543)
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:731)
at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.read(DefaultArraySerializers.java:391)
at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.read(DefaultArraySerializers.java:302)
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:731)
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125)
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:543)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:813)
at org.apache.spark.serializer.KryoSerializerInstance.deserialize(KryoSerializer.scala:362)
at org.apache.spark.scheduler.DirectTaskResult.value(TaskResult.scala:88)
at org.apache.spark.scheduler.TaskResultGetter$$anon$3$$anonfun$run$1.apply$mcV$sp(TaskResultGetter.scala:72)
at org.apache.spark.scheduler.TaskResultGetter$$anon$3$$anonfun$run$1.apply(TaskResultGetter.scala:63)
at org.apache.spark.scheduler.TaskResultGetter$$anon$3$$anonfun$run$1.apply(TaskResultGetter.scala:63)
at org.apache.spark.util.Utils$.logUncaughtExceptions(Utils.scala:1945)
at org.apache.spark.scheduler.TaskResultGetter$$anon$3.run(TaskResultGetter.scala:62)
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: java.lang.UnsupportedOperationException
at org.apache.iceberg.shaded.com.google.common.collect.ImmutableCollection.add(ImmutableCollection.java:244)
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:134)
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:40)
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:731)
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125)
... 18 more
2019-09-04 05:35:13 ERROR WriteToDataSourceV2Exec:70 - Data source writer IcebergWrite(table=default.test, format=PARQUET) is aborting.
2019-09-04 05:35:13 ERROR WriteToDataSourceV2Exec:70 - Data source writer IcebergWrite(table=default.test, format=PARQUET) aborted.
Hitting this when writing Parquet data in Spark 2.4 using the latest master. I believe this is because in 549da80 an immutable copy of the split offsets are stored in GenericDataFile. The serialization is successful, but when deserializing, Kryo will try to instantiate an ImmutableList first and then add elements to it.
I think this can be fixed in two ways:
- Don't use immutable copies of the split offsets list. I am not sure what was the intention of making them immutable in the first place. Other metadata like metrics are still being provided in mutable collections.
- Include custom Kryo serdes which support guava immutable collections. e.g. https://github.com/magro/kryo-serializers/
Option 2 seems a little overkill IMO for this specific case given that immutable collections don't seem to be necessary here, but would like to hear what others think.
Metadata
Metadata
Assignees
Labels
No labels
Activity
rdblue commentedon Sep 5, 2019
I would rather add the Kryo serializers for immutable collections. I think it makes sense for Iceberg to use ImmutableList because the data returned should not be mutable and that minimizes the cost of later copies.
aokolnychyi commentedon Sep 6, 2019
We ended up with
kryo.register(Class.forName("org.apache.iceberg.GenericDataFile"), new JavaSerializer());to make Kryo work with Iceberg.GenericDataFilehas custom serialization logic.rdsr commentedon Sep 17, 2019
@shardulm94 do u plan to submit a PR for this?
shardulm94 commentedon Sep 17, 2019
@rdsr I plan to, although I am not fully sure how to register the custom serializers in Spark.
@aokolnychyi Did you have to modify Spark to add that line (here) or is there a way to get the Kryo instance used so that we can register the class from inside Iceberg?
aokolnychyi commentedon Sep 17, 2019
@shardulm94 @rdsr it is possible to set this via the public API:
aokolnychyi commentedon Sep 17, 2019
If the above logic works for you, it would be great to add this to our docs.
aokolnychyi commentedon Sep 26, 2019
@shardulm94 did the suggested approach work for you?
jzhuge commentedon Oct 17, 2019
@aokolnychyi @shardulm94 @rdsr please take a look at a custom Spark Kryo registrator for Iceberg in #549.