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

KAFKA-7284: streams should unwrap fenced exception #5520

Merged
merged 5 commits into from Aug 21, 2018
Merged

KAFKA-7284: streams should unwrap fenced exception #5520

merged 5 commits into from Aug 21, 2018

Conversation

vvcephei
Copy link
Contributor

Unwrap the ProducerFencedException in RecordCollectorImpl
so it can be caught and converted to a TaskMigratedException
instead of triggering a shutdown.

See also #5499 and #5513

Committer Checklist (excluded from commit message)

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

@vvcephei
Copy link
Contributor Author

@mjsax @guozhangwang , Here's the 1.0 implementation.

The RecordCollectorImpl is significantly different from the later branches. I tried to preserve the existing logic, but it might we worth a close look.

Thanks,
-John

@mjsax mjsax added the streams label Aug 16, 2018
@@ -205,7 +206,7 @@ public void abortTransaction() throws ProducerFencedException {
this.transactionInFlight = false;
}

private void verifyProducerState() {
private synchronized void verifyProducerState() {
Copy link
Member

Choose a reason for hiding this comment

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

why do we need to synchronized a private method?

I was just looking into trunk and it seems to be synchronized there, too. Also, some methods are synchronized others are not, but I could not see any pattern. Should we just synchronized all public method? Performance should not be a concern for MockProducer. On the other hand, when would a producer be used by multiple threads? Neither KafkaConsumer nor KafkaProducer are thread-safe by design. Why does MockProducer need to be thread-safe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added it in the prior PRs because findbugs complained that some, but not all, accesses of the "am I fenced" field are synchronized. I didn't bother verifying that it's necessary in the older branches, but I can check it out real quick.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why anything in here is synchronized; that's just the way I found it.

Copy link
Member

Choose a reason for hiding this comment

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

I see. Maybe ok for older branches to leave as is. But might be wroth to cleanup in trunk?

Copy link
Member

Choose a reason for hiding this comment

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

To be fair: fenceProducer() is not part of public producer API but added to MockProducer and it might be called from a different thread (ie, the main testing thread while StreamThread used the producer, too). Because all public methods within MockProducer call verifyState() it makes sense what findbugs complains about. Did miss this connection before. So maybe drop latest commit :)

Sorry for the forth and back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out the tests fail with the synchronization is removed. See https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/15966/findbugsResult/ while it's still available.

@vvcephei
Copy link
Contributor Author

I missed the failure messages.

Retest this, please.

@vvcephei
Copy link
Contributor Author

@mjsax The test failure was due to the missing synchronization, so I've added it back in.

Copy link
Member

@mjsax mjsax left a comment

Choose a reason for hiding this comment

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

LGTM. Will merge if Jenkins build succeeds.

@mjsax
Copy link
Member

mjsax commented Aug 21, 2018

Retest this please

1 similar comment
@mjsax
Copy link
Member

mjsax commented Aug 21, 2018

Retest this please

@vvcephei
Copy link
Contributor Author

Note that the java 10 build won't pass on 1.x due to the incompatible scala version.

@mjsax mjsax merged commit a9692ff into apache:1.0 Aug 21, 2018
@mjsax
Copy link
Member

mjsax commented Aug 21, 2018

Merged to 1.0 and cherry-picked to 0.11.0 branch.

mjsax pushed a commit that referenced this pull request Aug 21, 2018
Reviewers: Matthias J. Sax <matthias@confluent.io>
@vvcephei vvcephei deleted the KAFKA-7284-streams-fenced-exeption-1.0 branch August 21, 2018 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants