kafka-go icon indicating copy to clipboard operation
kafka-go copied to clipboard

topic partition not found

Open zty-f opened this issue 11 months ago • 0 comments

The kafka configuration has only 60 shards, but the partition that is pushed is not within this access。

Kafka Version v0.4.47

My kafka cluster creation code

func (c cluster) NewSyncWriterWithAckNoBatch(ctx context.Context, topic string, ackConfig int) queue.Writer {
	ack := kafka.RequireNone
	if ackConfig == int(kafka.RequireNone) || ackConfig == int(kafka.RequireOne) || ackConfig == int(kafka.RequireAll) {
		ack = kafka.RequiredAcks(ackConfig)
	}

	client := &kafka.Writer{
		Addr:                   kafka.TCP(c.Brokers...),
		Balancer:               &kafka.LeastBytes{},
		BatchSize:              1,
		AllowAutoTopicCreation: false, // 不允许自动创建topic, 应该从后台创建,方便统一管理
		Topic:                  topic, // 如果创建生产者的时候,topic为空,那么每个消息体里就必须指定topic
		Async:                  false,
		RequiredAcks:           ack,
	}

	if c.Sasl.Username != "" {
		client.Transport = &kafka.Transport{
			TLS:  c.tls,
			SASL: c.Sasl,
		}
	}
	if ctx == nil {
		ctx = context.Background()
	}
	return writer{ctx, client}
}

topic info image

write message error Kafka write errors (1/1), errors: [kafka.(*Client).Produce: fetch request error: topic partition not found (topic="mall_growth_center_7001000" partition=3191777)]

zty-f avatar Dec 26 '24 02:12 zty-f