Users cannot provide their own sharding function when using FileIO
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 4.7k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 196
Description
Beam uses RandomShardingFunction ([https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/io/WriteFiles.java#L834](https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/io/WriteFiles.java#L834)) by default for sharding when using FileIO.write().
RandomShardingFuncction doesn’t work well with Flink Runner. Its assigning same key (hashDestination(destination, destinationCoder)) along with the shard number. ([https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/io/WriteFiles.java#L863](https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/io/WriteFiles.java#L863))
This is causing different ShardedKeys going to same task slot. As a result, there is no equal distribution of files written from different task slots.
E.g. 2 files are written by task slot 1, 3 files written by task slot 2, 0 files written by other task slots.
As a result, we are seeing Out of Memory from the pods writing more files.
At [https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/io/WriteFiles.java#L695-L698](https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/io/WriteFiles.java#L695-L698)
There is an option to give a different sharding function. But there is no way for the user to mention different sharding function when using FileIO class.
Imported from Jira [BEAM-13667](https://issues.apache.org/jira/browse/BEAM-13667). Original Jira may contain additional context.
Reported by: kathulasandeep.
Contributor guide
Assessment
This issue has not been assessed yet.