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

br: RangeTree.GetIncompleteRange return wrong result when the rangeTree is empty. #37085

Closed
pingyu opened this issue Aug 13, 2022 · 0 comments · Fixed by #37086
Closed

br: RangeTree.GetIncompleteRange return wrong result when the rangeTree is empty. #37085

pingyu opened this issue Aug 13, 2022 · 0 comments · Fixed by #37086

Comments

@pingyu
Copy link
Contributor

pingyu commented Aug 13, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Run the following test case (with empty rangeTree):

func TestRangeTree(t *testing.T) {
	rangeTree := rtree.NewRangeTree()
	require.Nil(t, rangeTree.Get(newRange([]byte(""), []byte(""))))

	assertIncomplete := func(startKey, endKey []byte, ranges []rtree.Range) {
		incomplete := rangeTree.GetIncompleteRange(startKey, endKey)
		t.Logf("%#v %#v\n%#v\n%#v\n", startKey, endKey, incomplete, ranges)
		require.Equal(t, len(ranges), len(incomplete))
		for idx, rg := range incomplete {
			require.Equalf(t, ranges[idx].StartKey, rg.StartKey, "idx=%d", idx)
			require.Equalf(t, ranges[idx].EndKey, rg.EndKey, "idx=%d", idx)
		}
	}

	assertIncomplete([]byte(""), []byte(""), []rtree.Range{{StartKey: []byte(""), EndKey: []byte("")}})
}

2. What did you expect to see? (Required)

Test succeed.

3. What did you see instead (Required)

Test failed:

--- FAIL: TestRangeTree (0.00s)
    /disk1/home/pingyu/workspace/tidb/br/pkg/rtree/rtree_test.go:7: []byte{} []byte{}
        []rtree.Range{}
        []rtree.Range{rtree.Range{StartKey:[]uint8{}, EndKey:[]uint8{}, Files:[]*backup.File(nil)}}
    /disk1/home/pingyu/workspace/tidb/br/pkg/rtree/rtree_test.go:8: 
        	Error Trace:	/disk1/home/pingyu/workspace/tidb/br/pkg/rtree/rtree_test.go:8
        	            				/disk1/home/pingyu/workspace/tidb/br/pkg/rtree/rtree_test.go:1
        	Error:      	Not equal: 
        	            	expected: 1
        	            	actual  : 0
        	Test:       	TestRangeTree
FAIL
FAIL	github.com/pingcap/tidb/br/pkg/rtree	0.036s
FAIL

4. What is your TiDB version? (Required)

master (96165aa)

@pingyu pingyu added the type/bug The issue is confirmed as a bug. label Aug 13, 2022
pingyu added a commit to pingyu/tidb that referenced this issue Aug 13, 2022
Issue Number: pingcap#37085

Signed-off-by: pingyu <yuping@pingcap.com>
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 labels Aug 15, 2022
@ChenPeng2013 ChenPeng2013 removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 labels Aug 15, 2022
@jebter jebter added the component/br This issue is related to BR of TiDB. label Aug 4, 2023
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this issue Aug 16, 2023
Issue Number: pingcap#37085

Signed-off-by: pingyu <yuping@pingcap.com>
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this issue Aug 16, 2023
Issue Number: pingcap#37085

Signed-off-by: pingyu <yuping@pingcap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants