diff --git a/lightning/backend/local.go b/lightning/backend/local.go index 8555207aa..b65fc6189 100644 --- a/lightning/backend/local.go +++ b/lightning/backend/local.go @@ -1240,7 +1240,7 @@ func (local *local) isIngestRetryable( } } return true, newRegion, errors.Errorf("not leader: %s", errPb.GetMessage()) - case strings.Contains(errPb.Message, "Raft raft: proposal dropped"): + case strings.Contains(errPb.Message, "raft: proposal dropped"): // TODO: we should change 'Raft raft: proposal dropped' to a error type like 'NotLeader' newRegion, err = getRegion() if err != nil { diff --git a/lightning/backend/local_test.go b/lightning/backend/local_test.go new file mode 100644 index 000000000..19a2ce8f2 --- /dev/null +++ b/lightning/backend/local_test.go @@ -0,0 +1,33 @@ +package backend + +import ( + "bytes" + + . "github.com/pingcap/check" +) + +type localSuite struct{} + +var _ = Suite(&localSuite{}) + +func (s *localSuite) TestNextKey(c *C) { + c.Assert(nextKey([]byte{}), Equals, []byte{}) + + cases := [][]byte{ + []byte{0}, + []byte{255}, + []byte{1, 255}, + } + for _, b := range cases { + next := nextKey(b) + c.Assert(next, Equals, append(b, 0)) + } + + // in the old logic, this should return []byte{} which is not the actually smallest eky + next := nextKey([]byte{1, 255}) + c.Assert(bytes.Compare(next, []byte{2}), Equals, -1) + + // another test case, nextkey()'s return should be smaller than key with a prefix of the origin key + next = nextKey([]byte{1, 255}) + c.Assert(bytes.Compare(next, []byte{1, 255, 0, 1, 2}), Equals, -1) +}