Skip to content

KAFKA-8011: Fix for race condition causing ConcurrentModificationException#6338

Merged
bbejeck merged 1 commit intoapache:trunkfrom
bbejeck:KAFKA-8011_flaky_Regex_Source_Integration_test
Feb 28, 2019
Merged

KAFKA-8011: Fix for race condition causing ConcurrentModificationException#6338
bbejeck merged 1 commit intoapache:trunkfrom
bbejeck:KAFKA-8011_flaky_Regex_Source_Integration_test

Conversation

@bbejeck
Copy link
Copy Markdown
Member

@bbejeck bbejeck commented Feb 27, 2019

In the RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenCreated() and RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenDeleted() a race condition exists where the ConsumerRebalanceListener in the test modifies the list of subscribed topics when the condition for the test success is comparing the same array instance against expected values.

This PR should fix this race condition by using a CopyOnWriteArrayList which guarantees safe traversal of the list even when a concurrent modification is happening.

Using the CopyOnWriteArrayList should not impact performance negatively as the number of traversals, a result of using ArrayList.equals(), far outnumber (TestUtils.waitForCondition() checks for a successful result every100ms) the possible modifications as there will be at most one topic name added/removed during the test.

For testing, I updated the RegexSourceIntegrationTestintegration test and ran the suite of streams tests.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@bbejeck
Copy link
Copy Markdown
Member Author

bbejeck commented Feb 27, 2019

\cc @vvcephei @ableegoldman for reviews

Copy link
Copy Markdown
Contributor

@guozhangwang guozhangwang left a comment

Choose a reason for hiding this comment

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

Thanks @bbejeck ! LGTM.

@guozhangwang
Copy link
Copy Markdown
Contributor

@bbejeck please feel free to cherry-pick to older branches as well.

@bbejeck bbejeck merged commit 45adc80 into apache:trunk Feb 28, 2019
@bbejeck
Copy link
Copy Markdown
Member Author

bbejeck commented Feb 28, 2019

Merged #6338 to trunk

@bbejeck bbejeck deleted the KAFKA-8011_flaky_Regex_Source_Integration_test branch February 28, 2019 23:54
bbejeck added a commit that referenced this pull request Feb 28, 2019
…ception (#6338)

In the RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenCreated() and RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenDeleted() a race condition exists where the ConsumerRebalanceListener in the test modifies the list of subscribed topics when the condition for the test success is comparing the same array instance against expected values.

This PR should fix this race condition by using a CopyOnWriteArrayList which guarantees safe traversal of the list even when a concurrent modification is happening.

Reviewers: Guozhang Wang <wangguoz@gmail.com>
bbejeck added a commit that referenced this pull request Feb 28, 2019
…ception (#6338)

In the RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenCreated() and RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenDeleted() a race condition exists where the ConsumerRebalanceListener in the test modifies the list of subscribed topics when the condition for the test success is comparing the same array instance against expected values.

This PR should fix this race condition by using a CopyOnWriteArrayList which guarantees safe traversal of the list even when a concurrent modification is happening.

Reviewers: Guozhang Wang <wangguoz@gmail.com>
bbejeck added a commit that referenced this pull request Mar 1, 2019
…ception (#6338)

In the RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenCreated() and RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenDeleted() a race condition exists where the ConsumerRebalanceListener in the test modifies the list of subscribed topics when the condition for the test success is comparing the same array instance against expected values.

This PR should fix this race condition by using a CopyOnWriteArrayList which guarantees safe traversal of the list even when a concurrent modification is happening.

Reviewers: Guozhang Wang <wangguoz@gmail.com>
@bbejeck
Copy link
Copy Markdown
Member Author

bbejeck commented Mar 1, 2019

cherry-picked to 2.2, 2.1, 2.0, 1.1, 1.0

jarekr pushed a commit to confluentinc/kafka that referenced this pull request Apr 18, 2019
* apache/trunk:
  KAFKA-7880:Naming worker thread by task id (apache#6275)
  improve some logging statements (apache#6078)
  KAFKA-7312: Change broker port used in testMinimumRequestTimeouts and testForceClose
  KAFKA-7997: Use automatic RPC generation in SaslAuthenticate
  KAFKA-8002; Log dir reassignment stalls if future replica has different segment base offset (apache#6346)
  KAFKA-3522: Add TimestampedKeyValueStore builder/runtime classes (apache#6152)
  HOTFIX: add igore import to streams_upgrade_test
  MINOR: ConsumerNetworkClient does not need to send the remaining requests when the node is not ready (apache#6264)
  KAFKA-7922: Return authorized operations in describe consumer group responses (KIP-430 Part-1)
  KAFKA-7918: Inline generic parameters Pt. III: in-memory window store (apache#6328)
  KAFKA-8012; Ensure partitionStates have not been removed before truncating. (apache#6333)
  KAFKA-8011: Fix for race condition causing concurrent modification exception (apache#6338)
  KAFKA-7912: Support concurrent access in InMemoryKeyValueStore (apache#6336)
  MINOR: Skip quota check when replica is in sync (apache#6344)
  HOTFIX: Change header back to http instead of https to path license header test (apache#6347)
  MINOR: fix release.py script (apache#6317)
  MINOR: Remove types from caching stores (apache#6331)
  MINOR: Improve logging for alter log dirs (apache#6302)
  MINOR: state.cleanup.delay.ms default is 600,000 ms (10 minutes). (apache#6345)
  MINOR: disable Streams system test for broker upgrade/downgrade (apache#6341)
pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
…ception (apache#6338)

In the RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenCreated() and RegexSourceIntegrationTest#testRegexMatchesTopicsAWhenDeleted() a race condition exists where the ConsumerRebalanceListener in the test modifies the list of subscribed topics when the condition for the test success is comparing the same array instance against expected values.

This PR should fix this race condition by using a CopyOnWriteArrayList which guarantees safe traversal of the list even when a concurrent modification is happening.

Reviewers: Guozhang Wang <wangguoz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants