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 trigger: read kafka producer's error channel #1656

Closed
csimplestring opened this issue Feb 22, 2022 · 0 comments
Closed

Kafka trigger: read kafka producer's error channel #1656

csimplestring opened this issue Feb 22, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@csimplestring
Copy link
Contributor

csimplestring commented Feb 22, 2022

Is your feature request related to a problem? Please describe.
When the kafka cluster brokers are restarted, I notice that the kafka-sensor fails to produce the messages. And no kafka-related error messages printed in log. I have to manually restart the sensor pod, then it works again.

argo-event version: 1.3.1

Describe the solution you'd like

According to the comment of sarama's AsyncProducer:

// Errors is the error output channel back to the user. You MUST read from this
// channel or the Producer will deadlock when the channel is full. Alternatively,
// you can set Producer.Return.Errors in your config to false, which prevents
// errors to be returned.

However, there is no such option to specify the Producer.Return.Errors to be False in kafka-trigger yaml template.

After checking the source code of kafka trigger , I found that the producer's error channel is not read.

Therefore I believe the most straightforward way to fix is by reading error channel, for example

// inside NewKafkaTrigger function, add below code

go func() {
	
	for err := range producer.Errors() {
		log.Println(err)
	}
}()

Describe alternatives you've considered

Additional context
The root cause is potentially related to
IBM/sarama#2133
IBM/sarama#1430
Ideally kafka async producer should refresh metadata and re-connect to brokers automatically, but seems that is not completely fixed by Shopify.


Message from the maintainers:

If you wish to see this enhancement implemented please add a 👍 reaction to this issue! We often sort issues this way to know what to prioritize.

@csimplestring csimplestring added the enhancement New feature or request label Feb 22, 2022
@csimplestring csimplestring changed the title Restart kafka sensor and log kafka error message Kafka trigger: read kafka producer's error channel Feb 22, 2022
whynowy pushed a commit that referenced this issue Feb 27, 2022
* fix:read kafka error channel

Signed-off-by: Yi Wang <yi.wang@rtl.nl>

* fix: change comment

Signed-off-by: Yi Wang <yi.wang@rtl.nl>

* fix: only init error channel reading goroutine once

Signed-off-by: Yi Wang <yi.wang@rtl.nl>

* fix: format code

Signed-off-by: Yi Wang <yi.wang@rtl.nl>
whynowy pushed a commit that referenced this issue Feb 27, 2022
* fix:read kafka error channel

Signed-off-by: Yi Wang <yi.wang@rtl.nl>

* fix: change comment

Signed-off-by: Yi Wang <yi.wang@rtl.nl>

* fix: only init error channel reading goroutine once

Signed-off-by: Yi Wang <yi.wang@rtl.nl>

* fix: format code

Signed-off-by: Yi Wang <yi.wang@rtl.nl>
BulkBeing pushed a commit to BulkBeing/argo-events that referenced this issue Mar 7, 2022
* fix:read kafka error channel

Signed-off-by: Yi Wang <yi.wang@rtl.nl>

* fix: change comment

Signed-off-by: Yi Wang <yi.wang@rtl.nl>

* fix: only init error channel reading goroutine once

Signed-off-by: Yi Wang <yi.wang@rtl.nl>

* fix: format code

Signed-off-by: Yi Wang <yi.wang@rtl.nl>
juliev0 pushed a commit to juliev0/argo-events that referenced this issue Mar 29, 2022
* fix:read kafka error channel

Signed-off-by: Yi Wang <yi.wang@rtl.nl>

* fix: change comment

Signed-off-by: Yi Wang <yi.wang@rtl.nl>

* fix: only init error channel reading goroutine once

Signed-off-by: Yi Wang <yi.wang@rtl.nl>

* fix: format code

Signed-off-by: Yi Wang <yi.wang@rtl.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant