Skip to content

Commit d474642

Browse files
committed
MDEV-10092: Server crashes in in ha_heap::rnd_pos / Table_read_cursor::get_next
The bug was caused by several issues. 2 problems in seek_io_cache. Due to wrong offsets used, we would end up seeking way too much (first change), or over the intended seek point (second change). Fixing it requires correctly detecting available data in buffer (first change), and not using "IO_SIZE alligned" reads. The second is needed because _my_b_cache_read adjusts the pos_in_file itself based on read_pos and read_end. Pretending buffer is empty when we want to force a read will aleviate this problem. Secondly, the big-table cursors didn't repect the interface definitions of always returning the rownumber that Table_read_cursor::fetch() would activate. At the same time, next(), prev() and move_to() should not perform any row activation.
1 parent 9fe9fb6 commit d474642

File tree

4 files changed

+477
-28
lines changed

4 files changed

+477
-28
lines changed
Lines changed: 328 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
#
2+
# MDEV-10092: Server crashes in in ha_heap::rnd_pos / Table_read_cursor::get_next
3+
#
4+
CREATE TABLE `orders` (
5+
`o_orderkey` int(11) NOT NULL,
6+
`o_custkey` double DEFAULT NULL,
7+
`o_orderstatus` char(1) DEFAULT NULL,
8+
`o_totalprice` double DEFAULT NULL,
9+
`o_orderDATE` date DEFAULT NULL,
10+
`o_orderpriority` char(15) DEFAULT NULL,
11+
`o_clerk` char(15) DEFAULT NULL,
12+
`o_shippriority` int(11) DEFAULT NULL,
13+
`o_comment` varchar(79) DEFAULT NULL,
14+
KEY `i_o_orderdate` (`o_orderDATE`),
15+
KEY `i_o_custkey` (`o_custkey`)
16+
) DEFAULT CHARSET=latin1;
17+
create procedure add_data()
18+
begin
19+
INSERT INTO `orders` VALUES (593793,3220,'O',181553.02,'1996-10-12','5-LOW','Clerk#000000921',0,'carefully unusual instructions are final pl');
20+
INSERT INTO `orders` VALUES (593794,4681,'F',32306.35,'1994-03-15','2-HIGH','Clerk#000000776',0,'slyly ironic depths are blithely. final excuses across the unusual instruction');
21+
INSERT INTO `orders` VALUES (593795,7213,'O',206579.47,'1998-03-04','2-HIGH','Clerk#000000746',0,'ruthlessly regular theodolites atop the blith');
22+
INSERT INTO `orders` VALUES (593796,10486,'F',181299.81,'1993-01-13','3-MEDIUM','Clerk#000000787',0,'special theodolites detect slyly. p');
23+
INSERT INTO `orders` VALUES (593797,3316,'O',208149.32,'1996-12-22','1-URGENT','Clerk#000000355',0,'carefully silent theodolites use blithely acco');
24+
INSERT INTO `orders` VALUES (593798,1613,'F',254625.5,'1995-01-26','2-HIGH','Clerk#000000504',0,'fluffily even requests ar');
25+
INSERT INTO `orders` VALUES (593799,4418,'F',45122.99,'1993-07-12','1-URGENT','Clerk#000000838',0,'blithely ironic ideas boost furiously above the ironic foxes. special pac');
26+
INSERT INTO `orders` VALUES (593824,12013,'F',216314.23,'1992-02-28','1-URGENT','Clerk#000000074',0,'quickly furious requests play above the fur');
27+
INSERT INTO `orders` VALUES (593825,8101,'O',123101.26,'1997-01-23','5-LOW','Clerk#000000649',0,'regular deposits haggle after the carefully i');
28+
INSERT INTO `orders` VALUES (593826,6958,'O',280097.59,'1995-12-14','2-HIGH','Clerk#000000080',0,'slyly even ideas about the slyly pending escapades cajole above th');
29+
INSERT INTO `orders` VALUES (593827,14116,'O',103011.78,'1995-12-16','3-MEDIUM','Clerk#000000567',0,'blithely bold decoys are furiously. fluffy deposits serve flu');
30+
INSERT INTO `orders` VALUES (593828,6839,'F',106697.51,'1993-12-11','4-NOT SPECIFIED','Clerk#000000065',0,'carefully final theodolites wake quickly final theodolites! unus');
31+
INSERT INTO `orders` VALUES (593829,14605,'O',44147.73,'1997-02-18','3-MEDIUM','Clerk#000000474',0,'ironic requests use carefully against the iro');
32+
INSERT INTO `orders` VALUES (593830,12976,'F',167393.6,'1994-06-21','1-URGENT','Clerk#000000424',0,'dolphins haggle careful');
33+
INSERT INTO `orders` VALUES (593831,14107,'O',208417.51,'1997-11-18','4-NOT SPECIFIED','Clerk#000000336',0,'furiously express pinto beans after the blithely pending requests need to ');
34+
INSERT INTO `orders` VALUES (593856,5623,'O',143236.09,'1998-03-24','5-LOW','Clerk#000000382',0,'carefully ironic accounts impress slyly according to the ironic');
35+
INSERT INTO `orders` VALUES (593857,1828,'O',217673.82,'1996-01-12','1-URGENT','Clerk#000000060',0,'special, special pinto beans haggle blithely. blithel');
36+
INSERT INTO `orders` VALUES (593858,14755,'O',8032.07,'1997-07-20','4-NOT SPECIFIED','Clerk#000000110',0,'regular excuses use ironic pinto ');
37+
INSERT INTO `orders` VALUES (593859,8780,'F',356852.14,'1992-10-09','2-HIGH','Clerk#000000510',0,'furiously regular accounts eat across the carefully ');
38+
INSERT INTO `orders` VALUES (593860,13318,'O',18413.14,'1998-01-10','2-HIGH','Clerk#000000673',0,'pending pains cajole furiously alo');
39+
INSERT INTO `orders` VALUES (593861,1175,'O',28859.21,'1996-09-10','4-NOT SPECIFIED','Clerk#000000680',0,'carefully silent instructi');
40+
INSERT INTO `orders` VALUES (593862,7787,'F',202891.72,'1992-02-27','5-LOW','Clerk#000000988',0,'slyly express requests sleep. express dependencies wake bli');
41+
INSERT INTO `orders` VALUES (593863,1897,'O',33062.05,'1998-06-29','1-URGENT','Clerk#000000117',0,'accounts integrate carefully across the fluffily even warhorses');
42+
INSERT INTO `orders` VALUES (593888,5656,'O',20952.26,'1997-02-04','3-MEDIUM','Clerk#000000735',0,'requests could have to cajole about the special, final ');
43+
INSERT INTO `orders` VALUES (593889,2692,'F',282718.42,'1992-08-02','4-NOT SPECIFIED','Clerk#000000669',0,'regular deposits haggle fluff');
44+
INSERT INTO `orders` VALUES (593890,3685,'O',34012.74,'1996-06-17','5-LOW','Clerk#000000993',0,'furiously even requests');
45+
INSERT INTO `orders` VALUES (593891,10333,'F',182791.4,'1993-01-23','4-NOT SPECIFIED','Clerk#000000098',0,'slyly final platelets doubt');
46+
INSERT INTO `orders` VALUES (593892,5687,'F',224381.48,'1994-09-18','2-HIGH','Clerk#000000294',0,'blithely bold epitaphs sleep after the carefully express in');
47+
INSERT INTO `orders` VALUES (593893,5437,'F',124300.91,'1993-08-04','4-NOT SPECIFIED','Clerk#000000302',0,'daring instructions alongside of the si');
48+
INSERT INTO `orders` VALUES (593894,1732,'F',150438.64,'1993-11-07','3-MEDIUM','Clerk#000000046',0,'quickly special accounts integrate by the even, dogged platelets? slowly ');
49+
INSERT INTO `orders` VALUES (593895,12230,'O',47380.97,'1997-03-23','2-HIGH','Clerk#000000168',0,'fluffily permanent instructions alongside of the furiously even pack');
50+
INSERT INTO `orders` VALUES (593920,13871,'F',2919.68,'1992-01-29','5-LOW','Clerk#000000597',0,'quickly regular foxes across the furiously bold accounts wake car');
51+
INSERT INTO `orders` VALUES (593921,6664,'F',139065.79,'1992-04-21','5-LOW','Clerk#000000017',0,'fluffily final deposits are carefully. quickly special pinto beans bel');
52+
INSERT INTO `orders` VALUES (593922,2504,'O',179041.45,'1997-04-05','2-HIGH','Clerk#000000902',0,'final pinto beans are furiously. ');
53+
INSERT INTO `orders` VALUES (593923,4978,'O',258843,'1998-02-27','1-URGENT','Clerk#000000654',0,'carefully final asymptotes according to the regular dependencie');
54+
INSERT INTO `orders` VALUES (593924,7550,'O',232280.81,'1995-10-28','3-MEDIUM','Clerk#000000063',0,'fluffily ironic packages haggle carefully pending platelets. q');
55+
INSERT INTO `orders` VALUES (593925,12226,'O',319755.48,'1995-09-01','3-MEDIUM','Clerk#000000308',0,'quickly pending packages throughout the quickly unusual requests');
56+
INSERT INTO `orders` VALUES (593926,2819,'F',204662.4,'1994-11-07','4-NOT SPECIFIED','Clerk#000000298',0,'blithely special grouches cajole ironic instructions. slyly pendin');
57+
INSERT INTO `orders` VALUES (593927,593,'F',188162.64,'1995-03-04','1-URGENT','Clerk#000000263',0,'express, unusual deposits boost furiously after the unusual dolphi');
58+
INSERT INTO `orders` VALUES (593952,9362,'P',318688.16,'1995-03-05','4-NOT SPECIFIED','Clerk#000000468',0,'ruthless requests must have to are carefully? special pa');
59+
INSERT INTO `orders` VALUES (593953,11410,'O',166717.28,'1998-07-29','5-LOW','Clerk#000000509',0,'even, regular instructions snooze. slyly ironic packages nag fluffily.');
60+
INSERT INTO `orders` VALUES (593954,8875,'O',132909.37,'1996-08-29','3-MEDIUM','Clerk#000000825',0,'special decoys integrate carefully. care');
61+
INSERT INTO `orders` VALUES (593955,12494,'O',73329.07,'1995-08-05','1-URGENT','Clerk#000000561',0,'quickly special request');
62+
INSERT INTO `orders` VALUES (593956,1390,'O',187837.11,'1995-10-17','5-LOW','Clerk#000000797',0,'silent, pending foxes');
63+
INSERT INTO `orders` VALUES (593957,10106,'F',196969.46,'1993-04-03','2-HIGH','Clerk#000000566',0,'blithely ruthless excuses boost slyly about the requests. careful');
64+
INSERT INTO `orders` VALUES (593958,14770,'F',103528.82,'1993-12-27','3-MEDIUM','Clerk#000000598',0,'carefully special deposits eat above the q');
65+
INSERT INTO `orders` VALUES (593959,14566,'O',156600.32,'1996-11-16','2-HIGH','Clerk#000000030',0,'accounts are quickly bold packages. carefully ironic depos');
66+
INSERT INTO `orders` VALUES (593984,4924,'O',47149.15,'1995-05-06','3-MEDIUM','Clerk#000000120',0,'regular asymptotes haggle slyly abo');
67+
INSERT INTO `orders` VALUES (593985,5185,'O',152533.91,'1997-08-04','3-MEDIUM','Clerk#000000575',0,'blithely special dolphins are even requests. carefully eve');
68+
INSERT INTO `orders` VALUES (593986,14257,'O',109734.28,'1998-06-05','3-MEDIUM','Clerk#000000930',0,'carefully final instructions against the slyly');
69+
INSERT INTO `orders` VALUES (593987,5818,'F',64541.52,'1994-04-13','3-MEDIUM','Clerk#000000259',0,'slyly pending deposits are furiously. regular requests h');
70+
INSERT INTO `orders` VALUES (593988,1178,'F',249608.42,'1994-10-01','2-HIGH','Clerk#000000266',0,'fluffily regular foxes toward the furiously bold accounts sleep furiously');
71+
INSERT INTO `orders` VALUES (593989,5173,'P',61508.55,'1995-03-02','2-HIGH','Clerk#000000374',0,'slyly express deposits wake between ');
72+
INSERT INTO `orders` VALUES (593990,8395,'O',129696.17,'1997-12-30','4-NOT SPECIFIED','Clerk#000000570',0,'carefully final requests haggle furiously fluffily final accou');
73+
INSERT INTO `orders` VALUES (593991,1894,'O',145691.27,'1998-04-09','5-LOW','Clerk#000000294',0,'slyly final notornis haggle carefull');
74+
INSERT INTO `orders` VALUES (594016,14935,'F',144592.29,'1992-10-20','3-MEDIUM','Clerk#000000602',0,'furiously express ideas cajole quickl');
75+
INSERT INTO `orders` VALUES (594017,892,'F',147267.55,'1994-12-10','1-URGENT','Clerk#000000419',0,'close, pending packages affix blithely. slyly regular reque');
76+
end;
77+
//
78+
call add_data();
79+
call add_data();
80+
set sort_buffer_size = 1024;
81+
flush status;
82+
select o_custkey, Avg(o_custkey) OVER ( ORDER BY o_custkey ) from orders;
83+
o_custkey Avg(o_custkey) OVER ( ORDER BY o_custkey )
84+
593 593
85+
593 593
86+
892 742.5
87+
892 742.5
88+
1175 886.6666666666666
89+
1175 886.6666666666666
90+
1178 959.5
91+
1178 959.5
92+
1390 1045.6
93+
1390 1045.6
94+
1613 1140.1666666666667
95+
1613 1140.1666666666667
96+
1732 1224.7142857142858
97+
1732 1224.7142857142858
98+
1828 1300.125
99+
1828 1300.125
100+
1894 1366.111111111111
101+
1894 1366.111111111111
102+
1897 1419.2
103+
1897 1419.2
104+
2504 1517.8181818181818
105+
2504 1517.8181818181818
106+
2692 1615.6666666666667
107+
2692 1615.6666666666667
108+
2819 1708.2307692307693
109+
2819 1708.2307692307693
110+
3220 1816.2142857142858
111+
3220 1816.2142857142858
112+
3316 1916.2
113+
3316 1916.2
114+
3685 2026.75
115+
3685 2026.75
116+
4418 2167.4117647058824
117+
4418 2167.4117647058824
118+
4681 2307.0555555555557
119+
4681 2307.0555555555557
120+
4924 2444.7894736842104
121+
4924 2444.7894736842104
122+
4978 2571.45
123+
4978 2571.45
124+
5173 2695.3333333333335
125+
5173 2695.3333333333335
126+
5185 2808.5
127+
5185 2808.5
128+
5437 2922.782608695652
129+
5437 2922.782608695652
130+
5623 3035.2916666666665
131+
5623 3035.2916666666665
132+
5656 3140.12
133+
5656 3140.12
134+
5687 3238.076923076923
135+
5687 3238.076923076923
136+
5818 3333.6296296296296
137+
5818 3333.6296296296296
138+
6664 3452.5714285714284
139+
6664 3452.5714285714284
140+
6839 3569.344827586207
141+
6839 3569.344827586207
142+
6958 3682.3
143+
6958 3682.3
144+
7213 3796.1935483870966
145+
7213 3796.1935483870966
146+
7550 3913.5
147+
7550 3913.5
148+
7787 4030.878787878788
149+
7787 4030.878787878788
150+
8101 4150.588235294118
151+
8101 4150.588235294118
152+
8395 4271.857142857143
153+
8395 4271.857142857143
154+
8780 4397.083333333333
155+
8780 4397.083333333333
156+
8875 4518.108108108108
157+
8875 4518.108108108108
158+
9362 4645.578947368421
159+
9362 4645.578947368421
160+
10106 4785.589743589743
161+
10106 4785.589743589743
162+
10333 4924.275
163+
10333 4924.275
164+
10486 5059.926829268293
165+
10486 5059.926829268293
166+
11410 5211.119047619048
167+
11410 5211.119047619048
168+
12013 5369.302325581395
169+
12013 5369.302325581395
170+
12226 5525.136363636364
171+
12226 5525.136363636364
172+
12230 5674.133333333333
173+
12230 5674.133333333333
174+
12494 5822.391304347826
175+
12494 5822.391304347826
176+
12976 5974.595744680851
177+
12976 5974.595744680851
178+
13318 6127.583333333333
179+
13318 6127.583333333333
180+
13871 6285.6122448979595
181+
13871 6285.6122448979595
182+
14107 6442.04
183+
14107 6442.04
184+
14116 6592.509803921569
185+
14116 6592.509803921569
186+
14257 6739.903846153846
187+
14257 6739.903846153846
188+
14566 6887.566037735849
189+
14566 6887.566037735849
190+
14605 7030.481481481482
191+
14605 7030.481481481482
192+
14755 7170.927272727273
193+
14755 7170.927272727273
194+
14770 7306.625
195+
14770 7306.625
196+
14935 7440.456140350877
197+
14935 7440.456140350877
198+
select variable_name,
199+
case when variable_value > 0 then 'WITH PASSES' else 'NO PASSES' end
200+
from information_schema.session_status
201+
where variable_name like 'Sort_merge_passes';
202+
variable_name case when variable_value > 0 then 'WITH PASSES' else 'NO PASSES' end
203+
SORT_MERGE_PASSES WITH PASSES
204+
flush status;
205+
select o_custkey, Avg(o_custkey) OVER ( ORDER BY o_custkey RANGE CURRENT ROW ) from orders;
206+
o_custkey Avg(o_custkey) OVER ( ORDER BY o_custkey RANGE CURRENT ROW )
207+
593 593
208+
593 593
209+
892 892
210+
892 892
211+
1175 1175
212+
1175 1175
213+
1178 1178
214+
1178 1178
215+
1390 1390
216+
1390 1390
217+
1613 1613
218+
1613 1613
219+
1732 1732
220+
1732 1732
221+
1828 1828
222+
1828 1828
223+
1894 1894
224+
1894 1894
225+
1897 1897
226+
1897 1897
227+
2504 2504
228+
2504 2504
229+
2692 2692
230+
2692 2692
231+
2819 2819
232+
2819 2819
233+
3220 3220
234+
3220 3220
235+
3316 3316
236+
3316 3316
237+
3685 3685
238+
3685 3685
239+
4418 4418
240+
4418 4418
241+
4681 4681
242+
4681 4681
243+
4924 4924
244+
4924 4924
245+
4978 4978
246+
4978 4978
247+
5173 5173
248+
5173 5173
249+
5185 5185
250+
5185 5185
251+
5437 5437
252+
5437 5437
253+
5623 5623
254+
5623 5623
255+
5656 5656
256+
5656 5656
257+
5687 5687
258+
5687 5687
259+
5818 5818
260+
5818 5818
261+
6664 6664
262+
6664 6664
263+
6839 6839
264+
6839 6839
265+
6958 6958
266+
6958 6958
267+
7213 7213
268+
7213 7213
269+
7550 7550
270+
7550 7550
271+
7787 7787
272+
7787 7787
273+
8101 8101
274+
8101 8101
275+
8395 8395
276+
8395 8395
277+
8780 8780
278+
8780 8780
279+
8875 8875
280+
8875 8875
281+
9362 9362
282+
9362 9362
283+
10106 10106
284+
10106 10106
285+
10333 10333
286+
10333 10333
287+
10486 10486
288+
10486 10486
289+
11410 11410
290+
11410 11410
291+
12013 12013
292+
12013 12013
293+
12226 12226
294+
12226 12226
295+
12230 12230
296+
12230 12230
297+
12494 12494
298+
12494 12494
299+
12976 12976
300+
12976 12976
301+
13318 13318
302+
13318 13318
303+
13871 13871
304+
13871 13871
305+
14107 14107
306+
14107 14107
307+
14116 14116
308+
14116 14116
309+
14257 14257
310+
14257 14257
311+
14566 14566
312+
14566 14566
313+
14605 14605
314+
14605 14605
315+
14755 14755
316+
14755 14755
317+
14770 14770
318+
14770 14770
319+
14935 14935
320+
14935 14935
321+
select variable_name,
322+
case when variable_value > 0 then 'WITH PASSES' else 'NO PASSES' end
323+
from information_schema.session_status
324+
where variable_name like 'Sort_merge_passes';
325+
variable_name case when variable_value > 0 then 'WITH PASSES' else 'NO PASSES' end
326+
SORT_MERGE_PASSES WITH PASSES
327+
drop table orders;
328+
drop procedure add_data;

0 commit comments

Comments
 (0)