Commit 6882beb
committed
Bug#14113704 - A STAT ON A NON EXISTING FILE CREATING A FILE RECORD IN PFS
Before this fix, the file io instrumentation for the performance schema
would instrument some operations as follows:
- For FILE_STAT, a file instrument was created before the actual call to
my_file_stat.
- For FILE_OPEN, FILE_STREAM_OPEN, a file instrument was also created
before the actual file open call.
- For FILE_DELETE, a file instrument was possibly created before the
actual call, only to be destroyed after the call.
In general, this "optimistic" approach leads to several problems.
When the actual call to open(), fopen() or stat() fails, the instrumented
file that was created needs to be cleaned up.
At best, this creates some performance overhead.
At worst, this creates instrumentation leaks when the cleanup code is missing,
as found initially with the FILE_STAT operation.
In addition, attempting to create / destroy file instrumentations in several
threads executing open / close / stat / delete on the same file concurrently
has a high risk of creating race conditions inside the file instrumentation,
even when such race conditions do not exist in the code instrumented.
The solution is to never create files optimistically in a "start" event
(before the operation), but do create file instrumentation in the "end" event
only, and only if the operation actually succeeded.
Specific changes:
- move the find_or_create_file() call from start_file_open_wait() to end_file_open_wait()
- add a name / class member to the file locker state, to hold parameters until the call
to find_or_create_file()
- remove all file creation / deletion logic present in start_file_wait() and end_file_wait(),
for both clarity and performances
- create new start_file_close_wait() and end_file_close_wait() instrumentation points,
used when closing / deleting files.
- created find_file(), to be used when instrumenting FILE_DELETE: if the file is not known,
there is no point in creating instrumentation only to remove it after the operation.1 parent 408ef21 commit 6882beb
File tree
8 files changed
+314
-79
lines changed- include/mysql/psi
- mysys
- storage/perfschema
- unittest
8 files changed
+314
-79
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
813 | 813 | | |
814 | 814 | | |
815 | 815 | | |
816 | | - | |
| 816 | + | |
817 | 817 | | |
818 | 818 | | |
819 | | - | |
| 819 | + | |
820 | 820 | | |
821 | 821 | | |
822 | 822 | | |
| |||
854 | 854 | | |
855 | 855 | | |
856 | 856 | | |
857 | | - | |
| 857 | + | |
858 | 858 | | |
859 | | - | |
| 859 | + | |
860 | 860 | | |
861 | 861 | | |
862 | 862 | | |
| |||
1069 | 1069 | | |
1070 | 1070 | | |
1071 | 1071 | | |
1072 | | - | |
| 1072 | + | |
1073 | 1073 | | |
1074 | | - | |
| 1074 | + | |
1075 | 1075 | | |
1076 | 1076 | | |
1077 | 1077 | | |
| |||
1271 | 1271 | | |
1272 | 1272 | | |
1273 | 1273 | | |
1274 | | - | |
| 1274 | + | |
1275 | 1275 | | |
1276 | | - | |
| 1276 | + | |
1277 | 1277 | | |
1278 | 1278 | | |
1279 | 1279 | | |
| |||
1352 | 1352 | | |
1353 | 1353 | | |
1354 | 1354 | | |
1355 | | - | |
| 1355 | + | |
1356 | 1356 | | |
1357 | | - | |
| 1357 | + | |
1358 | 1358 | | |
1359 | 1359 | | |
1360 | 1360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
899 | 899 | | |
900 | 900 | | |
901 | 901 | | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
902 | 906 | | |
903 | 907 | | |
904 | 908 | | |
| |||
1575 | 1579 | | |
1576 | 1580 | | |
1577 | 1581 | | |
1578 | | - | |
1579 | 1582 | | |
1580 | | - | |
| 1583 | + | |
1581 | 1584 | | |
1582 | 1585 | | |
1583 | 1586 | | |
1584 | 1587 | | |
1585 | 1588 | | |
| 1589 | + | |
| 1590 | + | |
1586 | 1591 | | |
1587 | | - | |
1588 | | - | |
| 1592 | + | |
| 1593 | + | |
1589 | 1594 | | |
1590 | 1595 | | |
1591 | 1596 | | |
| |||
1622 | 1627 | | |
1623 | 1628 | | |
1624 | 1629 | | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
1625 | 1649 | | |
1626 | 1650 | | |
1627 | 1651 | | |
| |||
2025 | 2049 | | |
2026 | 2050 | | |
2027 | 2051 | | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
2028 | 2056 | | |
2029 | 2057 | | |
2030 | 2058 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
224 | 226 | | |
225 | 227 | | |
226 | 228 | | |
| |||
422 | 424 | | |
423 | 425 | | |
424 | 426 | | |
425 | | - | |
| 427 | + | |
426 | 428 | | |
427 | | - | |
428 | | - | |
| 429 | + | |
| 430 | + | |
429 | 431 | | |
430 | 432 | | |
431 | 433 | | |
432 | 434 | | |
433 | 435 | | |
434 | 436 | | |
435 | 437 | | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
436 | 442 | | |
437 | 443 | | |
438 | 444 | | |
| |||
571 | 577 | | |
572 | 578 | | |
573 | 579 | | |
| 580 | + | |
| 581 | + | |
574 | 582 | | |
575 | 583 | | |
576 | 584 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | | - | |
406 | | - | |
407 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
408 | 408 | | |
409 | | - | |
| 409 | + | |
410 | 410 | | |
411 | 411 | | |
412 | | - | |
413 | | - | |
| 412 | + | |
| 413 | + | |
414 | 414 | | |
415 | | - | |
| 415 | + | |
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
| |||
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
438 | 451 | | |
439 | 452 | | |
440 | 453 | | |
| |||
698 | 711 | | |
699 | 712 | | |
700 | 713 | | |
| 714 | + | |
| 715 | + | |
701 | 716 | | |
702 | 717 | | |
703 | 718 | | |
| |||
0 commit comments