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

Switch to use ConcurrentMap for StringSetData #33057

Merged
merged 2 commits into from
Nov 12, 2024
Merged

Conversation

Abacn
Copy link
Contributor

@Abacn Abacn commented Nov 8, 2024

Fix #33054

Please add a meaningful description for your change here


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.

@Abacn
Copy link
Contributor Author

Abacn commented Nov 8, 2024

tested that the test before this change reliably fails with

java.util.ConcurrentModificationException
	at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1511)
	at java.base/java.util.HashMap$KeyIterator.next(HashMap.java:1534)
	at java.base/java.util.AbstractCollection.toArray(AbstractCollection.java:144)
	at java.base/java.util.ArrayList.<init>(ArrayList.java:179)
	at org.apache.beam.runners.core.metrics.StringSetCellTest.testStringSetCellConcurrentAddRetrivial(StringSetCellTest.java:124)

@Abacn
Copy link
Contributor Author

Abacn commented Nov 8, 2024

tested on a pipeline continuously writing Lineage

before (Dataflow job id: 2024-11-08_11_36_49-8094892231622614854):

image

after (Dataflow job id: 2024-11-08_11_44_52-6414777021729411991):

image

no "Unexpected exception while trying to send counter updates" error log

Copy link
Contributor

github-actions bot commented Nov 8, 2024

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @lostluck added as fallback since no labels match configuration

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Copy link
Contributor

@jonathan-lemos jonathan-lemos left a comment

Choose a reason for hiding this comment

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

Rest of this LGTM.

for (long i = 0; !finished.get(); ++i) {
cell.add(String.valueOf(i));
try {
Thread.sleep(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

1s sleep in a 3s test doesn't give much room to find races.

Does this test fail without your changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here it is 1 ms sleep. it does - #33057 (comment).

Copy link
Contributor

Choose a reason for hiding this comment

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

My mistake. I was thinking Python where it's in seconds and not ms.

while (true) {
Set<String> s = cell.getCumulative().stringSet();
List<String> snapshot = new ArrayList<>(s);
if (Instant.now().isAfter(start.plusSeconds(3)) && snapshot.size() > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should assert that the contents of the snapshot are not corrupt.

Maybe we keep track of the highest integer reached by the thread, and assert that at the end, the snapshot contains all of [0, N].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, added assert.

@Abacn
Copy link
Contributor Author

Abacn commented Nov 12, 2024

GCP IO PreCommit failing SpannerChangeStream test testInvalidRecordReceived not related

@Abacn Abacn merged commit 2604943 into apache:master Nov 12, 2024
18 of 19 checks passed
@Abacn Abacn deleted the concurrent branch November 12, 2024 19:28
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.

[Bug]: Mutable stringset race condition
2 participants