Skip to content

Commit 4eba3e1

Browse files
committed
proxy: s.incrFails -> s.incrOpFails
1 parent 632f31d commit 4eba3e1

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

pkg/proxy/session.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (s *Session) Start(d *Router) {
117117
go func() {
118118
s.Conn.Encode(redis.NewErrorf("ERR max number of clients reached"), true)
119119
s.CloseWithError(ErrTooManySessions)
120-
s.incrFails()
120+
s.incrOpFails(nil, nil)
121121
s.flushOpStats(true)
122122
}()
123123
decrSessions()
@@ -128,7 +128,7 @@ func (s *Session) Start(d *Router) {
128128
go func() {
129129
s.Conn.Encode(redis.NewErrorf("ERR router is not online"), true)
130130
s.CloseWithError(ErrRouterNotOnline)
131-
s.incrFails()
131+
s.incrOpFails(nil, nil)
132132
s.flushOpStats(true)
133133
}()
134134
decrSessions()
@@ -167,8 +167,7 @@ func (s *Session) loopReader(tasks *RequestChan, d *Router) (err error) {
167167
s.incrOpTotal()
168168

169169
if tasks.Buffered() > maxPipelineLen {
170-
s.incrFails()
171-
return ErrTooManyPipelinedRequests
170+
return s.incrOpFails(nil, ErrTooManyPipelinedRequests)
172171
}
173172

174173
start := time.Now()
@@ -635,10 +634,6 @@ func (s *Session) incrOpTotal() {
635634
s.stats.total.Incr()
636635
}
637636

638-
func (s *Session) incrFails() {
639-
s.stats.fails.Incr()
640-
}
641-
642637
func (s *Session) getOpStats(opstr string) *opStats {
643638
e := s.stats.opmap[opstr]
644639
if e == nil {
@@ -659,8 +654,12 @@ func (s *Session) incrOpStats(r *Request, t redis.RespType) {
659654
}
660655

661656
func (s *Session) incrOpFails(r *Request, err error) error {
662-
e := s.getOpStats(r.OpStr)
663-
e.fails.Incr()
657+
if r != nil {
658+
e := s.getOpStats(r.OpStr)
659+
e.fails.Incr()
660+
} else {
661+
s.stats.fails.Incr()
662+
}
664663
return err
665664
}
666665

0 commit comments

Comments
 (0)