Closed wangyanphp closed 1 year ago
Is this a theoretical problem, or something you've actually run into? How are you able to reproduce this? The only reason the Cancel on line 91 would ever be called is if for some reason the watch event cannot be sent to the client. If that fails, it is highly unlikely that the client would still be connected to see the the second cancel, which I suspect is why we never see this when kine is used as a Kubernetes datastore.
it's a theoretical problem. because kine could do it easily that send canceled response only once for watch id, but kine doesn't do it. So I'm curious if there's some details or design here that I didn't notice
I think that while it looks like it could happen just from reading through the code, in reality it does not because the client disconnects after receiving the first cancel. Feel free to reopen this if you find a way to actually reproduce an issue.
i noticed that will execute cancel function multiple times in
that will cause sending canceled watch response to etcd client multiple times:https://github.com/k3s-io/kine/blob/master/pkg/server/watch.go#L135![image](https://github.com/k3s-io/kine/assets/13374363/7bb6098b-30a8-4d97-80fa-165da903a33f)
when etcd client received multiple canceled response, it will panic because of close a closed channel https://github.com/etcd-io/etcd/blob/main/client/v3/watch.go#L637![image](https://github.com/k3s-io/kine/assets/13374363/5975026e-2565-404d-ba6f-4d1ea2a31846)
so my question is why kine doesn't send canceled response only once?