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

Enable MapState and SetState for dataflow streaming engine pipelines with legacy runner by building on top of MultimapState. #31453

Merged
merged 6 commits into from
Jul 4, 2024

Conversation

scwhittle
Copy link
Contributor

@scwhittle scwhittle commented May 30, 2024

Tests were not enabled for MapState/SetState for appliance on legacy runner. Enabling tests shows that MapState wasn't conforming to the spec that a read iterator is unaffected by subsequent writes, so this was fixed. Additional tests for the new map state built on MultimapState, exposed that MultimapState had a bug with remove/put/remove/put sequence which was fixed.

Related to issue #18200


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 or the workflows README to see a list of phrases to trigger workflows.

Copy link
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@scwhittle scwhittle force-pushed the layered_map_set_state branch 6 times, most recently from 91f0765 to 310042b Compare June 27, 2024 13:31
@scwhittle
Copy link
Contributor Author

R: @acrites

Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

Copy link
Contributor

@acrites acrites left a comment

Choose a reason for hiding this comment

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

Just a couple small things I noticed.

@Override
void initializeForWorkItem(
WindmillStateReader reader, Supplier<Closeable> scopedReadStateSupplier) {
super.cleanupAfterWorkItem();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be initializeForWorkItem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

doh, fixed.

@Override
public T read() {
Iterator<T> iterator = wrapped.read().iterator();
if (iterator.hasNext()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If `!hasNext()'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like the tests could use some improvement. I updated the validates runner test to cover a little more but I will also going to add unit tests to WindmillStateInternalsTest. I'll let you know when it's ready for another look.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some unit tests

@scwhittle scwhittle force-pushed the layered_map_set_state branch 5 times, most recently from 24e1905 to b002791 Compare July 1, 2024 19:03
@scwhittle scwhittle requested a review from acrites July 1, 2024 19:04
@@ -763,6 +786,28 @@ public void testMultimapPutAndGet() {
assertThat(result.read(), Matchers.containsInAnyOrder(1, 1, 2, 3));
}

@Test
public void testMapViaMultimapPutAndGet() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Some other edge cases that might be worth testing (unless I missed them somewhere):

  • Overwriting a key with a new value and then reading returns the new value.
  • Reading a key that hasn't been "put" returns correct value.
  • Put then Remove then Read returns empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added more tests and it exposed bug in multimapstate (improved multimap state test to expose it directly). During sequence of remove/put/remove/put multimapstate would remove the local knowledge of the remove.

waitAndSet(keysFuture, Arrays.asList(multimapEntry(key1), multimapEntry(key2)), 30);

mapState.put(key1, 7);
mapState.put(dup(key3), 8);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious: why do we sometimes need to call this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it just copies the key to ensure that it is compared based upon value instead of shallow compararison

mapState.put(key1, 7);
mapState.put(dup(key3), 8);
mapState.put(key4, 1);
mapState.remove(key4);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would also be interesting to test the case where key5 is returned by the backend read, but we've already called mapState.remove(key5) to make sure it's properly filtered out. I think this is basically the contents of testMultimapEntriesAndKeysMergeLocalRemove below, but not for MapViaMultimap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@acrites acrites left a comment

Choose a reason for hiding this comment

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

Some more small comments about tests.

Copy link
Contributor

@acrites acrites left a comment

Choose a reason for hiding this comment

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

Nice!

@svetakvsundhar svetakvsundhar self-requested a review July 3, 2024 14:49
CHANGES.md Outdated Show resolved Hide resolved
@scwhittle
Copy link
Contributor Author

Run Java PreCommit

@scwhittle scwhittle merged commit c08afea into apache:master Jul 4, 2024
33 checks passed
@scwhittle scwhittle deleted the layered_map_set_state branch July 4, 2024 20:22
acrites pushed a commit to acrites/beam that referenced this pull request Jul 17, 2024
…with legacy runner by building on top of MultimapState. (apache#31453)
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