etcdserver: clarify read index warnings

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
Gyuho Lee 2018-07-02 12:38:50 -07:00
parent be3e6f6ed5
commit 09843d5d90

View File

@ -725,8 +725,9 @@ func (s *EtcdServer) linearizableReadLoop() {
var rs raft.ReadState var rs raft.ReadState
for { for {
ctx := make([]byte, 8) ctxToSend := make([]byte, 8)
binary.BigEndian.PutUint64(ctx, s.reqIDGen.Next()) id1 := s.reqIDGen.Next()
binary.BigEndian.PutUint64(ctxToSend, id1)
select { select {
case <-s.readwaitc: case <-s.readwaitc:
@ -742,7 +743,7 @@ func (s *EtcdServer) linearizableReadLoop() {
s.readMu.Unlock() s.readMu.Unlock()
cctx, cancel := context.WithTimeout(context.Background(), s.Cfg.ReqTimeout()) 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() cancel()
if err == raft.ErrStopped { if err == raft.ErrStopped {
return return
@ -760,16 +761,22 @@ func (s *EtcdServer) linearizableReadLoop() {
for !timeout && !done { for !timeout && !done {
select { select {
case rs = <-s.r.readStateC: case rs = <-s.r.readStateC:
done = bytes.Equal(rs.RequestCtx, ctx) done = bytes.Equal(rs.RequestCtx, ctxToSend)
if !done { if !done {
// a previous request might time out. now we should ignore the response of it and // a previous request might time out. now we should ignore the response of it and
// continue waiting for the response of the current requests. // continue waiting for the response of the current requests.
plog.Warningf("ignored out-of-date read index response (want %v, got %v)", rs.RequestCtx, ctx) id2 := uint64(0)
if len(rs.RequestCtx) == 8 {
id2 = binary.BigEndian.Uint64(rs.RequestCtx)
}
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()): case <-time.After(s.Cfg.ReqTimeout()):
plog.Warningf("timed out waiting for read index response") plog.Warningf("timed out waiting for read index response")
nr.notify(ErrTimeout) nr.notify(ErrTimeout)
timeout = true timeout = true
case <-s.stopping: case <-s.stopping:
return return
} }