IBM / sarama

Sarama is a Go library for Apache Kafka.
MIT License
11.57k stars 1.76k forks source link

consumer_group newSession() infinite loop #2640

Closed nbajaj90 closed 1 year ago

nbajaj90 commented 1 year ago

https://github.com/IBM/sarama/blob/9e759865b0d47cd5598befc103c0c40b45784d3c/consumer_group.go#L311 If the error is ErrUnknownMemberId and context gets cancelled by some other go-routine, the above code can go in an infinite loop.

Need a check to cross-check if context is cancelled before below switch: https://github.com/IBM/sarama/blob/9e759865b0d47cd5598befc103c0c40b45784d3c/consumer_group.go#L305

Example code required: select { case <-ctx.Done(): return nil, ctx.Err() default: }

dnwe commented 1 year ago

Thanks, this is a general bug that the newSession and retryNewSession funcs should both be checking for ctx cancellation to exit early before proceeding