segmentio / kafka-go

Kafka library in Go
MIT License
7.64k stars 792 forks source link

Reader.Close hangs for ReaderConfig.MaxWait #428

Open feldgendler opened 4 years ago

feldgendler commented 4 years ago

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.

Antonboom commented 3 years ago

+1

SuddenGunter commented 1 year ago

had the same issue any fix for it?

rhasanoff commented 10 months ago

Having the same issue +1

Gewinum commented 3 weeks ago

i've got the same issue