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

With small @@tidb_min_paging_size, coprocessor paging get wrong result with unistore #36145

Closed
tiancaiamao opened this issue Jul 12, 2022 · 2 comments · Fixed by #36147
Closed
Labels
feature/developing the related feature is in development severity/minor type/bug The issue is confirmed as a bug.

Comments

@tiancaiamao
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table trange(a int, b int, index idx_a(a)) partition by range(a) (
		partition p0 values less than(300),
		partition p1 values less than (500),
		partition p2 values less than(1100));

insert into trange values (610, 1675), (258, 591), (819, 1234), (610, 308), (857, 618), (946, 1), (706, 263), (769, 904), (1078, 1655), (169, 77), (549, 1461), (1048, 673), (650, 1028), (356, 681), (380, 986), (1055, 1211), (275, 1507), (392, 754), (416, 329), (30, 1537), (434, 1072), (7, 1859), (7, 420), (743, 1883), (1005, 1457), (629, 43), (641, 1013), (177, 635), (654, 1611), (670, 135), (563, 1787), (1064, 59), (857, 1082), (1014, 922), (929, 1286), (480, 898), (738, 1294), (653, 1642), (155, 1194), (710, 1489), (615, 945), (106, 1304), (966, 1515), (627, 1446), (1049, 619), (172, 1682), (633, 1763), (445, 959), (1066, 1092), (134, 1105), (1004, 1662), (787, 1284), (890, 929), (859, 167), (253, 1700), (966, 1147), (834, 1619), (760, 1100), (536, 652), (429, 1263), (981, 1655), (729, 1256), (990, 1122), (67, 1075), (471, 1868), (676, 1389), (675, 1028), (529, 779), (105, 1574), (608, 1275), (115, 1447), (234, 1791), (678, 560), (793, 294), (486, 1975), (127, 230), (125, 881), (8, 1872), (756, 437), (532, 149), (620, 1102), (14, 698), (89, 569), (997, 592), (995, 1447), (390, 934), (746, 819), (197, 424), (149, 44), (949, 583), (745, 962), (969, 1600), (998, 1552), (329, 580), (385, 497), (408, 328), (37, 911), (660, 1313), (877, 173), (376, 1884), (641, 1851), (45, 1370), (759, 1722), (90, 165), (946, 965), (193, 390), (722, 1550), (557, 1029), (491, 1963), (587, 570), (325, 748), (538, 1188), (426, 240), (920, 1583), (803, 1171), (448, 752), (893, 809), (766, 286), (689, 1530), (904, 890), (1008, 1050), (865, 134), (243, 1298), (182, 1), (1053, 1529), (447, 1715), (733, 665), (742, 1668), (1070, 168), (910, 1921), (616, 613), (957, 1597), (117, 1644), (146, 1039), (3, 1448), (947, 1333), (32, 1369), (830, 1364), (660, 1903), (1032, 1991), (454, 1879), (822, 1774), (181, 1747), (146, 341), (795, 1860), (834, 363), (502, 1770), (581, 535), (191, 609), (199, 1418), (817, 940), (821, 9), (1079, 901), (684, 84), (750, 685), (137, 1857), (631, 1452), (838, 1193), (1068, 1017), (332, 595), (38, 304), (29, 1269), (560, 1061), (257, 1735), (33, 1416), (236, 1587), (414, 354), (648, 251), (155, 913), (565, 1242), (936, 235), (1085, 892), (209, 659), (685, 1876), (16, 581), (895, 1838), (638, 540), (864, 1560), (461, 1977), (585, 401), (51, 1390), (513, 1590), (729, 1080), (13, 1705), (919, 342), (760, 458), (996, 816), (952, 1479), (247, 1952), (39, 685), (528, 1890), (1009, 664), (1023, 1386), (468, 781), (298, 1095), (436, 1146), (109, 538), (20, 979), (402, 86), (561, 36), (427, 1824), (650, 212), (669, 174), (182, 611), (1069, 1876), (749, 859), (857, 482), (116, 337), (603, 826), (688, 1525), (159, 35), (731, 1699), (472, 916), (405, 1322), (347, 764), (115, 1793), (1094, 436), (1008, 1730), (808, 341), (1092, 1166), (867, 825), (210, 297), (503, 1157), (16, 1619), (599, 1830), (158, 1300), (138, 1799), (410, 1756), (885, 739), (575, 1190), (575, 428), (909, 1665), (719, 826), (723, 752), (931, 1017), (84, 1201), (23, 1670), (407, 1813), (554, 1082), (835, 975), (723, 442), (925, 1599), (1069, 1061), (986, 1135), (5, 467), (867, 1463), (1027, 1186), (272, 414), (544, 1964), (1060, 30), (955, 1945), (459, 1538), (923, 948), (591, 361), (970, 523), (505, 233), (703, 317), (559, 523), (1089, 1432), (672, 573), (23, 1968), (319, 442), (690, 1111), (815, 1746), (1072, 1874), (471, 1711), (908, 215), (500, 11), (1018, 1649), (922, 1258), (856, 1776), (102, 1839), (751, 1025), (386, 725), (109, 92), (407, 1821), (837, 1879), (295, 1192), (543, 477), (576, 1162), (672, 1177), (275, 879), (624, 1002), (852, 1658), (822, 869), (591, 135), (396, 293), (1024, 746), (1036, 951), (216, 1943), (995, 1484), (750, 1897), (140, 384), (560, 325), (490, 0), (335, 1786), (687, 847), (863, 43), (521, 1708), (893, 602), (404, 943), (29, 1647), (764, 1483), (466, 1058), (978, 265), (304, 137), (876, 498), (395, 243), (1011, 855), (312, 892), (939, 585), (886, 725), (694, 8), (217, 1114), (774, 1362), (251, 536), (582, 7), (423, 446), (976, 337), (243, 1389), (365, 1864), (949, 329), (1087, 626), (605, 838), (1003, 207), (111, 847), (258, 1572), (874, 1066), (622, 1052), (630, 361), (1095, 1875), (631, 790), (258, 832), (774, 1335), (119, 666), (545, 371), (770, 1841), (1047, 879), (1050, 1349), (172, 721), (906, 1322), (471, 1505), (706, 1119), (471, 1732), (583, 561), (631, 1555), (793, 1338), (1081, 1680), (270, 1597), (750, 1139), (638, 1945), (976, 682), (285, 1529), (341, 1764), (493, 1895), (625, 1735), (995, 1827), (92, 615), (597, 1822), (1057, 451), (1039, 260), (883, 1546), (704, 1368), (263, 92), (911, 715), (148, 818), (765, 1194), (356, 1980), (1086, 1895), (968, 199), (781, 61), (397, 690), (975, 1131), (997, 1975), (812, 1289), (1074, 1865), (388, 869), (888, 263), (275, 1249), (791, 63), (316, 313), (1039, 376), (901, 412), (1087, 1292), (769, 258), (963, 1), (799, 1704), (537, 355), (485, 65), (1082, 1538), (132, 1719), (247, 1107), (629, 805), (253, 156), (837, 859), (232, 270), (677, 252), (249, 304), (139, 1998), (192, 152), (410, 1332), (1087, 101), (485, 1936), (951, 1094), (462, 1463), (820, 1782), (733, 1047), (1041, 1600), (57, 296), (268, 1560), (1076, 18), (373, 1799), (936, 1276), (850, 1321), (40, 982), (317, 755), (255, 345), (760, 1678), (903, 24), (355, 245), (567, 40), (607, 1033), (117, 1152), (384, 684), (649, 1254), (186, 212), (493, 429), (585, 755), (979, 1787), (851, 746), (491, 1984), (68, 305), (6, 449), (768, 231), (1057, 1379), (406, 963), (899, 250), (135, 185), (895, 564), (616, 1198), (80, 908), (881, 1164), (641, 109), (789, 602), (674, 1533), (582, 1994), (740, 237), (878, 281), (786, 1880), (371, 119), (436, 107), (897, 1543), (497, 1681), (778, 1593), (687, 850), (546, 122), (243, 1101), (1048, 351), (615, 1077), (936, 37), (691, 1942), (401, 332), (217, 91), (519, 1164), (70, 951), (274, 1343), (223, 1804), (463, 164), (807, 594), (671, 1840), (142, 1467), (17, 0), (84, 1436), (583, 1483), (567, 336), (742, 1981), (381, 1792), (551, 1939), (687, 1753), (858, 710), (173, 1599), (574, 1844), (933, 1078), (192, 1033), (523, 1384), (87, 132), (671, 1052), (502, 1495), (224, 98), (987, 490), (1081, 397), (326, 1573), (887, 1935), (1065, 621), (405, 1506), (187, 1880), (689, 1159), (693, 1481), (442, 1641), (515, 124), (431, 1883), (546, 1750), (704, 826), (983, 883), (905, 936), (59, 337), (1073, 16), (672, 466), (519, 1225), (243, 455), (358, 1029), (426, 977), (492, 1377), (47, 1699), (499, 1858), (0, 1716), (831, 574), (988, 739), (1040, 1668), (105, 1482), (81, 1877), (189, 1871), (743, 744), (770, 1405), (1080, 595), (662, 1686), (47, 1049), (739, 546), (90, 1739), (357, 492), (408, 1448), (815, 570), (909, 1153), (1095, 277), (333, 1149), (64, 1363), (631, 834), (336, 1819), (219, 1022), (737, 426), (64, 1370), (29, 974), (1064, 469), (223, 517), (742, 534), (847, 237), (122, 63), (154, 1678), (166, 1604), (92, 1478), (1059, 264), (549, 1461), (1019, 1315), (675, 1415), (223, 863), (963, 1478), (1093, 1559), (202, 477), (1056, 975), (237, 1239), (301, 508), (277, 527), (644, 1365), (803, 1809), (275, 199), (982, 941), (1009, 1559), (283, 993), (732, 1030), (361, 529), (698, 58), (1042, 177), (512, 1521), (61, 391), (561, 1349), (904, 1920), (1076, 1319), (434, 1943), (608, 1449), (783, 1278), (681, 1970), (777, 126), (223, 1769), (900, 1550), (258, 1913), (1011, 848), (974, 889), (818, 371), (764, 1141), (669, 1926), (787, 563), (897, 1735), (274, 312), (696, 444), (335, 1817), (527, 1976), (21, 604), (219, 343), (632, 1652), (829, 1359), (11, 386), (347, 1096), (703, 768), (107, 119), (60, 1288), (441, 1588), (124, 1008), (1077, 1195), (317, 1141), (674, 1560), (534, 363), (932, 1753), (589, 393), (937, 43), (476, 1573), (579, 804), (970, 890), (965, 200), (706, 185), (414, 226), (592, 1847), (731, 115), (269, 1214), (1093, 1567), (59, 473), (327, 1126), (316, 1287), (936, 630), (333, 1850), (134, 324), (946, 632), (624, 961), (433, 1619), (721, 1540), (709, 725), (31, 1273), (508, 1658), (871, 1165), (916, 1402), (849, 1053), (176, 904), (168, 310), (738, 1798), (937, 931), (41, 1142), (582, 749), (275, 782), (714, 1261), (490, 823), (685, 140), (1038, 1781), (891, 1971), (13, 282), (814, 1427), (284, 1217), (151, 1443), (111, 1623), (642, 1734), (219, 321), (879, 965), (1084, 172), (363, 712), (1008, 1705), (1000, 931), (158, 573), (838, 762), (960, 1371), (441, 378), (837, 1710), (923, 460), (823, 589), (382, 1902), (411, 1899), (485, 570), (332, 1268), (1064, 265), (810, 62), (446, 1593), (1064, 1739), (86, 1911), (287, 1131), (498, 175), (638, 1914), (27, 1522), (544, 958), (280, 1345), (290, 547), (409, 1618), (472, 1735), (569, 975), (671, 513), (770, 548), (695, 1076), (449, 1934), (849, 855), (483, 719), (844, 607), (465, 1614), (186, 1029), (636, 1481), (13, 1625), (904, 1521), (440, 1), (112, 1093), (977, 72), (1031, 398), (1065, 1250), (804, 1605), (592, 1985), (203, 1194), (839, 255), (150, 1913), (416, 344), (779, 1911), (861, 1082), (1000, 420), (55, 932), (644, 1018), (161, 1193), (577, 1507), (148, 571), (92, 1515), (173, 1229), (987, 586), (312, 271), (474, 187), (579, 1423), (899, 98), (641, 512), (124, 990), (226, 1321), (324, 1106), (716, 873), (650, 1963), (228, 353), (1009, 888), (908, 1132), (670, 4), (228, 1062), (231, 1006), (622, 1795), (73, 1689), (152, 493), (159, 1658), (756, 598), (405, 1615), (222, 1176), (865, 1407), (439, 172), (239, 30), (681, 507), (1055, 1417), (236, 1794), (162, 302), (960, 1455), (680, 1464), (608, 1170), (140, 1570), (18, 1168), (37, 1437), (21, 1660), (824, 1795), (456, 1953), (724, 1879), (24, 1534), (435, 1351), (967, 1417), (296, 295), (513, 1960), (614, 1296), (144, 24), (941, 990), (320, 432), (651, 1613), (484, 1686), (1002, 834), (890, 512), (940, 1635), (99, 632), (831, 118), (24, 1692), (681, 1169), (502, 886), (45, 1387), (561, 716), (168, 1170), (19, 1131), (666, 1314), (108, 501), (1014, 285), (231, 687), (765, 1375), (642, 1350), (965, 223), (232, 1846), (347, 519), (752, 450), (846, 69), (970, 347), (37, 42), (291, 904), (106, 632), (155, 727), (248, 524), (761, 1683), (660, 1580), (39, 1407), (525, 1639), (838, 71), (88, 111), (186, 1257), (34, 1335), (442, 253), (870, 156), (975, 242), (668, 1379), (741, 134), (782, 1098), (233, 1139), (130, 1811), (397, 332), (849, 1473), (114, 447), (1029, 1991), (1047, 62), (606, 12), (219, 342), (271, 1102), (95, 610), (614, 849), (635, 1889), (101, 1373), (1011, 502), (1099, 974), (315, 354), (251, 998), (687, 209), (554, 1590), (123, 957), (65, 1043), (727, 1113), (691, 603), (620, 1603), (577, 620), (327, 1622), (660, 520), (316, 1815), (373, 1344), (48, 816), (634, 1502), (426, 1116), (260, 219), (376, 1999), (110, 503), (334, 1210), (606, 1948), (423, 623), (838, 1216), (131, 788), (560, 681), (497, 1167), (901, 83), (462, 1169), (363, 953), (707, 1471), (940, 520), (308, 229), (582, 1999), (606, 699), (366, 1911), (122, 411), (98, 841), (519, 322), (561, 1769), (914, 570), (639, 344), (628, 583), (239, 1787), (438, 909), (213, 1136), (677, 91), (141, 266), (316, 657), (1055, 1447), (530, 1068), (251, 1563), (1099, 33), (1010, 1666), (531, 148), (442, 836), (643, 779), (327, 1196), (106, 429), (497, 1680), (133, 915), (656, 411), (849, 417), (156, 660), (564, 1883), (130, 98), (984, 1544), (677, 1219), (903, 1349), (776, 1808), (834, 1260), (709, 718), (164, 1751), (144, 1054), (879, 814), (720, 1527), (522, 1862), (34, 372), (375, 416), (325, 1074), (750, 1932), (238, 1673), (1064, 114), (188, 310), (795, 1334), (942, 1268), (177, 1927), (517, 226), (907, 833), (1058, 558), (161, 1891), (368, 1236), (200, 1625), (707, 776), (600, 322), (329, 1582), (263, 1720), (928, 381), (869, 387), (326, 1692), (1, 1495), (109, 1223), (14, 1965), (744, 115), (457, 1539), (352, 1508), (335, 1833), (1, 229), (982, 1540), (413, 902), (243, 1006), (634, 979), (1061, 1323), (689, 1876), (678, 1277), (1054, 797), (990, 89), (604, 1311), (755, 926), (75, 220), (531, 276), (1063, 1296), (545, 1811), (11, 1086), (342, 1365), (143, 1392), (1066, 1489), (548, 77), (786, 551), (1007, 1856), (27, 1059), (722, 623), (806, 1188), (373, 912), (446, 449), (217, 1311), (597, 956), (832, 1588), (708, 1662), (922, 78), (32, 505), (859, 976), (295, 1665), (384, 475), (1071, 1485), (521, 1587), (35, 1025), (667, 1576), (411, 703), (727, 513), (627, 1247), (643, 773), (716, 805), (538, 1105), (630, 709), (344, 652), (551, 1544), (1080, 1431), (583, 844), (250, 1810), (282, 653), (536, 956), (9, 299), (54, 3), (938, 1597), (888, 1060), (960, 1624), (137, 778), (1001, 344), (463, 1896), (176, 162), (772, 1107), (965, 1586), (104, 375), (414, 1402), (221, 127), (819, 1919), (728, 1584), (181, 183), (378, 1979), (343, 1988), (275, 982), (533, 1857), (502, 503), (1048, 1369), (829, 1362), (1031, 1374), (1087, 464), (208, 1028), (841, 658), (437, 924), (16, 1868), (266, 1031), (965, 592), (920, 781), (16, 528), (204, 1733), (565, 598), (924, 626), (959, 1682), (33, 888), (442, 398), (671, 186), (7, 206), (973, 1313), (738, 937), (141, 356), (217, 237), (380, 1796), (310, 866), (401, 105), (203, 525), (721, 1534), (673, 1690), (471, 633), (832, 447), (750, 1668), (591, 377), (697, 1604), (744, 369), (618, 1302), (552, 1079), (462, 1639), (881, 1578), (582, 1788), (550, 1618), (581, 954), (361, 287), (205, 838), (462, 1980), (37, 1377), (169, 1385), (335, 1187), (900, 1752), (315, 905), (139, 1893), (110, 850), (243, 1574), (383, 1329), (61, 141), (1040, 951), (229, 573), (40, 386), (446, 185), (615, 737), (1027, 1655), (667, 1284), (794, 1733), (411, 393), (394, 1265), (821, 1560), (246, 1857), (383, 1135), (376, 718), (327, 1575), (997, 1846), (1004, 749), (490, 1171), (549, 860), (649, 943), (25, 459), (792, 137), (343, 432), (265, 633), (423, 933), (970, 560), (206, 773), (280, 1892), (923, 843), (331, 1265), (317, 353), (1082, 373), (539, 897), (833, 1346), (272, 520), (395, 1013), (37, 709), (844, 50), (0, 1883), (1028, 270), (133, 1958), (273, 415), (392, 1905), (782, 543), (371, 31), (34, 1368), (199, 10), (598, 1377), (965, 1398), (516, 1088), (290, 1579), (82, 710), (0, 1433), (135, 1028), (793, 1642), (409, 1670), (752, 353), (856, 1184), (718, 1224), (648, 790), (192, 692), (571, 699), (515, 660), (150, 853), (232, 1853), (595, 1402), (757, 231), (1004, 1596), (516, 1631), (30, 1784), (341, 1157), (906, 494), (283, 1048), (540, 1855), (906, 1993), (204, 147), (94, 817), (685, 1624), (1098, 1119), (159, 329), (1072, 109), (588, 1806), (614, 1141), (830, 1721), (327, 115), (277, 717), (882, 575), (1092, 1099), (956, 1479), (564, 215), (359, 1274), (64, 131), (1097, 120), (186, 1972), (321, 316), (947, 467), (464, 1815), (540, 1000), (497, 1490), (298, 1382), (469, 1623), (507, 157), (112, 955), (826, 384), (7, 1371), (192, 1638), (502, 1741), (793, 1541), (34, 434), (22, 850), (882, 1865), (999, 1801), (604, 1058), (15, 1421), (1097, 848), (819, 296), (555, 1229), (168, 83), (380, 1705), (376, 125), (1057, 1862), (37, 1257), (1048, 1531), (434, 1947), (354, 1662), (702, 1164), (497, 893), (690, 433), (821, 1817), (785, 84), (97, 145), (476, 1095), (95, 238), (910, 1529), (687, 592), (847, 1326), (345, 636), (505, 1161), (639, 313), (814, 421), (0, 1501), (309, 702), (972, 192), (458, 1344), (817, 349), (166, 658), (879, 9), (623, 1893), (744, 78), (155, 106), (645, 1297), (1002, 1805), (679, 1062), (408, 1104), (1063, 1118), (948, 1949), (620, 732), (36, 1645), (959, 1572), (14, 1928), (54, 1104), (714, 1792), (600, 1784), (466, 533), (1088, 632), (519, 1245), (882, 613), (421, 791), (712, 392), (806, 368), (79, 825), (1050, 930), (1053, 650), (463, 1040), (809, 134), (263, 390), (746, 274), (386, 1652), (92, 1547), (2, 824), (184, 28), (494, 990), (695, 1627), (83, 1929), (106, 1729), (195, 1062), (99, 1901), (566, 1577), (875, 1344), (826, 1502), (518, 1994), (120, 1895), (773, 1812), (962, 1383), (295, 1240), (200, 55), (278, 1066), (505, 1270), (601, 1532), (972, 0), (110, 217), (141, 403), (865, 1831), (61, 636), (453, 1275), (560, 277), (149, 1525), (233, 230), (632, 304), (887, 1927), (881, 1126), (821, 1667), (150, 1873), (582, 865), (1023, 1142), (545, 1127), (435, 611), (66, 1470), (915, 1058), (746, 1634), (118, 1207), (947, 661), (361, 1233), (737, 574), (252, 345), (187, 174), (514, 1213), (577, 154), (629, 1937), (980, 247), (549, 1859), (1095, 1048), (12, 328), (263, 1217), (662, 22), (897, 364), (669, 474), (251, 1421), (760, 333), (282, 1497), (956, 1336), (355, 1174), (822, 1933), (772, 1936), (282, 962), (617, 855), (760, 136), (821, 600), (570, 886), (1020, 198), (95, 1884), (565, 628), (525, 296), (588, 1558), (760, 1948), (725, 894), (8, 74), (755, 1157), (290, 1016), (259, 1739), (581, 920), (112, 878), (390, 157), (728, 723), (673, 963), (516, 609), (371, 1157), (3, 401), (1060, 1833), (828, 304), (686, 805), (1081, 180), (623, 1355), (55, 1207), (318, 242), (839, 1935), (855, 273), (492, 433), (287, 456), (439, 609), (164, 1709), (379, 264), (563, 1876), (930, 1042), (996, 296), (610, 1818), (1045, 1579), (427, 1837), (345, 1682), (732, 1742), (158, 525), (357, 854), (140, 335), (664, 25), (923, 1280), (509, 1902), (568, 306), (257, 1582), (149, 1039), (1030, 1928), (1035, 1531), (707, 1955), (974, 843), (55, 1313), (94, 794), (617, 699), (107, 978), (1063, 1017), (367, 1281), (805, 1731), (224, 403), (420, 826), (836, 1740), (740, 459), (264, 491), (957, 738), (912, 461), (246, 1722), (766, 744), (673, 287), (279, 1596), (1001, 844), (574, 1700), (697, 791), (737, 1520), (133, 1921), (1034, 935), (227, 1996), (128, 1643), (524, 1220), (657, 427), (933, 1523), (251, 1561), (283, 1774), (775, 935), (6, 363), (949, 1643), (763, 1066), (624, 661), (744, 498), (645, 949), (78, 360), (1013, 1930), (348, 1718), (240, 1505), (972, 1180), (532, 63), (69, 93), (899, 1284), (393, 682), (675, 1921), (571, 511), (1078, 104), (499, 1356), (650, 1050), (469, 1599), (1067, 1154), (236, 1392), (4, 771), (655, 890), (980, 1861), (381, 706), (98, 1663), (156, 1522), (147, 1052), (737, 1095), (59, 1252), (1065, 228), (54, 859), (182, 521), (348, 1619), (119, 1365), (247, 1951), (458, 193), (130, 1918), (379, 1518), (46, 1548), (843, 513), (268, 878), (780, 218), (905, 1919), (786, 1568), (927, 772), (418, 693), (361, 1111), (592, 135), (292, 1378), (458, 1692), (896, 302), (613, 1522), (1086, 1852), (847, 933), (673, 1925), (641, 215), (732, 1607), (748, 1757), (259, 720), (145, 1386), (494, 1289), (677, 1192), (239, 913), (263, 1666), (599, 722), (691, 1673), (625, 1267), (42, 1140), (959, 12), (141, 341), (504, 1616), (645, 1657), (600, 1864), (536, 626), (422, 977), (1076, 1326), (750, 939), (1057, 96), (20, 832), (330, 876), (865, 1783), (472, 1485), (671, 517), (332, 1090), (576, 573), (57, 1584), (600, 1283), (939, 1081), (173, 692), (973, 1312), (1068, 1094), (500, 1462), (571, 1413), (1065, 930), (20, 754), (791, 154), (127, 1525), (987, 1625), (667, 746), (361, 1747), (1048, 974), (70, 1352), (901, 100), (156, 1057), (812, 1022), (851, 1763), (419, 1129), (335, 378), (1023, 683), (0, 237), (376, 1554), (399, 1271), (169, 1788), (585, 1301), (917, 1068), (167, 1744), (872, 720), (450, 505), (949, 339), (301, 1964), (715, 723), (802, 470), (375, 1625), (65, 292), (1046, 1949), (364, 981), (0, 495), (587, 25), (904, 975), (61, 874), (1056, 1670), (7, 265), (1088, 1149), (379, 1818), (507, 8), (64, 1094), (992, 26), (743, 1750), (548, 1309), (490, 1087), (246, 1728), (121, 94), (393, 727), (757, 764), (680, 887), (288, 653), (121, 1394), (975, 240), (261, 1458), (703, 1229), (240, 1574), (1066, 950), (810, 68), (779, 197), (95, 246), (356, 1106), (239, 376), (866, 1828), (254, 1842), (1044, 477), (146, 1599), (570, 686), (540, 452), (323, 491), (180, 1584), (804, 1227), (497, 696), (15, 1148), (805, 109), (655, 424), (893, 1307), (229, 60), (371, 916), (800, 1511), (574, 1886), (176, 425), (940, 1089), (846, 931), (892, 1140), (384, 162), (462, 573), (52, 305), (356, 628), (482, 1560), (545, 1838), (412, 1577), (100, 995), (716, 927), (555, 1224), (79, 1152), (178, 1161), (199, 1156), (581, 1710), (562, 1229), (195, 1392), (19, 1546), (1045, 289), (290, 141), (73, 955), (982, 1126), (389, 1048), (986, 1861), (1047, 376), (441, 254), (326, 694), (10, 197), (1029, 1212), (242, 1168), (491, 1373), (352, 18), (388, 491), (485, 536), (1015, 1371), (492, 1428), (583, 440), (430, 278), (513, 1482), (363, 1849), (682, 512), (975, 92), (590, 1801), (320, 1566), (511, 155), (393, 1682), (950, 1333), (132, 506), (684, 1832), (572, 1642), (571, 551), (137, 1738), (394, 288), (763, 1015), (763, 431), (27, 1247), (858, 1695), (950, 947), (404, 82), (207, 1645), (108, 156), (560, 1926), (51, 203), (410, 1706), (636, 64), (815, 375), (435, 563), (945, 1465), (599, 255), (1071, 663), (248, 1551), (1030, 1582), (949, 327), (587, 665), (524, 599), (358, 848), (687, 382), (882, 1111), (341, 72), (629, 1142), (505, 940), (203, 540), (173, 1156), (451, 332), (288, 1957), (1077, 836), (917, 1035), (904, 1048), (205, 716), (725, 1734), (61, 1495), (762, 173), (865, 777), (707, 1472), (724, 1607), (344, 1963), (732, 1806), (193, 667), (442, 1066), (55, 1809), (35, 1533), (887, 1074), (456, 1189), (278, 1201), (967, 1219), (169, 1193), (885, 134), (745, 1234), (326, 1141), (1070, 1441), (550, 1160), (1012, 1016), (169, 1129), (67, 590), (894, 367), (972, 1847), (23, 1779), (115, 1754), (304, 1080), (474, 1321), (248, 1624), (526, 651), (178, 886), (647, 854), (222, 712), (914, 539), (261, 1549), (507, 1953), (126, 672), (420, 742), (991, 219), (1035, 1041), (969, 1247), (318, 1309), (240, 1661), (235, 597), (168, 1686), (374, 1660), (435, 286), (784, 1131), (1009, 1707), (937, 1984), (762, 1667), (838, 79), (983, 1488), (740, 1620), (798, 363), (166, 412), (465, 1160), (667, 1850), (272, 489), (184, 609), (682, 684), (840, 931), (751, 310), (869, 1944), (501, 1955), (728, 1930), (698, 1660), (1014, 1786), (13, 757), (370, 1972), (572, 1005), (1012, 408), (546, 1573), (226, 662), (598, 1672), (192, 1258), (990, 526), (1012, 512), (861, 633), (316, 953), (739, 27), (627, 722), (556, 1424), (274, 212), (852, 1148), (834, 914), (897, 789), (935, 194), (943, 653), (422, 1225), (789, 1950), (842, 644), (578, 181), (818, 1519), (332, 948), (444, 1029), (904, 1858), (755, 1814), (89, 555), (756, 304), (315, 153), (388, 310), (512, 446), (224, 1763), (713, 53), (566, 961), (790, 1788), (629, 384), (536, 1512), (391, 565), (167, 1444), (612, 17), (497, 1429), (184, 1988), (298, 1672), (536, 1453), (851, 682), (470, 763), (891, 1381), (736, 258), (231, 1479), (315, 1708), (104, 1667), (836, 1149), (988, 305), (154, 1275), (706, 1990), (687, 1923), (238, 31), (764, 157), (413, 1904), (1012, 1423), (994, 1819), (163, 525), (1061, 1983), (748, 763), (126, 1273), (334, 71), (146, 176), (1071, 1564), (45, 1368), (1084, 1316), (602, 295), (956, 1732), (64, 235), (857, 8), (962, 1993), (190, 1148), (221, 386), (464, 841), (666, 1887), (391, 1447), (1026, 1879), (158, 1086), (16, 652), (930, 1087), (242, 1586), (374, 365), (391, 1259), (901, 1472), (1042, 1962), (804, 420), (1082, 218), (1054, 1631), (644, 1055), (1041, 966), (400, 1857), (1057, 1407), (362, 1587), (207, 358), (418, 105), (200, 108), (515, 68), (911, 1218), (470, 664), (713, 980), (568, 879), (411, 499), (449, 80), (314, 8), (143, 1195), (327, 835), (871, 639), (916, 1324), (357, 1576), (809, 300), (453, 1941), (616, 1086), (377, 1739), (295, 480), (997, 717), (591, 1520), (955, 610), (289, 166), (901, 1243), (375, 525), (413, 958), (527, 1820), (315, 755), (289, 1667), (541, 617), (356, 533), (792, 1354), (436, 1407), (1094, 394), (370, 641), (1088, 1025), (769, 387), (194, 1222), (298, 1718), (652, 1296), (155, 36), (851, 1075), (1088, 1826), (685, 1913), (239, 72), (334, 1473), (939, 825), (661, 1020), (754, 426), (259, 1468), (528, 790), (738, 1076), (642, 366), (908, 294), (262, 503), (387, 1403), (80, 1137), (988, 1250), (728, 816), (609, 1622), (990, 1617), (236, 1838), (637, 1997), (14, 1528), (769, 955), (581, 1909), (908, 1014), (4, 822), (544, 454), (775, 756), (174, 110), (486, 1943), (459, 417), (1076, 1573), (401, 1206), (1088, 1559), (1073, 347), (110, 1679), (560, 598), (370, 1914), (922, 1171), (1065, 527), (326, 1160), (416, 1411), (800, 547), (114, 924), (961, 265), (541, 588), (25, 321), (981, 561), (0, 1077), (27, 795), (1081, 333), (212, 1153), (499, 480), (541, 993), (652, 823), (71, 845), (819, 1368), (907, 568), (29, 1908), (572, 286), (700, 1838), (175, 156), (134, 1759), (729, 1360), (895, 1371), (632, 1700), (912, 1955), (240, 1887), (450, 305), (260, 44), (727, 792), (676, 1508), (451, 640), (141, 824), (235, 1179), (381, 8), (291, 652), (658, 445), (246, 435), (379, 646), (427, 1699), (622, 1095), (143, 1341), (282, 772), (551, 1574), (907, 338), (666, 712), (299, 969), (442, 55), (862, 614), (83, 374), (384, 1921), (459, 232), (966, 1962), (220, 684), (514, 1008), (536, 1954), (537, 1377), (174, 500), (665, 1308), (853, 1620), (588, 527), (934, 134), (1028, 164), (988, 1264);

select a from trange use index(idx_a) where a > 84 order by a limit 1484;

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

The query return more than 1000 rows...

3. What did you see instead (Required)

The result is wrong, only 96 rows.

4. What is your TiDB version? (Required)

master

@tiancaiamao tiancaiamao added type/bug The issue is confirmed as a bug. feature/developing the related feature is in development labels Jul 12, 2022
@tiancaiamao
Copy link
Contributor Author

The test case is from

func TestOrderByandLimit(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create database test_orderby_limit")
tk.MustExec("use test_orderby_limit")
tk.MustExec("set @@tidb_partition_prune_mode = 'dynamic'")
// range partition table
tk.MustExec(`create table trange(a int, b int, index idx_a(a)) partition by range(a) (
partition p0 values less than(300),
partition p1 values less than (500),
partition p2 values less than(1100));`)
// hash partition table
tk.MustExec("create table thash(a int, b int, index idx_a(a), index idx_b(b)) partition by hash(a) partitions 4;")
// regular table
tk.MustExec("create table tregular(a int, b int, index idx_a(a))")
// generate some random data to be inserted
vals := make([]string, 0, 2000)
for i := 0; i < 2000; i++ {
vals = append(vals, fmt.Sprintf("(%v, %v)", rand.Intn(1100), rand.Intn(2000)))
}
tk.MustExec("insert into trange values " + strings.Join(vals, ","))
tk.MustExec("insert into thash values " + strings.Join(vals, ","))
tk.MustExec("insert into tregular values " + strings.Join(vals, ","))
// test indexLookUp
for i := 0; i < 100; i++ {
// explain select * from t where a > {y} use index(idx_a) order by a limit {x}; // check if IndexLookUp is used
// select * from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result
x := rand.Intn(1099)
y := rand.Intn(2000) + 1
queryPartition := fmt.Sprintf("select * from trange use index(idx_a) where a > %v order by a, b limit %v;", x, y)
queryRegular := fmt.Sprintf("select * from tregular use index(idx_a) where a > %v order by a, b limit %v;", x, y)
require.True(t, tk.HasPlan(queryPartition, "IndexLookUp")) // check if IndexLookUp is used
tk.MustQuery(queryPartition).Sort().Check(tk.MustQuery(queryRegular).Sort().Rows())
}
// test tableReader
for i := 0; i < 100; i++ {
// explain select * from t where a > {y} ignore index(idx_a) order by a limit {x}; // check if IndexLookUp is used
// select * from t where a > {y} ignore index(idx_a) order by a limit {x}; // it can return the correct result
x := rand.Intn(1099)
y := rand.Intn(2000) + 1
queryPartition := fmt.Sprintf("select * from trange ignore index(idx_a) where a > %v order by a, b limit %v;", x, y)
queryRegular := fmt.Sprintf("select * from tregular ignore index(idx_a) where a > %v order by a, b limit %v;", x, y)
require.True(t, tk.HasPlan(queryPartition, "TableReader")) // check if tableReader is used
tk.MustQuery(queryPartition).Sort().Check(tk.MustQuery(queryRegular).Sort().Rows())
}
// test indexReader
for i := 0; i < 100; i++ {
// explain select a from t where a > {y} use index(idx_a) order by a limit {x}; // check if IndexLookUp is used
// select a from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result
x := rand.Intn(1099)
y := rand.Intn(2000) + 1
queryPartition := fmt.Sprintf("select a from trange use index(idx_a) where a > %v order by a limit %v;", x, y)
queryRegular := fmt.Sprintf("select a from tregular use index(idx_a) where a > %v order by a limit %v;", x, y)
require.True(t, tk.HasPlan(queryPartition, "IndexReader")) // check if indexReader is used
tk.MustQuery(queryPartition).Sort().Check(tk.MustQuery(queryRegular).Sort().Rows())
}
// test indexMerge
for i := 0; i < 100; i++ {
// explain select /*+ use_index_merge(t) */ * from t where a > 2 or b < 5 order by a limit {x}; // check if IndexMerge is used
// select /*+ use_index_merge(t) */ * from t where a > 2 or b < 5 order by a limit {x}; // can return the correct value
y := rand.Intn(2000) + 1
queryPartition := fmt.Sprintf("select /*+ use_index_merge(thash) */ * from thash where a > 2 or b < 5 order by a, b limit %v;", y)
queryRegular := fmt.Sprintf("select * from tregular where a > 2 or b < 5 order by a, b limit %v;", y)
require.True(t, tk.HasPlan(queryPartition, "IndexMerge")) // check if indexMerge is used
tk.MustQuery(queryPartition).Sort().Check(tk.MustQuery(queryRegular).Sort().Rows())
}
}

I found this when I'm testing #36106

@tiancaiamao
Copy link
Contributor Author

Only affect unistore...
In a real tikv, the query work correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/developing the related feature is in development severity/minor type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant