Skip to content

Commit

Permalink
store/tikv: fix log of sendTxnHeartBeat (#21017)
Browse files Browse the repository at this point in the history
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
  • Loading branch information
youjiali1995 authored Nov 13, 2020
1 parent a81c89f commit 8a4b52e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion store/tikv/2pc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package tikv
import (
"bytes"
"context"
"encoding/hex"
"math"
"strings"
"sync"
Expand Down Expand Up @@ -874,7 +875,7 @@ func sendTxnHeartBeat(bo *Backoffer, store *tikvStore, primary []byte, startTS,
}
cmdResp := resp.Resp.(*pb.TxnHeartBeatResponse)
if keyErr := cmdResp.GetError(); keyErr != nil {
return 0, errors.Errorf("txn %d heartbeat fail, primary key = %v, err = %s", startTS, primary, keyErr.Abort)
return 0, errors.Errorf("txn %d heartbeat fail, primary key = %v, err = %s", startTS, hex.EncodeToString(primary), extractKeyErr(keyErr))
}
return cmdResp.GetLockTtl(), nil
}
Expand Down
4 changes: 4 additions & 0 deletions store/tikv/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,10 @@ func extractKeyErr(keyErr *pb.KeyError) error {
logutil.BgLogger().Warn("2PC failed", zap.Error(err))
return errors.Trace(err)
}
if keyErr.TxnNotFound != nil {
err := errors.Errorf("txn %d not found", keyErr.TxnNotFound.StartTs)
return errors.Trace(err)
}
return errors.Errorf("unexpected KeyError: %s", keyErr.String())
}

Expand Down

0 comments on commit 8a4b52e

Please sign in to comment.