Merge pull request #14420 from vsvastey/usr/vsvastey/nil-logger

etcdserver: nil-logger issue fix for version 3.4
This commit is contained in:
Benjamin Wang 2022-09-05 14:53:08 +08:00 committed by GitHub
commit 9d5ae56764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -779,11 +779,15 @@ func (s *EtcdServer) requestCurrentIndex(leaderChangedNotifier <-chan struct{},
if len(rs.RequestCtx) == 8 {
responseId = binary.BigEndian.Uint64(rs.RequestCtx)
}
lg.Warn(
"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", requestId),
zap.Uint64("received-request-id", responseId),
)
if lg != nil {
lg.Warn(
"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", requestId),
zap.Uint64("received-request-id", responseId),
)
} else {
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)", requestId, responseId)
}
slowReadIndex.Inc()
continue
}
@ -794,7 +798,11 @@ func (s *EtcdServer) requestCurrentIndex(leaderChangedNotifier <-chan struct{},
return 0, ErrLeaderChanged
case <-firstCommitInTermNotifier:
firstCommitInTermNotifier = s.FirstCommitInTermNotify()
lg.Info("first commit in current term: resending ReadIndex request")
if lg != nil {
lg.Info("first commit in current term: resending ReadIndex request")
} else {
plog.Info("first commit in current term: resending ReadIndex request")
}
err := s.sendReadIndex(requestId)
if err != nil {
return 0, err
@ -802,11 +810,15 @@ func (s *EtcdServer) requestCurrentIndex(leaderChangedNotifier <-chan struct{},
retryTimer.Reset(readIndexRetryTime)
continue
case <-retryTimer.C:
lg.Warn(
"waiting for ReadIndex response took too long, retrying",
zap.Uint64("sent-request-id", requestId),
zap.Duration("retry-timeout", readIndexRetryTime),
)
if lg != nil {
lg.Warn(
"waiting for ReadIndex response took too long, retrying",
zap.Uint64("sent-request-id", requestId),
zap.Duration("retry-timeout", readIndexRetryTime),
)
} else {
plog.Warningf("waiting for ReadIndex response took too long, retrying (sent-request-id: %d, retry-timeout: %s)", requestId, readIndexRetryTime)
}
err := s.sendReadIndex(requestId)
if err != nil {
return 0, err
@ -814,10 +826,14 @@ func (s *EtcdServer) requestCurrentIndex(leaderChangedNotifier <-chan struct{},
retryTimer.Reset(readIndexRetryTime)
continue
case <-errorTimer.C:
lg.Warn(
"timed out waiting for read index response (local node might have slow network)",
zap.Duration("timeout", s.Cfg.ReqTimeout()),
)
if lg != nil {
lg.Warn(
"timed out waiting for read index response (local node might have slow network)",
zap.Duration("timeout", s.Cfg.ReqTimeout()),
)
} else {
plog.Warningf("timed out waiting for read index response (local node might have slow network) timeout: %s", s.Cfg.ReqTimeout())
}
slowReadIndex.Inc()
return 0, ErrTimeout
case <-s.stopping: