-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
It's found when I'm implementing paging on unistore.
tk.MustExec(`create table t (id int) partition by list (id) (
partition p0 values in (1,2),
partition p1 values in (3,4),
partition p3 values in (5,null)
);`)
tk.MustExec(`insert into t values (1),(3),(5),(null)`)
oldTbl := external.GetTableByName(t, tk, "test", "t")
tk.MustExec(`alter table t truncate partition p1`)
tk.MustQuery("select * from t").Sort().Check(testkit.Rows("1", "5", "<nil>"))
Before the bug fix, with paging protocol, "select * from t" returns "1" "5" "5" "" "<nil">
There are duplicated results.
That's because the distsql range is [{7480000000000000465f720000000000000000 7480000000000000465f72ffffffffffffffff00} {74800000000000004b5f720000000000000000 74800000000000004b5f72ffffffffffffffff00} {7480000000000000485f720000000000000000 7480000000000000485f72ffffffffffffffff00}]
Those key ranges are not ordered... and when paging retry, it retries {74800000000000004b5f720000000000000000 74800000000000004b5f72ffffffffffffffff00} {7480000000000000485f720000000000000000 7480000000000000485f72ffffffffffffffff00}]
So duplicated results are returned.
2. What did you expect to see? (Required)
coprocess paging work on dynamic partition mode.
3. What did you see instead (Required)
Result error, duplicated data.
Cause by the bug that distsql request key ranges is not sorted.
4. What is your TiDB version? (Required)
master, 6.1 ... and all prior versions (as long as the dynamic partition mode is supported)