Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read keepAlive to avoid useless warning: 'lease keepalive response qu… #115

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions database/kv/etcd/v3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ import (
"strings"
"sync"
"time"
)

import (
perrors "github.com/pkg/errors"

"go.etcd.io/etcd/client/v3"
clientv3 "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/client/v3/concurrency"

"google.golang.org/grpc"
)

Expand Down Expand Up @@ -420,10 +417,30 @@ func (c *Client) keepAliveKV(k string, v string) error {
return perrors.New("keep alive lease")
}

// listen keepAlive to avoid useless warning:
// 'lease keepalive response queue is full; dropping response send'
go c.listenKeepAliveRsp(k, keepAlive)

_, err = rawClient.Put(c.ctx, k, v, clientv3.WithLease(lease.ID))
return perrors.WithMessage(err, "put k/v with lease")
}

// listenKeepAliveRsp listens to `keepAliveRspCh` channel.
func (c *Client) listenKeepAliveRsp(k string, keepAliveRspCh <-chan *clientv3.LeaseKeepAliveResponse) {
for {
select {
case <-c.ctx.Done():
log.Printf("listenKeepAliveRsp canceled: %v: %s", c.ctx.Err(), k)
AlexStocks marked this conversation as resolved.
Show resolved Hide resolved
return
case _, ok := <-keepAliveRspCh:
if !ok {
log.Printf("listenKeepAliveRsp canceled: unexpected lease expired: %s", k)
return
}
}
}
}

// Done return exit chan
func (c *Client) Done() <-chan struct{} {
return c.exit
Expand Down
Loading