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

fix a log issue #368

Open
wants to merge 3 commits into
base: course
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions kv/raftstore/meta/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
5 changes: 2 additions & 3 deletions kv/raftstore/runner/region_task.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package runner

import (
"encoding/hex"
"fmt"
"time"

Expand Down Expand Up @@ -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)
}
}

Expand Down
4 changes: 1 addition & 3 deletions kv/raftstore/runner/split_checker.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion kv/raftstore/util/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions kv/test_raftstore/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package test_raftstore
import (
"bytes"
"context"
"encoding/hex"
"fmt"
"io/ioutil"
"math/rand"
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions kv/test_raftstore/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package test_raftstore

import (
"bytes"
"encoding/hex"
"fmt"
"time"

Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down