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

etcdserver: clarify read index warnings, add metrics #9897

Merged
merged 2 commits into from
Jul 3, 2018
Merged
Changes from 1 commit
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
Next Next commit
etcdserver: clarify read index warnings
Signed-off-by: Gyuho Lee <[email protected]>
  • Loading branch information
gyuho committed Jul 2, 2018
commit 4733a1db5c7138e4f17222437daad3e16a01ff8c
22 changes: 13 additions & 9 deletions etcdserver/v3_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 18,6 @@ import (
"bytes"
"context"
"encoding/binary"
"fmt"
"time"

"github.com/coreos/etcd/auth"
Expand Down Expand Up @@ -632,8 631,9 @@ func (s *EtcdServer) linearizableReadLoop() {
var rs raft.ReadState

for {
ctx := make([]byte, 8)
binary.BigEndian.PutUint64(ctx, s.reqIDGen.Next())
ctxToSend := make([]byte, 8)
id1 := s.reqIDGen.Next()
binary.BigEndian.PutUint64(ctxToSend, id1)

select {
case <-s.readwaitc:
Expand All @@ -650,7 650,7 @@ func (s *EtcdServer) linearizableReadLoop() {

lg := s.getLogger()
cctx, cancel := context.WithTimeout(context.Background(), s.Cfg.ReqTimeout())
if err := s.r.ReadIndex(cctx, ctx); err != nil {
if err := s.r.ReadIndex(cctx, ctxToSend); err != nil {
cancel()
if err == raft.ErrStopped {
return
Expand All @@ -672,18 672,22 @@ func (s *EtcdServer) linearizableReadLoop() {
for !timeout && !done {
select {
case rs = <-s.r.readStateC:
done = bytes.Equal(rs.RequestCtx, ctx)
done = bytes.Equal(rs.RequestCtx, ctxToSend)
if !done {
// a previous request might time out. now we should ignore the response of it and
// continue waiting for the response of the current requests.
id2 := uint64(0)
if len(rs.RequestCtx) == 8 {
id2 = binary.BigEndian.Uint64(rs.RequestCtx)
}
if lg != nil {
lg.Warn(
"ignored out-of-date read index response",
zap.String("ctx-expected", fmt.Sprintf("% v", string(rs.RequestCtx))),
zap.String("ctx-got", fmt.Sprintf("% v", string(ctx))),
"ignored out-of-date read index response; local node read indexes queueing up and waiting to be in sync with leader",
zap.Uint64("sent-request-id", id1),
zap.Uint64("received-request-id", id2),
)
} else {
plog.Warningf("ignored out-of-date read index response (want %v, got %v)", rs.RequestCtx, ctx)
plog.Warningf("ignored out-of-date read index response; local node read indexes queueing up and waiting to be in sync with leader (request ID want %d, got %d)", id1, id2)
}
}
case <-time.After(s.Cfg.ReqTimeout()):
Expand Down