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

fix reshuffle translation #137

Open
wants to merge 4 commits into
base: li_trunk
Choose a base branch
from

Conversation

minxhe
Copy link

@minxhe minxhe commented Jan 15, 2025

Background

According to the Java doc of Beam reshuffle, it should perform the following operation:

Performs a {@link GroupByKey} so that the data is key-partitioned. Configures the {@link WindowingStrategy} so that no data is dropped, but doesn't affect the need for the user to specify allowed lateness and accumulation mode before a user-inserted GroupByKey.

However, the current Flink translation of Reshuffle simply performs a DataStream rebalance, which is not the same as a key partition.

Fix

This PR updates the Reshuffle translation to perform a physical repartition based on the Hash Code of the key (assign record to partition hashcode % numPartitions).

A few things to note:

  • We are using the partitionCustom operator instead of keyBy for 2 reasons:
    1. The downstream of a Reshuffle expects a DataStream instead of a KeyedStream.
    2. keyBy is a logical partitioning, for reshuffle we need to physically repartition the data.
  • The current partitioning logic that determines which partition to write the event to is destPartition = hashcodeOfEvent % numPartitions, which could cause data skew depending on the hashing mechanism of the key. We might want to revisit the Partitioner implementation if this becomes a significant bottleneck.

Testing

./gradlew :runners:flink:1.18:validatesRunner

passes


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant