Skip to content

Commit

Permalink
Eat all keep alive messages
Browse files Browse the repository at this point in the history
When use etcd keepalive method, we must consume all messages
from the queen it retured.Otherwise, the queen would be full.
See more detail, visit the follow links:

etcd-io/etcd#9952
etcd-io/etcd#8168
https://github.com/coreos/etcd/blob/master/clientv3/concurrency/session.go#L63
https://www.cnxct.com/etcd-lease-keepalive-debug-note/
  • Loading branch information
luoyancn committed Aug 11, 2018
1 parent 1c0ddb7 commit fe95542
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion registry/etcdv3/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,27 @@ func Register(ndata string) error {
// we must use context without timeout. Otherwise, the
// grpclient cannot receive any response from grpcserver after
// timeout.
if _, err = client.KeepAlive(context.TODO(), resp.ID); err != nil {
keep, err := client.KeepAlive(context.TODO(), resp.ID)
if nil != err {
logging.LOG.Errorf(
"Failed refresh the key %s exsit in etcd:%v\n",
key, err)
return err
}

// Eat all keep alive messages
// Otherwise, lease keepalive response queue will full,
// and etcd would dropping response send
// For more detail, visit the follow links:
// https://github.com/coreos/etcd/pull/9952
// https://github.com/coreos/etcd/issues/8168
// https://github.com/coreos/etcd/blob/master/clientv3/concurrency/session.go#L63
// https://www.cnxct.com/etcd-lease-keepalive-debug-note/

go func() {
for range keep {
}
}()
return nil
}

Expand Down

0 comments on commit fe95542

Please sign in to comment.