iceberg: Failed to assign splits due to the serialized split size
Apache Iceberg version
1.4.2 (latest release)
Query engine
Flink
Please describe the bug ๐
Hi there, I am trying to consume records from an Iceberg table in my Flink application and I am running into the following issue;
Caused by: org.apache.flink.util.FlinkRuntimeException: Failed to serialize splits.
at org.apache.flink.runtime.source.coordinator.SourceCoordinatorContext.lambda$assignSplits$4(SourceCoordinatorContext.java:223)
at java.base/java.util.HashMap.forEach(HashMap.java:1337)
at org.apache.flink.runtime.source.coordinator.SourceCoordinatorContext.lambda$assignSplits$5(SourceCoordinatorContext.java:213)
at org.apache.flink.runtime.source.coordinator.SourceCoordinatorContext.callInCoordinatorThread(SourceCoordinatorContext.java:428)
... 14 more
Caused by: java.io.UTFDataFormatException: Encoded string is too long: 123214
at org.apache.flink.core.memory.DataOutputSerializer.writeUTF(DataOutputSerializer.java:257)
at org.apache.iceberg.flink.source.split.IcebergSourceSplit.serializeV2(IcebergSourceSplit.java:150)
at org.apache.iceberg.flink.source.split.IcebergSourceSplitSerializer.serialize(IcebergSourceSplitSerializer.java:42)
at org.apache.iceberg.flink.source.split.IcebergSourceSplitSerializer.serialize(IcebergSourceSplitSerializer.java:25)
at org.apache.flink.runtime.source.event.AddSplitEvent.<init>(AddSplitEvent.java:44)
at org.apache.flink.runtime.source.coordinator.SourceCoordinatorContext.lambda$assignSplits$4(SourceCoordinatorContext.java:220)
... 17 more
Not really sure why it gets too big but when I looked at the source code here, it might be because there is too many file scan task in one split and that is why this is happening.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 29 (29 by maintainers)
Commits related to this issue
- [#9410] It fails to serialize IcebergSourceSplit when there is too many delete files which are created due to an upsert oepration on the table and then it is not possible to consume from such a table — committed to javrasya/iceberg by javrasya 3 years ago
- #9410 Still use writeUTF logic since that is an efficient way of serializing/deserializing and it is the most backward compatible, but support longer texts than 65K. This introduce a breaking change w... — committed to javrasya/iceberg by javrasya 3 years ago
- #9410 Write UTFs as chunks to not run into the max length a json can be due to the size of an unsigned short which is 65kb. The text is broken down to chunks that can always fit in 65kb and written t... — committed to javrasya/iceberg by javrasya 3 years ago
- [#9410] Introduce the new serialization with writing long UTF as V3 to allow smooth migration — committed to javrasya/iceberg by javrasya 3 years ago
- [#9410] Serialize as v3 by default Ahmet — committed to javrasya/iceberg by javrasya 3 years ago
- [#9410] Make the v3 serialization look more like the implementation in the Flink code Ahmet — committed to javrasya/iceberg by javrasya 3 years ago
- [#9410] Extract common code parts into separate functions to reduce code duplication — committed to javrasya/iceberg by javrasya 3 years ago
- [#9410] It fails to serialize IcebergSourceSplit when there is too many delete files which are created due to an upsert oepration on the table and then it is not possible to consume from such a table — committed to javrasya/iceberg by javrasya 3 years ago
- [#9410] Introduce the new serialization with writing long UTF as V3 to allow smooth migration — committed to javrasya/iceberg by javrasya 3 years ago
- [#9410] Serialize as v3 by default Ahmet — committed to javrasya/iceberg by javrasya 3 years ago
- [#9410] Make the v3 serialization look more like the implementation in the Flink code Ahmet — committed to javrasya/iceberg by javrasya 3 years ago
- [#9410] Extract common code parts into separate functions to reduce code duplication — committed to javrasya/iceberg by javrasya 3 years ago
- [#9410] Refactor according to the review and fix some format issues — committed to javrasya/iceberg by javrasya 3 years ago
- [#9410] Refactor according to the review and fix some format issues — committed to javrasya/iceberg by javrasya 3 years ago
- #9410 Fix code style issues Ahmet — committed to javrasya/iceberg by javrasya 3 years ago
I think RewriteDataFilesAction could help you there. If I remember correctly it will apply all the delete files on reading, so in theory, after a compaction, you should not need the delete files anymore. That said, I havenโt tried it myself, so this should be checked.
I couldnโt do this @pvary , the split is far ahead and some time is needed to get there in the application. My local environment is not able to run the app on real data and hit this problematic split on debug mode. It crashes because debug mode is quite a resource consuming mode. Still looking for a way to reproduce it and debu it but Just wanted to let you know the status. (Side note, I ended up re-creating my entire source data, that way it did not have this problem. But I want to find the reason why it exceeds that limit regardless.)
@stevenzwu: After a quick check, I have found this: https://github.com/apache/flink/blob/c6997c97c575d334679915c328792b8a3067cfb5/flink-core/src/main/java/org/apache/flink/core/memory/DataOutputSerializer.java#L256-L260
This means that anything which is above 64k could not be serialized by
DataOutputSerializer.writeUTF, which seems a bit arbitrary limit for me.We could use
DataOutputSerializer.writeCharswhich usesDataOutputSerializer.writeChar. The downside is that it is less effective if we use simple chars (between0x0001and0x007F): See: https://github.com/apache/flink/blob/c6997c97c575d334679915c328792b8a3067cfb5/flink-core/src/main/java/org/apache/flink/core/memory/DataOutputSerializer.java#L245C1-L254C10The upside that it should work regardless of the size of the string.