fix(kafka/sarama_broker): drain async producer Successes/Errors channels (#72)#120
Merged
Conversation
) The async Sarama producer was configured with Return.Successes=true and Return.Errors=true but no goroutine drained those channels, so they filled up and the producer blocked indefinitely. Two drainer goroutines now consume both channels for the producer's lifetime. Errors are logged and counted via the existing arcade_kafka_produce_errors_total metric. Closes F-014.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Successes()andErrors()channels inkafka/sarama_broker.go. Without them, the channels (capacity =ChannelBufferSize, default 256) filled and the producer blocked onInput()for the rest of the process lifetime.arcade_kafka_produce_errors_total{topic}metric — no new metric was needed.Close()now waits on async.WaitGroupso drainer goroutines exit cleanly before the broker reports closed.NewSaramaBroker(brokers, consumerGroup)signature unchanged. Added a siblingNewSaramaBrokerWithLoggerfor callers that want to inject a logger; the no-arg constructor falls back tozap.NewNop().kafka/sarama_broker_test.gocovering: success-channel drain (1024 messages, would deadlock without the fix), error-channel drain (512 failing messages), and Close() waiting on drainers.Closes #72
Test plan
go build ./...go vet ./...go test ./kafka/... -racegolangci-lint run ./kafka/...(0 issues)go test ./... -racepassesarcade_kafka_produce_errors_total) is acceptable rather than a separate..._async_produce_errors_total