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

hotfix : handle nil reply #41

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion cmd/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ func (sc *SyncerCmd) runSingle(runWait usync.WaitCloser, cfgs []syncer.SyncerCon
sc.logger.Infof("start syncer : %v", cfg)
err := sy.RunLeader()
runWait.Close(err)
}, nil)
}, func(i interface{}) {
runWait.Close(fmt.Errorf("panic : %v", i))
})

usync.SafeGo(func() {
<-runWait.Done()
Expand Down
3 changes: 3 additions & 0 deletions pkg/redis/client/cluster/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ func (bat *Batch) doBatch(batch *nodeBatch) {
for i := range batch.cmds {
reply, err := conn.receive()
if err != nil {
if err == common.ErrNil {
continue
}
batch.err = err
conn.shutdown()
batch.done <- 1
Expand Down
3 changes: 0 additions & 3 deletions pkg/redis/client/cluster/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,6 @@ func (conn *redisConn) readReply() (interface{}, error) {
return string(line[1:]), nil
}
case '-':
if common.IsNilReply(line) {
return nil, common.ErrNil
}
return common.RedisError(string(line[1:])), nil
case ':':
return parseInt(line[1:])
Expand Down
4 changes: 4 additions & 0 deletions pkg/redis/client/conn/redis_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ func (tb *batcher) Exec() ([]interface{}, error) {
for i := 0; i < receiveSize; i++ {
rpl, err := tb.conn.receive()
if err != nil {
if err == common.ErrNil {
replies = append(replies, nil)
continue
}
tb.conn.Close()
return nil, err
}
Expand Down
9 changes: 1 addition & 8 deletions pkg/redis/client/proto/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (r *Reader) ReadLine() ([]byte, error) {
}

// Compatible with RESP2
if IsNilReply(line) {
if common.IsNilReply(line) {
return nil, common.ErrNil
}

Expand Down Expand Up @@ -551,10 +551,3 @@ func replyLen(line []byte) (n int, err error) {
}
return n, nil
}

// IsNilReply detects redis.Nil of RESP2.
func IsNilReply(line []byte) bool {
return len(line) == 3 &&
(line[0] == RespString || line[0] == RespArray) &&
line[1] == '-' && line[2] == '1'
}
Loading