mariadb/storage/perfschema
Haidong Ji 03c9a4ef4a MDEV-29091: Correct event_name in PFS for wait caused by FOR UPDATE
When one session SELECT ... FOR UPDATE and holds the lock, subsequent
sessions that SELECT ... FOR UPDATE will wait to get the lock.
Currently, that event is labeled as `wait/io/table/sql/handler`, which
is incorrect. Instead, it should have been
`wait/lock/table/sql/handler`.

Two factors contribute to this bug:
1. Instrumentation interface and the heavy usage of `TABLE_IO_WAIT` in
   `sql/handler.cc` file. See interface [^1] for better understanding;
2. The balancing act [^2] of doing instrumentation aggregration _AND_
   having good performance. For example, EVENTS_WAITS_SUMMARY... is
   aggregated using EVENTS_WAITS_CURRENT. Aggregration needs to be based
   on the same wait class, and the code was overly aggressive in label a
   LOCK operation as an IO operation in this case.

The proposed fix is pretty simple, but understanding the bug took a
while. Hence the footnotes below.  For future improvement and
refactoring, we may want to consider renaming `TABLE_IO_WAIT` and making
it less coarse and more targeted.

Note that newly added test case, events_waits_current_MDEV-29091,
initially didn't pass Buildbot CI for embedded build tests.  Further
research showed that other impacted tests all included not_embedded.inc.
This oversight was fixed later.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license.  I am contributing on behalf of my employer Amazon Web
Services, Inc.

[^1]: To understand `performance_schema` instrumentation interface, I
found this URL is the most helpful:
https://dev.mysql.com/doc/dev/mysql-server/latest/PAGE_PFS_PSI.html
[^2]: The best place to understand instrumentation projection,
composition, and aggregration is through the source file. Although I
prefer reading Doxygen produced html file, but for whatever reason, the
rendering is not ideal. Here is link to 10.6's pfs.cc:
https://github.com/MariaDB/server/blob/10.6/storage/perfschema/pfs.cc
2023-02-15 14:36:05 +00:00
..
unittest Merge 10.3 into 10.4 2022-03-29 11:13:18 +03:00
CMakeLists.txt cleanup: specifying plugin dependencies in CMakeLists.txt 2021-08-03 10:10:00 +02:00
cursor_by_account.cc
cursor_by_account.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
cursor_by_host.cc
cursor_by_host.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
cursor_by_thread.cc
cursor_by_thread.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
cursor_by_thread_connect_attr.cc
cursor_by_thread_connect_attr.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
cursor_by_user.cc
cursor_by_user.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
gen_pfs_lex_token.cc
ha_perfschema.cc Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
ha_perfschema.h Merge branch '10.3' into 10.4 2020-01-21 23:15:02 +01:00
pfs.cc MDEV-29091: Correct event_name in PFS for wait caused by FOR UPDATE 2023-02-15 14:36:05 +00:00
pfs.h Merge branch '10.2' into 10.3 2020-01-21 09:11:14 +01:00
pfs_account.cc
pfs_account.h
pfs_atomic.h
pfs_autosize.cc Merge branch '10.2' into 10.3 2020-01-21 09:11:14 +01:00
pfs_column_types.h
pfs_column_values.cc Merge branch '10.2' into 10.3 2020-01-21 09:11:14 +01:00
pfs_column_values.h Merge branch '10.2' into 10.3 2020-01-21 09:11:14 +01:00
pfs_con_slice.cc
pfs_con_slice.h
pfs_defaults.cc Merge branch '10.2' into 10.3 2020-01-21 09:11:14 +01:00
pfs_defaults.h
pfs_digest.cc Merge branch '10.2' into 10.3 2020-01-21 09:11:14 +01:00
pfs_digest.h Merge branch '10.2' into 10.3 2020-01-21 09:11:14 +01:00
pfs_engine_table.cc Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
pfs_engine_table.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
pfs_events.h
pfs_events_stages.cc
pfs_events_stages.h
pfs_events_statements.cc
pfs_events_statements.h
pfs_events_waits.cc
pfs_events_waits.h
pfs_global.cc Merge branch '10.2' into 10.3 2020-01-21 09:11:14 +01:00
pfs_global.h Merge branch '10.2' into 10.3 2020-01-21 09:11:14 +01:00
pfs_host.cc
pfs_host.h
pfs_instr.cc MDEV-20857: perf schema conflict name filename_hash 2021-02-24 19:45:58 +11:00
pfs_instr.h MDEV-20857: perf schema conflict name filename_hash 2021-02-24 19:45:58 +11:00
pfs_instr_class.cc Merge 10.2 into 10.3 2020-03-13 12:31:55 +02:00
pfs_instr_class.h
pfs_lock.h
pfs_server.cc Merge branch '10.2' into 10.3 2020-01-21 09:11:14 +01:00
pfs_server.h fix perfschema.start_server_innodb test (related to MDEV-17571) 2020-01-24 14:34:07 +01:00
pfs_setup_actor.cc
pfs_setup_actor.h
pfs_setup_object.cc MDEV-22387: Do not violate __attribute__((nonnull)) 2020-11-02 14:19:21 +02:00
pfs_setup_object.h
pfs_stat.h
pfs_timer.cc fix typos 2023-01-12 14:02:20 +11:00
pfs_timer.h Merge branch '10.2' into 10.3 2020-01-21 09:11:14 +01:00
pfs_user.cc
pfs_user.h
pfs_visitor.cc Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
pfs_visitor.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_accounts.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_accounts.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_all_instr.cc
table_all_instr.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_esgs_by_account_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_esgs_by_account_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_esgs_by_host_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_esgs_by_host_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_esgs_by_thread_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_esgs_by_thread_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_esgs_by_user_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_esgs_by_user_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_esgs_global_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_esgs_global_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_esms_by_account_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_esms_by_account_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_esms_by_digest.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_esms_by_digest.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_esms_by_host_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_esms_by_host_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_esms_by_thread_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_esms_by_thread_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_esms_by_user_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_esms_by_user_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_esms_global_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_esms_global_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_events_stages.cc Merge branch '10.2' into 10.3 2021-09-07 16:32:35 +03:00
table_events_stages.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_events_statements.cc Merge branch '10.2' into 10.3 2021-09-07 16:32:35 +03:00
table_events_statements.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_events_waits.cc Merge branch '10.2' into 10.3 2021-09-07 16:32:35 +03:00
table_events_waits.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_events_waits_summary.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_events_waits_summary.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_ews_by_account_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_ews_by_account_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_ews_by_host_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_ews_by_host_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_ews_by_thread_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_ews_by_thread_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_ews_by_user_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_ews_by_user_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_ews_global_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_ews_global_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_file_instances.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_file_instances.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_file_summary_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_file_summary_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_file_summary_by_instance.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_file_summary_by_instance.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_helper.cc
table_helper.h
table_host_cache.cc Merge branch '10.2' into 10.3 2021-09-07 16:32:35 +03:00
table_host_cache.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_hosts.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_hosts.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_os_global_by_type.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_os_global_by_type.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_performance_timers.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_performance_timers.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_session_account_connect_attrs.cc Merge branch '10.2' into 10.3 2021-09-07 16:32:35 +03:00
table_session_account_connect_attrs.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_session_connect.cc Merge branch '10.2' into 10.3 2020-01-21 09:11:14 +01:00
table_session_connect.h
table_session_connect_attrs.cc Merge branch '10.2' into 10.3 2021-09-07 16:32:35 +03:00
table_session_connect_attrs.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_setup_actors.cc Merge remote-tracking branch 'upstream/10.3' into 10.4 2021-09-09 09:23:35 +03:00
table_setup_actors.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_setup_consumers.cc Merge branch '10.2' into 10.3 2021-09-07 16:32:35 +03:00
table_setup_consumers.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_setup_instruments.cc Merge branch '10.2' into 10.3 2021-09-07 16:32:35 +03:00
table_setup_instruments.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_setup_objects.cc Merge remote-tracking branch 'upstream/10.3' into 10.4 2021-09-09 09:23:35 +03:00
table_setup_objects.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_setup_timers.cc Merge branch '10.2' into 10.3 2021-09-07 16:32:35 +03:00
table_setup_timers.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_socket_instances.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_socket_instances.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_socket_summary_by_event_name.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_socket_summary_by_event_name.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_socket_summary_by_instance.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_socket_summary_by_instance.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_sync_instances.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_sync_instances.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_threads.cc Merge branch '10.2' into 10.3 2021-09-07 16:32:35 +03:00
table_threads.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_tiws_by_index_usage.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_tiws_by_index_usage.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_tiws_by_table.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_tiws_by_table.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_tlws_by_table.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_tlws_by_table.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
table_users.cc MDEV-25325 built-in documentation for performance_schema tables 2021-09-07 08:45:19 +03:00
table_users.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00