1 /* Copyright (c) 2015, 2021, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software Foundation,
21 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
22
23
24 #include "plugin_psi.h"
25
26 PSI_mutex_key key_GR_LOCK_applier_module_run,
27 key_GR_LOCK_applier_module_suspend,
28 key_GR_LOCK_cert_broadcast_run,
29 key_GR_LOCK_cert_broadcast_dispatcher_run,
30 key_GR_LOCK_certification_info,
31 key_GR_LOCK_cert_members,
32 key_GR_LOCK_channel_observation_list,
33 key_GR_LOCK_delayed_init_run,
34 key_GR_LOCK_delayed_init_server_ready,
35 key_GR_LOCK_group_part_handler_run,
36 key_GR_LOCK_group_part_handler_abort,
37 key_GR_LOCK_view_modification_wait,
38 key_GR_LOCK_group_info_manager,
39 key_GR_LOCK_pipeline_continuation,
40 key_GR_LOCK_synchronized_queue,
41 key_GR_LOCK_count_down_latch,
42 key_GR_LOCK_wait_ticket,
43 key_GR_LOCK_recovery_module_run,
44 key_GR_LOCK_recovery,
45 key_GR_LOCK_recovery_donor_selection,
46 key_GR_LOCK_session_thread_method_exec,
47 key_GR_LOCK_session_thread_run,
48 key_GR_LOCK_plugin_running,
49 key_GR_LOCK_force_members_running,
50 key_GR_LOCK_write_lock_protection,
51 key_GR_LOCK_pipeline_stats_flow_control,
52 key_GR_LOCK_pipeline_stats_transactions_waiting_apply,
53 key_GR_LOCK_trx_unlocking;
54
55 PSI_cond_key key_GR_COND_applier_module_run,
56 key_GR_COND_applier_module_suspend,
57 key_GR_COND_applier_module_wait,
58 key_GR_COND_cert_broadcast_run,
59 key_GR_COND_cert_broadcast_dispatcher_run,
60 key_GR_COND_delayed_init_run,
61 key_GR_COND_delayed_init_server_ready,
62 key_GR_COND_group_part_handler_run,
63 key_GR_COND_group_part_handler_abort,
64 key_GR_COND_view_modification_wait,
65 key_GR_COND_pipeline_continuation,
66 key_GR_COND_synchronized_queue,
67 key_GR_COND_count_down_latch,
68 key_GR_COND_wait_ticket,
69 key_GR_COND_recovery_module_run,
70 key_GR_COND_recovery,
71 key_GR_COND_session_thread_method_exec,
72 key_GR_COND_session_thread_run,
73 key_GR_COND_pipeline_stats_flow_control;
74
75 PSI_thread_key key_GR_THD_applier_module_receiver,
76 key_GR_THD_cert_broadcast,
77 key_GR_THD_delayed_init,
78 key_GR_THD_plugin_session,
79 key_GR_THD_group_partition_handler,
80 key_GR_THD_recovery;
81
82 PSI_rwlock_key key_GR_RWLOCK_cert_stable_gtid_set,
83 key_GR_RWLOCK_io_cache_unused_list,
84 key_GR_RWLOCK_plugin_stop,
85 key_GR_RWLOCK_gcs_operations;
86
87 #ifdef HAVE_PSI_INTERFACE
88 static PSI_mutex_info all_group_replication_psi_mutex_keys[]=
89 {
90 {&key_GR_LOCK_applier_module_run, "LOCK_applier_module_run", PSI_FLAG_GLOBAL},
91 {&key_GR_LOCK_applier_module_suspend, "LOCK_applier_module_suspend", PSI_FLAG_GLOBAL},
92 {&key_GR_LOCK_cert_broadcast_run, "LOCK_certifier_broadcast_run", PSI_FLAG_GLOBAL},
93 {&key_GR_LOCK_cert_broadcast_dispatcher_run, "LOCK_certifier_broadcast_dispatcher_run", PSI_FLAG_GLOBAL},
94 {&key_GR_LOCK_certification_info, "LOCK_certification_info", PSI_FLAG_GLOBAL},
95 {&key_GR_LOCK_cert_members, "LOCK_certification_members", PSI_FLAG_GLOBAL},
96 {&key_GR_LOCK_channel_observation_list, "LOCK_channel_observation_list", PSI_FLAG_GLOBAL},
97 {&key_GR_LOCK_delayed_init_run, "LOCK_delayed_init_run", PSI_FLAG_GLOBAL},
98 {&key_GR_LOCK_delayed_init_server_ready, "LOCK_delayed_init_server_ready", PSI_FLAG_GLOBAL},
99 {&key_GR_LOCK_group_part_handler_run, "key_GR_LOCK_group_part_handler_run", PSI_FLAG_GLOBAL},
100 {&key_GR_LOCK_group_part_handler_abort, "key_GR_LOCK_group_part_handler_abort", PSI_FLAG_GLOBAL},
101 {&key_GR_LOCK_view_modification_wait, "LOCK_view_modification_wait", PSI_FLAG_GLOBAL},
102 {&key_GR_LOCK_group_info_manager, "LOCK_group_info_manager", PSI_FLAG_GLOBAL},
103 {&key_GR_LOCK_pipeline_continuation, "LOCK_pipeline_continuation", PSI_FLAG_GLOBAL},
104 {&key_GR_LOCK_synchronized_queue, "LOCK_synchronized_queue", PSI_FLAG_GLOBAL},
105 {&key_GR_LOCK_count_down_latch, "LOCK_count_down_latch", PSI_FLAG_GLOBAL},
106 {&key_GR_LOCK_wait_ticket, "LOCK_wait_ticket", PSI_FLAG_GLOBAL},
107 {&key_GR_LOCK_recovery_module_run, "LOCK_recovery_module_run", PSI_FLAG_GLOBAL},
108 {&key_GR_LOCK_recovery, "LOCK_recovery", PSI_FLAG_GLOBAL},
109 {&key_GR_LOCK_recovery_donor_selection, "LOCK_recovery_donor_selection", PSI_FLAG_GLOBAL},
110 {&key_GR_LOCK_session_thread_method_exec, "LOCK_session_thread_method_exec", PSI_FLAG_GLOBAL},
111 {&key_GR_LOCK_session_thread_run, "LOCK_session_thread_run", PSI_FLAG_GLOBAL},
112 {&key_GR_LOCK_plugin_running, "LOCK_plugin_running", PSI_FLAG_GLOBAL},
113 {&key_GR_LOCK_force_members_running, "LOCK_force_members_running", PSI_FLAG_GLOBAL},
114 {&key_GR_LOCK_write_lock_protection, "LOCK_write_lock_protection", PSI_FLAG_GLOBAL},
115 {&key_GR_LOCK_pipeline_stats_flow_control, "LOCK_pipeline_stats_flow_control", PSI_FLAG_GLOBAL},
116 {&key_GR_LOCK_pipeline_stats_transactions_waiting_apply, "LOCK_pipeline_stats_transactions_waiting_apply", PSI_FLAG_GLOBAL},
117 {&key_GR_LOCK_trx_unlocking, "LOCK_transaction_unblocking", PSI_FLAG_GLOBAL}
118 };
119
120 static PSI_cond_info all_group_replication_psi_condition_keys[]=
121 {
122 {&key_GR_COND_applier_module_run, "COND_applier_module_run", PSI_FLAG_GLOBAL},
123 {&key_GR_COND_applier_module_suspend, "COND_applier_module_suspend", PSI_FLAG_GLOBAL},
124 {&key_GR_COND_applier_module_wait, "COND_applier_module_wait", PSI_FLAG_GLOBAL},
125 {&key_GR_COND_cert_broadcast_run, "COND_certifier_broadcast_run", PSI_FLAG_GLOBAL},
126 {&key_GR_COND_cert_broadcast_dispatcher_run, "COND_certifier_broadcast_dispatcher_run", PSI_FLAG_GLOBAL},
127 {&key_GR_COND_delayed_init_run, "COND_delayed_init_run", PSI_FLAG_GLOBAL},
128 {&key_GR_COND_delayed_init_server_ready, "COND_delayed_init_server_ready", PSI_FLAG_GLOBAL},
129 {&key_GR_LOCK_group_part_handler_run, "COND_group_part_handler_run", PSI_FLAG_GLOBAL},
130 {&key_GR_LOCK_group_part_handler_abort, "COND_group_part_handler_abort", PSI_FLAG_GLOBAL},
131 {&key_GR_COND_view_modification_wait, "COND_view_modification_wait", PSI_FLAG_GLOBAL},
132 {&key_GR_COND_pipeline_continuation, "COND_pipeline_continuation", PSI_FLAG_GLOBAL},
133 {&key_GR_COND_synchronized_queue, "COND_synchronized_queue", PSI_FLAG_GLOBAL},
134 {&key_GR_COND_count_down_latch, "COND_count_down_latch", PSI_FLAG_GLOBAL},
135 {&key_GR_COND_wait_ticket, "COND_wait_ticket", PSI_FLAG_GLOBAL},
136 {&key_GR_COND_recovery_module_run, "COND_recovery_module_run", PSI_FLAG_GLOBAL},
137 {&key_GR_COND_recovery, "COND_recovery", PSI_FLAG_GLOBAL},
138 {&key_GR_COND_session_thread_method_exec, "COND_session_thread_method_exec", PSI_FLAG_GLOBAL},
139 {&key_GR_COND_session_thread_run, "COND_session_thread_run", PSI_FLAG_GLOBAL},
140 {&key_GR_COND_pipeline_stats_flow_control, "COND_pipeline_stats_flow_control", PSI_FLAG_GLOBAL},
141 };
142
143 static PSI_thread_info all_group_replication_psi_thread_keys[]=
144 {
145 {&key_GR_THD_applier_module_receiver, "THD_applier_module_receiver", PSI_FLAG_GLOBAL},
146 {&key_GR_THD_cert_broadcast, "THD_certifier_broadcast", PSI_FLAG_GLOBAL},
147 {&key_GR_THD_delayed_init, "THD_delayed_initialization", PSI_FLAG_GLOBAL},
148 {&key_GR_THD_plugin_session, "THD_plugin_server_session", PSI_FLAG_GLOBAL},
149 {&key_GR_THD_group_partition_handler, "THD_group_partition_handler", PSI_FLAG_GLOBAL},
150 {&key_GR_THD_recovery, "THD_recovery", PSI_FLAG_GLOBAL}
151 };
152
153 static PSI_rwlock_info all_group_replication_psi_rwlock_keys[]=
154 {
155 {&key_GR_RWLOCK_cert_stable_gtid_set, "RWLOCK_certifier_stable_gtid_set", PSI_FLAG_GLOBAL},
156 {&key_GR_RWLOCK_io_cache_unused_list , "RWLOCK_io_cache_unused_list", PSI_FLAG_GLOBAL},
157 {&key_GR_RWLOCK_plugin_stop, "RWLOCK_plugin_stop", PSI_FLAG_GLOBAL},
158 {&key_GR_RWLOCK_gcs_operations, "RWLOCK_gcs_operations", PSI_FLAG_GLOBAL}
159 };
160
register_group_replication_mutex_psi_keys(PSI_mutex_info mutexes[],size_t mutex_count)161 void register_group_replication_mutex_psi_keys(PSI_mutex_info mutexes[],
162 size_t mutex_count)
163 {
164 const char* category= "group_rpl";
165 if (mutexes != NULL)
166 {
167 mysql_mutex_register(category, mutexes, static_cast<int>(mutex_count));
168 }
169 }
170
register_group_replication_cond_psi_keys(PSI_cond_info conds[],size_t cond_count)171 void register_group_replication_cond_psi_keys(PSI_cond_info conds[],
172 size_t cond_count)
173 {
174 const char* category= "group_rpl";
175 if (conds != NULL)
176 {
177 mysql_cond_register(category, conds, static_cast<int>(cond_count));
178 }
179 }
180
register_group_replication_thread_psi_keys(PSI_thread_info threads[],size_t thread_count)181 void register_group_replication_thread_psi_keys(PSI_thread_info threads[],
182 size_t thread_count)
183 {
184 const char* category= "group_rpl";
185 if (threads != NULL)
186 {
187 mysql_thread_register(category, threads, static_cast<int>(thread_count));
188 }
189 }
190
register_group_replication_rwlock_psi_keys(PSI_rwlock_info * keys,size_t count)191 void register_group_replication_rwlock_psi_keys(PSI_rwlock_info *keys,
192 size_t count)
193 {
194 const char *category= "group_rpl";
195 mysql_rwlock_register(category, keys, static_cast<int>(count));
196 }
197
register_all_group_replication_psi_keys()198 void register_all_group_replication_psi_keys()
199 {
200 register_group_replication_mutex_psi_keys(all_group_replication_psi_mutex_keys,
201 array_elements(all_group_replication_psi_mutex_keys));
202 register_group_replication_cond_psi_keys(all_group_replication_psi_condition_keys,
203 array_elements(all_group_replication_psi_condition_keys));
204 register_group_replication_thread_psi_keys(all_group_replication_psi_thread_keys,
205 array_elements(all_group_replication_psi_thread_keys));
206 register_group_replication_rwlock_psi_keys(all_group_replication_psi_rwlock_keys,
207 array_elements(all_group_replication_psi_rwlock_keys));
208 }
209
210 #endif
211