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_producer: fix deadlock when an error occurs in asyncClient #3003

Merged
merged 3 commits into from
Oct 12, 2021

Conversation

liuzix
Copy link
Contributor

@liuzix liuzix commented Oct 9, 2021

What problem does this PR solve?

What is changed and how it works?

  • Made k.asyncClient.Input() <- msg cancellable in SendMessage
  • Changed the use of clientLock, so that checking whether the producer is closing will no longer be blocked by other goroutines.

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch

Release note

Fix possible deadlocking when Kafka producer reports an error.

@liuzix liuzix added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 9, 2021
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Oct 9, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • amyangfei
  • asddongmen

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Oct 9, 2021
@liuzix
Copy link
Contributor Author

liuzix commented Oct 9, 2021

/run-kafka-tests

@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 9, 2021
@liuzix liuzix force-pushed the zixiong-fix-kafka-producer-deadlock branch from d580f78 to e7ed165 Compare October 9, 2021 10:09
@liuzix
Copy link
Contributor Author

liuzix commented Oct 9, 2021

/run-kafka-tests

1 similar comment
@liuzix
Copy link
Contributor Author

liuzix commented Oct 9, 2021

/run-kafka-tests

@liuzix
Copy link
Contributor Author

liuzix commented Oct 9, 2021

/run-leak-tests

@liuzix liuzix added type/bugfix This PR fixes a bug. component/sink Sink component. priority/P1 The issue has P1 priority. needs-cherry-pick-release-4.0 Should cherry pick this PR to release-4.0 branch. needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. needs-cherry-pick-release-5.1 Should cherry pick this PR to release-5.1 branch. needs-cherry-pick-release-5.2 Should cherry pick this PR to release-5.2 branch. labels Oct 9, 2021
@liuzix
Copy link
Contributor Author

liuzix commented Oct 9, 2021

/run-kafka-tests

1 similar comment
@liuzix
Copy link
Contributor Author

liuzix commented Oct 9, 2021

/run-kafka-tests

@asddongmen asddongmen self-requested a review October 9, 2021 12:07
@liuzix liuzix added the status/ptal Could you please take a look? label Oct 9, 2021
@amyangfei amyangfei added this to the v5.3.0 milestone Oct 10, 2021
@@ -116,8 +133,7 @@ func (k *kafkaSaramaProducer) SendMessage(ctx context.Context, message *codec.MQ
return ctx.Err()
case <-k.closeCh:
return nil
default:
k.asyncClient.Input() <- msg
case k.asyncClient.Input() <- msg:
Copy link
Contributor

Choose a reason for hiding this comment

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

SyncBroadcastMessage has a similar default branch, please check whether we need to update in SyncBroadcastMessage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SyncBroadcastMessage has a different problem. I would like to fix it in a separate PR, what do you think?

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 12, 2021
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Oct 12, 2021
@amyangfei
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 17378b5

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Oct 12, 2021
@ti-chi-bot
Copy link
Member

@liuzix: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@liuzix
Copy link
Contributor Author

liuzix commented Oct 12, 2021

/run-integration-tests

@amyangfei
Copy link
Contributor

/run-kafka-tests

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #3015.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #3016.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #3017.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #3018.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/sink Sink component. needs-cherry-pick-release-4.0 Should cherry pick this PR to release-4.0 branch. needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. needs-cherry-pick-release-5.1 Should cherry pick this PR to release-5.1 branch. needs-cherry-pick-release-5.2 Should cherry pick this PR to release-5.2 branch. priority/P1 The issue has P1 priority. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. status/ptal Could you please take a look? type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants