Skip to content

Commit

Permalink
etcdserver: fix nil pointer panic for readonly txn
Browse files Browse the repository at this point in the history
FYI. #14891 (comment)

Signed-off-by: Benjamin Wang <wachao@vmware.com>
  • Loading branch information
ahrtr committed Dec 5, 2022
1 parent 5baf837 commit 48d6322
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/etcdserver/txn/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ func WarnOfExpensiveReadOnlyTxnRequest(lg *zap.Logger, warningApplyDuration time
for _, r := range txnResponse.Responses {
switch op := r.Response.(type) {
case *pb.ResponseOp_ResponseRange:
resps = append(resps, fmt.Sprintf("range_response_count:%d", len(op.ResponseRange.Kvs)))
if op.ResponseRange != nil {
resps = append(resps, fmt.Sprintf("range_response_count:%d", len(op.ResponseRange.Kvs)))
} else {
resps = append(resps, "range_response:nil_response")
}
default:
// only range responses should be in a read only txn request
}
Expand Down

0 comments on commit 48d6322

Please sign in to comment.