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

Reader.Close hangs for ReaderConfig.MaxWait

Open feldgendler opened this issue 4 years ago • 3 comments

Describe the bug After reading once, Reader.Close hangs until the end of a MaxWait duration.

Kafka Version 2.3.0

To Reproduce

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/segmentio/kafka-go"
)

func main() {
	reader := kafka.NewReader(kafka.ReaderConfig{
		Brokers: []string{"localhost:9092"}, // assuming a running Kafka instance
		Topic:   "test", // does not need to exist
		MaxWait: time.Hour,
	})

	ctx, cancel := context.WithTimeout(context.Background(), time.Second)
	defer cancel()

	fmt.Println("Trying to read...")
	_, _ = reader.FetchMessage(ctx)

	fmt.Println("Closing reader...")
	reader.Close()

	fmt.Println("Test passed")
}

Expected behavior Reader.Close should close the connection and return immediately.

feldgendler avatar Apr 14 '20 14:04 feldgendler

+1

Antonboom avatar Feb 03 '21 15:02 Antonboom

had the same issue any fix for it?

SuddenGunter avatar May 30 '23 12:05 SuddenGunter

Having the same issue +1

rhasanoff avatar Jan 18 '24 08:01 rhasanoff