[Bug]: GenerateSequence is broken on SDF
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 4.7k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 196
Description
### What happened?
The transform `GenerateSequence.from(0).to(...).withRate(...)` that is expanded into a streaming source (that is bounded, as there's a maximum number of records read) is broken after it was migrated from an `UnboundedSource` based implementaion.
For smaller data sizes, the source works as expected, and a sequence is generated properly.
For larger data sizes, the transform causes workers to OOM and never make progress.
Reasons:
- Firstly, the maximum number of initial splits is 100: https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/io/BoundedReadFromUnboundedSource.java#L157-L161
- This makes it such that each individual split can be very large for medium data sizes (over 100k elements per split).
- Secondly, the consumption is implemented as a simple DoFn that consumes the whole source without checkpointing halfway: https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/io/BoundedReadFromUnboundedSource.java#L189-L212
This is what causes ooms for workers before they can make any progress.
(here's the expansion for GenerateSequence: https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/io/GenerateSequence.java#L242-L258)
I found that the expansion always became a `BoundedReadFromUnboundedSource` if we had `from` and `to` parameters.
### Issue Priority
Priority: 1 (data loss / total loss of function)
### Issue Components
- [ ] Component: Python SDK
- [X] Component: Java SDK
- [ ] Component: Go SDK
- [ ] Component: Typescript SDK
- [X] Component: IO connector
- [ ] Component: Beam examples
- [ ] Component: Beam playground
- [ ] Component: Beam katas
- [ ] Component: Website
- [ ] Component: Spark Runner
- [ ] Component: Flink Runner
- [ ] Component: Samza Runner
- [ ] Component: Twister2 Runner
- [ ] Component: Hazelcast Jet Runner
- [X] Component: Google Cloud Dataflow Runner
Contributor guide
Assessment
This issue has not been assessed yet.