Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: BigtableSource "Desired bundle size 0 bytes must be greater than 0" #28793

Closed
2 of 16 tasks
joar opened this issue Oct 3, 2023 · 4 comments · Fixed by #28798
Closed
2 of 16 tasks

[Bug]: BigtableSource "Desired bundle size 0 bytes must be greater than 0" #28793

joar opened this issue Oct 3, 2023 · 4 comments · Fixed by #28798

Comments

@joar
Copy link
Contributor

joar commented Oct 3, 2023

In short,

  • if targetParallelismBigtableSource#getEstimatedSizeBytes; then
  • desiredBundleSizeBytes is set to 0; which
  • makes BigtableSource#splitKeyRangeIntoBundleSizedSubranges angry.

What happened?

Imagine a case where in:

long estimatedBytes = source.getEstimatedSizeBytes(options);
long bytesPerBundle = estimatedBytes / targetParallelism;
List<? extends BoundedSource<T>> bundles = source.split(bytesPerBundle, options);

  • targetParallelism is 32; and
  • source.getEstimatedByteSize() is 10

then

  • bytesPerBundle will be 0

so

List<? extends BoundedSource<T>> bundles = source.split(bytesPerBundle, options);

will be called with the values: split.source(0L, options)

In OffsetBasedSource#split, this desired-0-sized split is handled:

long desiredBundleSizeOffsetUnits =
Math.max(Math.max(1, desiredBundleSizeBytes / getBytesPerOffset()), minBundleSize);

But BigtableSource#split does not seem to handle the desired-0-sized split:

desiredBundleSizeBytes =
Math.max(sizeEstimate / maximumNumberOfSplits, desiredBundleSizeBytes);
// Delegate to testable helper.
List<BigtableSource> splits =
splitBasedOnSamples(desiredBundleSizeBytes, getSampleRowKeys(options));

so a few frames down the road from BigtableSource#split you'll end up violating this checkArgument in BigtableSource#splitKeyRangeIntoBundleSizedSubranges:

checkArgument(
desiredBundleSizeBytes > 0,
"Desired bundle size %s bytes must be greater than 0.",
desiredBundleSizeBytes);

Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

Issue Components

  • Component: Python SDK
  • Component: Java SDK
  • Component: Go SDK
  • Component: Typescript SDK
  • Component: IO connector
  • Component: Beam YAML
  • 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
  • Component: Google Cloud Dataflow Runner
@Abacn
Copy link
Contributor

Abacn commented Oct 3, 2023

Thanks for reporting the issue. Interesting edge case, since it has been root caused, would you mind entering a PR for fix, thanks for the contribution!

@joar
Copy link
Contributor Author

joar commented Oct 3, 2023

The scenario that makes this edge case pop up for us is running pipelines in CI against the Bigtable emulator. The key of course being tiny tables.

I'll enter a PR!

@joar
Copy link
Contributor Author

joar commented Oct 3, 2023

The question is, should it be fixed in BigtableSource, BoundedReadEvaluatorFactory or both?

@Abacn
Copy link
Contributor

Abacn commented Oct 3, 2023

Fix BoundedReadEvaluatorFactory

  • Pro: prevent errorprone behavior on all implementation like this
  • Con: changed the behavior of java core, the scope of impact is unknown

Fix BigtableSource

  • Pro: safe
  • Con: just fix one use case

Based on this understanding I would vote for Fix BigtableSource for now.

joar added a commit to joar/beam that referenced this issue Oct 4, 2023
Fixes apache#28793 in the way suggested in apache#28793 (comment):

- `BoundedReadEvaluatorFactory#getInitialInputs` may still calculate a
  `bytesPerBundle` of `0`; but
- `BigtableSource#split` will interpret it as `1` in order to not
  violate the `checkArgument()` in
  https://github.com/apache/beam/blob/71c8459633ec86e576eca080a26be9f42474ecb2/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIO.java#L1623-L1626
@github-actions github-actions bot added this to the 2.52.0 Release milestone Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants