From b9b592ed0719eb5260fcfee156a323b406abfde0 Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Mon, 11 Oct 2021 14:22:37 -0600 Subject: [PATCH] kgo: change default MaxBufferedRecords from unlimited to 10,000 10k was the original limit. I'm not sure when this was bumped to unlimited, but it is problematic when producing to topics that do not exist. 10k is still a good limit. --- pkg/kgo/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/kgo/config.go b/pkg/kgo/config.go index 43244920..0490b605 100644 --- a/pkg/kgo/config.go +++ b/pkg/kgo/config.go @@ -451,7 +451,7 @@ func defaultCfg() cfg { acks: AllISRAcks(), compression: []CompressionCodec{SnappyCompression(), NoCompression()}, maxRecordBatchBytes: 1000000, // Kafka max.message.bytes default is 1000012 - maxBufferedRecords: math.MaxInt64, + maxBufferedRecords: 10000, produceTimeout: 30 * time.Second, recordRetries: math.MaxInt64, // effectively unbounded partitioner: StickyKeyPartitioner(nil), // default to how Kafka partitions @@ -859,7 +859,7 @@ func ProducerBatchMaxBytes(v int32) ProducerOpt { // MaxBufferedRecords sets the max amount of records the client will buffer, // blocking produces until records are finished if this limit is reached. -// This overrides the unbounded default. +// This overrides the default of 10,000. func MaxBufferedRecords(n int) ProducerOpt { return producerOpt{func(cfg *cfg) { cfg.maxBufferedRecords = int64(n) }} }