diff --git a/kv/raftstore/meta/keys.go b/kv/raftstore/meta/keys.go index 8d311adaf..62b619603 100644 --- a/kv/raftstore/meta/keys.go +++ b/kv/raftstore/meta/keys.go @@ -88,10 +88,10 @@ func IsRaftStateKey(key []byte) bool { func DecodeRegionMetaKey(key []byte) (uint64, byte, error) { if len(RegionMetaMinKey)+8+1 != len(key) { - return 0, 0, errors.Errorf("invalid region meta key length for key %v", key) + return 0, 0, errors.Errorf("invalid region meta key length for key %s", key) } if !bytes.HasPrefix(key, RegionMetaMinKey) { - return 0, 0, errors.Errorf("invalid region meta key prefix for key %v", key) + return 0, 0, errors.Errorf("invalid region meta key prefix for key %s", key) } regionID := binary.BigEndian.Uint64(key[len(RegionMetaMinKey):]) return regionID, key[len(key)-1], nil @@ -117,7 +117,7 @@ func RegionStateKey(regionID uint64) []byte { /// RaftLogIndex gets the log index from raft log key generated by `raft_log_key`. func RaftLogIndex(key []byte) (uint64, error) { if len(key) != RegionRaftLogLen { - return 0, errors.Errorf("key %v is not a valid raft log key", key) + return 0, errors.Errorf("key %s is not a valid raft log key", key) } return binary.BigEndian.Uint64(key[RegionRaftLogLen-8:]), nil } diff --git a/kv/raftstore/runner/region_task.go b/kv/raftstore/runner/region_task.go index 8b7e5fb64..950514a78 100644 --- a/kv/raftstore/runner/region_task.go +++ b/kv/raftstore/runner/region_task.go @@ -1,7 +1,6 @@ package runner import ( - "encoding/hex" "fmt" "time" @@ -132,10 +131,10 @@ func (snapCtx *snapContext) handleApply(regionId uint64, notifier chan<- bool, s func (snapCtx *snapContext) cleanUpRange(regionId uint64, startKey, endKey []byte) { if err := engine_util.DeleteRange(snapCtx.engines.Kv, startKey, endKey); err != nil { log.Fatalf("failed to delete data in range, [regionId: %d, startKey: %s, endKey: %s, err: %v]", regionId, - hex.EncodeToString(startKey), hex.EncodeToString(endKey), err) + startKey, endKey, err) } else { log.Infof("succeed in deleting data in range. [regionId: %d, startKey: %s, endKey: %s]", regionId, - hex.EncodeToString(startKey), hex.EncodeToString(endKey)) + startKey, endKey) } } diff --git a/kv/raftstore/runner/split_checker.go b/kv/raftstore/runner/split_checker.go index 72a2ed369..f023b316a 100644 --- a/kv/raftstore/runner/split_checker.go +++ b/kv/raftstore/runner/split_checker.go @@ -1,8 +1,6 @@ package runner import ( - "encoding/hex" - "github.com/Connor1996/badger" "github.com/pingcap-incubator/tinykv/kv/config" "github.com/pingcap-incubator/tinykv/kv/raftstore/message" @@ -43,7 +41,7 @@ func (r *splitCheckHandler) Handle(t worker.Task) { region := spCheckTask.Region regionId := region.Id log.Debugf("executing split check worker.Task: [regionId: %d, startKey: %s, endKey: %s]", regionId, - hex.EncodeToString(region.StartKey), hex.EncodeToString(region.EndKey)) + region.StartKey, region.EndKey) key := r.splitCheck(regionId, region.StartKey, region.EndKey) if key != nil { _, userKey, err := codec.DecodeBytes(key) diff --git a/kv/raftstore/util/error.go b/kv/raftstore/util/error.go index 0f54d63d1..5843ad06f 100644 --- a/kv/raftstore/util/error.go +++ b/kv/raftstore/util/error.go @@ -31,7 +31,7 @@ type ErrKeyNotInRegion struct { } func (e *ErrKeyNotInRegion) Error() string { - return fmt.Sprintf("key %v is not in region %v", e.Key, e.Region) + return fmt.Sprintf("key %s is not in region %v", e.Key, e.Region) } type ErrEpochNotMatch struct { diff --git a/kv/test_raftstore/cluster.go b/kv/test_raftstore/cluster.go index 11de7afd5..f3ca9fea4 100644 --- a/kv/test_raftstore/cluster.go +++ b/kv/test_raftstore/cluster.go @@ -3,7 +3,6 @@ package test_raftstore import ( "bytes" "context" - "encoding/hex" "fmt" "io/ioutil" "math/rand" @@ -274,7 +273,7 @@ func (c *Cluster) GetRegion(key []byte) *metapb.Region { // retry to get the region again. SleepMS(20) } - panic(fmt.Sprintf("find no region for %s", hex.EncodeToString(key))) + panic(fmt.Sprintf("find no region for %s", key)) } func (c *Cluster) GetRandomRegion() *metapb.Region { diff --git a/kv/test_raftstore/utils.go b/kv/test_raftstore/utils.go index dc4ac9534..b8abdc8b6 100644 --- a/kv/test_raftstore/utils.go +++ b/kv/test_raftstore/utils.go @@ -2,7 +2,6 @@ package test_raftstore import ( "bytes" - "encoding/hex" "fmt" "time" @@ -100,7 +99,7 @@ func MustGetCf(engine *engine_util.Engines, cf string, key []byte, value []byte) } SleepMS(20) } - panic(fmt.Sprintf("can't get value %s for key %s", hex.EncodeToString(value), hex.EncodeToString(key))) + panic(fmt.Sprintf("can't get value %s for key %s", value, key)) } func MustGetCfEqual(engine *engine_util.Engines, cf string, key []byte, value []byte) { @@ -121,7 +120,7 @@ func MustGetCfNone(engine *engine_util.Engines, cf string, key []byte) { } SleepMS(20) } - panic(fmt.Sprintf("get value %s for key %s", hex.EncodeToString(val), hex.EncodeToString(key))) + panic(fmt.Sprintf("get value %s for key %s", val, key)) } func MustGetNone(engine *engine_util.Engines, key []byte) {