forked from pingcap/tidb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backend/local: do not retry epochNotMatch error when ingest sst (ping…
…cap#419) * do not retry epochNotMatch error when ingest sst * add retry ingest for 'Raft raft: proposal dropped' error in ingest * change some retryable error log level from Error to Warn * fix nextKey * add a comment for nextKey * fix comment and add a unit test * wrap time.Sleep in select Co-authored-by: kennytm <[email protected]>
- Loading branch information
Showing
2 changed files
with
80 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{}), DeepEquals, []byte{}) | ||
|
||
cases := [][]byte{ | ||
{0}, | ||
{255}, | ||
{1, 255}, | ||
} | ||
for _, b := range cases { | ||
next := nextKey(b) | ||
c.Assert(next, DeepEquals, 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) | ||
} |