Commit b4287f9
committed
Bug#23550835 ITERATING ON A FULL PERFORMANCE SCHEMA BUFFER CAN CRASH
Before this fix, a SELECT on performance schema tables could crash
the server, when an internal buffer is full.
This could happen for example with:
- more than 2^20 tables
- more than 2^20 indexes
- more than 2^20 files
The immediate root cause is that using PFS_buffer_scalable_iterator
on a full buffer causes an overflow in
PFS_buffer_scalable_container::scan_next(),
by accessing a page outside of m_pages[]
This has been fixed by changing the do {} while loop
into a while {} loop.
For robustness, other do while loops have been
changed to use the same while {} pattern,
which is more tolerant to edge cases,
and therefore less risky for maintenance.
While investigating this issue, another case of overflow was found
in the code: every page in the scalable buffer is of size PFS_PAGE_SIZE,
** except ** the last page, which can be smaller, due to m_last_page_size.
The problem is that every code that iterate on pages,
for example PFS_buffer_scalable_container::apply(),
expects page to have a size of PFS_PAGE_SIZE,
and cause corruption when using a partial last page.
The fix is to:
- make each page aware of its own size, with
PFS_buffer_default_array::m_max,
- iterate from PFS_buffer_default_array::get_first()
to PFS_buffer_default_array::get_last(),
instead of using [0, PFS_PAGE_SIZE[
Also, logic for iterators need to be aware of partial pages,
with tests such as "if (index_2 >= page->m_max)",
in PFS_buffer_scalable_container::get().
Lastly, the hard coded theoretical size limit on some buffers
has been raised, since it was reached in practice for some workloads.
New limits are:
- 16 million instrumented tables (2^24), increased from 1M (2^20)
- 64 million instrumented indexes (2^26), increased from 1M (2^20)
- 16 million instrumented files (2^24), increased from 1M (2^20)1 parent a574ded commit b4287f9
File tree
2 files changed
+104
-71
lines changed- storage/perfschema
2 files changed
+104
-71
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
168 | 169 | | |
169 | 170 | | |
170 | 171 | | |
171 | | - | |
| 172 | + | |
172 | 173 | | |
| 174 | + | |
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
| |||
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
212 | | - | |
| 214 | + | |
213 | 215 | | |
| 216 | + | |
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
| |||
316 | 319 | | |
317 | 320 | | |
318 | 321 | | |
319 | | - | |
| 322 | + | |
320 | 323 | | |
| 324 | + | |
321 | 325 | | |
322 | 326 | | |
323 | 327 | | |
| |||
357 | 361 | | |
358 | 362 | | |
359 | 363 | | |
360 | | - | |
| 364 | + | |
361 | 365 | | |
| 366 | + | |
362 | 367 | | |
363 | 368 | | |
364 | 369 | | |
| |||
614 | 619 | | |
615 | 620 | | |
616 | 621 | | |
617 | | - | |
| 622 | + | |
618 | 623 | | |
| 624 | + | |
619 | 625 | | |
620 | 626 | | |
621 | 627 | | |
| |||
718 | 724 | | |
719 | 725 | | |
720 | 726 | | |
721 | | - | |
| 727 | + | |
722 | 728 | | |
| 729 | + | |
723 | 730 | | |
724 | 731 | | |
725 | 732 | | |
| |||
825 | 832 | | |
826 | 833 | | |
827 | 834 | | |
828 | | - | |
| 835 | + | |
829 | 836 | | |
| 837 | + | |
830 | 838 | | |
831 | 839 | | |
832 | 840 | | |
| |||
0 commit comments