Commit 1badccd
Bug#36846567 Inplace ALTER TABLE might cause lost rows if concurrent purge [Post-push fix]
Bug#37318367 Inplace ALTER on table with spatial idx might cause lost rows if concurrent purge [Post-push fix]
Description:
------------
This is post push fix of the above Bugs. There is another method
PCursor::move_to_next_block() where the scan is paused and latches are
released. This method was missed to be addressed, as a result
ALTER TABLE rebuild might lose records if latches are released in
this case.
Background:
-----------
When doing a parallel scan, Parallel_reader::Ctx::traverse() calls
Parallel_reader::Ctx::traverse_recs() which does:
```
/* Note: The page end callback (above) can save and restore the cursor.
The restore can end up in the middle of a page. */
if (pcursor->is_after_last_on_page() && !move_to_next_node(pcursor)) {
break;
}
```
Where Parallel_reader::Ctx::move_to_next_node() calls
PCursor::move_to_next_block which uses PCursor::savepoint() and
PCursor::restore_from_savepoint().
These functions are known to have problems which were addressed in the
recent bug fixes, but they missed to fix this particular code path.
The reason for that omission was that the PCursor::move_to_next_block()
is also used during SELECT COUNT(*) at internal level (above leaves) for
which the solution employed for ALTER will not work, because B-tree
navigation functions do not support the required comparison mode when
searching to non-leaf level.
Fix:
----
This patch carves out the part of PCursor::move_to_next_block() which is
handling the simple leaf-level case, for which it is well known what
should be done: we are at supremum, all previous records were fully
processed, and we should restore the cursor to a user record which is
larger than any processed record. That can be accomplished by using the
recently introduced methods save_previous_user_record_as_last_processed()
and restore_to_first_unprocessed(), with a small adjustment, that here we
require the cursor to be not only after all processed records, but also
on a user record, so in case it is restored to supremum, we should
additionally call move_to_user_rec().
This patch also makes it clear which methods are used, and where, by
removing unused methods, marking some of them as private, and adding
asserts that m_read_level!=0 to those related to SELECT COUNT() only.
Change-Id: I2994374c542e168e0884e947634593ade17495ec1 parent e7456a7 commit 1badccd
File tree
6 files changed
+268
-48
lines changed- mysql-test/suite
- innodb_gis
- r
- t
- innodb
- r
- t
- storage/innobase
- include
- row
6 files changed
+268
-48
lines changedLines changed: 47 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
3 | 10 | | |
4 | 11 | | |
5 | 12 | | |
| |||
10 | 17 | | |
11 | 18 | | |
12 | 19 | | |
13 | | - | |
| 20 | + | |
14 | 21 | | |
15 | 22 | | |
16 | 23 | | |
| |||
20 | 27 | | |
21 | 28 | | |
22 | 29 | | |
| 30 | + | |
23 | 31 | | |
24 | 32 | | |
25 | 33 | | |
| |||
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
31 | | - | |
32 | 39 | | |
33 | 40 | | |
34 | | - | |
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
| |||
43 | 49 | | |
44 | 50 | | |
45 | 51 | | |
46 | | - | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
| |||
53 | 59 | | |
54 | 60 | | |
55 | 61 | | |
| 62 | + | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
| |||
61 | 68 | | |
62 | 69 | | |
63 | 70 | | |
64 | | - | |
65 | 71 | | |
66 | 72 | | |
67 | | - | |
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
| |||
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
79 | | - | |
| 84 | + | |
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
| |||
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
| 94 | + | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
| |||
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
97 | | - | |
98 | 103 | | |
99 | 104 | | |
100 | | - | |
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
| |||
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
112 | | - | |
| 116 | + | |
113 | 117 | | |
114 | 118 | | |
115 | 119 | | |
| |||
119 | 123 | | |
120 | 124 | | |
121 | 125 | | |
| 126 | + | |
122 | 127 | | |
123 | 128 | | |
124 | 129 | | |
| |||
127 | 132 | | |
128 | 133 | | |
129 | 134 | | |
130 | | - | |
131 | 135 | | |
132 | 136 | | |
133 | | - | |
134 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
135 | 167 | | |
136 | 168 | | |
| 169 | + | |
137 | 170 | | |
138 | 171 | | |
139 | 172 | | |
| 173 | + | |
140 | 174 | | |
Lines changed: 92 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
11 | 24 | | |
12 | 25 | | |
13 | 26 | | |
| |||
21 | 34 | | |
22 | 35 | | |
23 | 36 | | |
24 | | - | |
| 37 | + | |
25 | 38 | | |
26 | 39 | | |
27 | 40 | | |
| |||
35 | 48 | | |
36 | 49 | | |
37 | 50 | | |
| 51 | + | |
38 | 52 | | |
39 | 53 | | |
40 | 54 | | |
41 | 55 | | |
42 | | - | |
43 | | - | |
44 | 56 | | |
45 | 57 | | |
46 | | - | |
47 | 58 | | |
48 | 59 | | |
49 | 60 | | |
| |||
60 | 71 | | |
61 | 72 | | |
62 | 73 | | |
63 | | - | |
| 74 | + | |
64 | 75 | | |
65 | 76 | | |
66 | 77 | | |
| |||
74 | 85 | | |
75 | 86 | | |
76 | 87 | | |
| 88 | + | |
77 | 89 | | |
78 | 90 | | |
79 | 91 | | |
80 | 92 | | |
81 | | - | |
82 | | - | |
83 | 93 | | |
84 | 94 | | |
85 | | - | |
86 | 95 | | |
87 | 96 | | |
88 | 97 | | |
| |||
98 | 107 | | |
99 | 108 | | |
100 | 109 | | |
101 | | - | |
| 110 | + | |
102 | 111 | | |
103 | 112 | | |
104 | 113 | | |
| |||
112 | 121 | | |
113 | 122 | | |
114 | 123 | | |
| 124 | + | |
115 | 125 | | |
116 | 126 | | |
117 | 127 | | |
118 | 128 | | |
119 | | - | |
120 | | - | |
121 | 129 | | |
122 | 130 | | |
123 | | - | |
124 | 131 | | |
125 | 132 | | |
126 | 133 | | |
| |||
136 | 143 | | |
137 | 144 | | |
138 | 145 | | |
139 | | - | |
| 146 | + | |
140 | 147 | | |
141 | 148 | | |
142 | 149 | | |
| |||
150 | 157 | | |
151 | 158 | | |
152 | 159 | | |
| 160 | + | |
153 | 161 | | |
154 | 162 | | |
155 | 163 | | |
156 | 164 | | |
157 | | - | |
158 | | - | |
159 | 165 | | |
160 | 166 | | |
161 | | - | |
162 | 167 | | |
163 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
164 | 237 | | |
165 | 238 | | |
| 239 | + | |
166 | 240 | | |
| 241 | + | |
167 | 242 | | |
168 | 243 | | |
169 | 244 | | |
| |||
0 commit comments