Skip to content

ServerWatchStream can't be closed when client closed watcher #20484

@chaofengliu-okg

Description

@chaofengliu-okg

Bug report criteria

What happened?

ServerWatchStream can't be closed when client closed watcher

What did you expect to happen?

when client closed watcher ServerWatchStream should be closed

How can we reproduce it (as minimally and precisely as possible)?

using jetcd write the follow code and run
while(1) {
Watch.Watcher watcher = etcdClient.getWatchClient().watch(....);
TimeUnit.SECONDS.sleep(5);
watcher.close();
}

Anything else we need to know?

func (ws *watchServer) Watch(stream pb.Watch_WatchServer) (err error) {
in this function, sws.recvLoop() return nil when recv EOF,so the line errc <- rerr will never be executed.
go the below select will never be executed. this lead to serverWatchStream leak.

Etcd version (please run commands below)

$ etcd --version
# 3.5.17

$ etcdctl version
# 3.5.17

Etcd configuration (command line flags or environment variables)

paste your configuration here

Etcd debug information (please run commands below, feel free to obfuscate the IP address or FQDN in the output)

$ etcdctl member list -w table
# paste output here

$ etcdctl --endpoints=<member list> endpoint status -w table
# paste output here

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions