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

Samza runner support for non unique stateId across multiple ParDos #24276

Merged
merged 5 commits into from
Dec 7, 2022

Conversation

seungjin-an
Copy link
Contributor

@seungjin-an seungjin-an commented Nov 19, 2022

Samza runner support for non-unique stateIds across multiple ParDos
(1) Do not touch existing RocksDB Store Id with stateId used only by one ParDo
(2) Add a prescan logic in SamzaRunner to traverse Beam pipeline topologically and identify non-unique stateIds.
(3) Using the set of non-unique stateIds, introduce a new mapping of user-provided stateIds to store ID

// stateId used in a single ParDo continue to use the same stateId as storeId
.apply("First stateful ParDo", ParDo.of(fn));
→ “foo"

// stateId used in multiple ParDos use a new mapping to store Id with PTransform name
.apply("Second stateful ParDo", ParDo.of(fn2));
→ “foo-Second_stateful_ParDo”

(4) Re-enable ParDoTest in :runners:samza build.gradle


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

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • 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.

Copy link
Member

@dxichen dxichen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style/readability comments, thanks for the diff!

Copy link
Contributor

@xinyuiscool xinyuiscool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two main issues:

  1. no rewriting of configs, instead, do a prescan of pipeline and build the non-unique state id set
  2. the changes in the SamzaStateInternals are not needed if you make the stores map still follow the same definition of {stateId -> store}. The state internals is generated per PTransform so it will not have dups here.

…or Samza Runner

- Add unit tests

- Re-enable ParDoTest with the support on same staste id across DoFns
@seungjin-an seungjin-an force-pushed the same-stateid-samza-runner branch from b4f6ba2 to 95540c1 Compare December 2, 2022 08:56
* Perform prescan of a pipeline to identify non-unique state ids
@seungjin-an seungjin-an force-pushed the same-stateid-samza-runner branch from c1cda56 to 76e8fe6 Compare December 2, 2022 09:17
@seungjin-an
Copy link
Contributor Author

Two main issues:

  1. no rewriting of configs, instead, do a prescan of pipeline and build the non-unique state id set
  2. the changes in the SamzaStateInternals are not needed if you make the stores map still follow the same definition of {stateId -> store}. The state internals is generated per PTransform so it will not have dups here.

Thank you so much for taking the time reviewing, providing suggestions on the pre-scan/ better naming, and fixing my understanding in SamzaStoreInternals. I have addressed all the comments and please have another look.

@seungjin-an seungjin-an marked this pull request as draft December 2, 2022 18:39
@xinyuiscool
Copy link
Contributor

Thanks for fixing the problem for #1 in my previous comments. However, seems some of the necessary changes are also reverted for #2. I expect passing a mapping {stateId -> storeId} (currently it's a set of stateId) to the SamzaStoreStateInternals.createStateInternalsFactory(). Then createStateInternalsFactory() can use that information to create the stores map. Somehow this logic is missing. It was present in your previous code. Please take a look and run ./gradlew :runners:samza:build to verify the tests pass.

@seungjin-an seungjin-an marked this pull request as ready for review December 2, 2022 21:31
@seungjin-an seungjin-an changed the title Samza runner support for same stateId with multiple ParDos Samza runner support for non unique stateId across multiple ParDos Dec 5, 2022
@seungjin-an
Copy link
Contributor Author

Thank you @xinyuiscool for the review again. SamzaStoreStateInternals logic has been included and verified the changes with all the tests passing from ./gradlew :runners:samza:build

Copy link
Contributor

@xinyuiscool xinyuiscool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great! Have some minor comments about consolidating some duplicate logic into a single class.

…ndMultiTranslator within ConfigContext/TranslationContext
@seungjin-an
Copy link
Contributor Author

Overall looks great! Have some minor comments about consolidating some duplicate logic into a single class.

@xinyuiscool Awesome, I've addressed all the comments above. Please review upon your availability! Thank you.

Copy link
Contributor

@xinyuiscool xinyuiscool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@xinyuiscool
Copy link
Contributor

Run Java PreCommit

@xinyuiscool xinyuiscool merged commit 11ed0e1 into apache:master Dec 7, 2022
dxichen pushed a commit to linkedin/beam that referenced this pull request Dec 8, 2022
* Samza runner support for non unique stateId across multiple ParDos (apache#24276)

* Update version
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.

3 participants