MySQL  8.0.27
Source Code Documentation
pfs_server.h
Go to the documentation of this file.
1 /* Copyright (c) 2008, 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
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef PFS_SERVER_H
24 #define PFS_SERVER_H
25 
26 /**
27  @file storage/perfschema/pfs_server.h
28  Private interface for the server (declarations).
29 */
30 
31 #include <sys/types.h>
32 
33 #include "my_psi_config.h"
34 #include "mysql/psi/psi_cond.h"
36 #include "mysql/psi/psi_error.h"
37 #include "mysql/psi/psi_file.h"
38 #include "mysql/psi/psi_idle.h"
39 #include "mysql/psi/psi_mdl.h"
40 #include "mysql/psi/psi_memory.h"
41 #include "mysql/psi/psi_mutex.h"
42 #include "mysql/psi/psi_rwlock.h"
43 #include "mysql/psi/psi_socket.h"
44 #include "mysql/psi/psi_stage.h"
46 #include "mysql/psi/psi_system.h"
47 #include "mysql/psi/psi_table.h"
48 #include "mysql/psi/psi_thread.h"
51 
52 #ifdef HAVE_PSI_INTERFACE
53 
54 #define PFS_AUTOSCALE_VALUE (-1)
55 #define PFS_AUTOSIZE_VALUE (-1)
56 
57 #ifndef PFS_MAX_MUTEX_CLASS
58 #define PFS_MAX_MUTEX_CLASS 350
59 #endif
60 #ifndef PFS_MAX_RWLOCK_CLASS
61 #define PFS_MAX_RWLOCK_CLASS 60
62 #endif
63 #ifndef PFS_MAX_COND_CLASS
64 #define PFS_MAX_COND_CLASS 150
65 #endif
66 #ifndef PFS_MAX_THREAD_CLASS
67 #define PFS_MAX_THREAD_CLASS 100
68 #endif
69 #ifndef PFS_MAX_FILE_CLASS
70 #define PFS_MAX_FILE_CLASS 80
71 #endif
72 #ifndef PFS_MAX_FILE_HANDLE
73 #define PFS_MAX_FILE_HANDLE 32768
74 #endif
75 #ifndef PFS_MAX_SOCKET_CLASS
76 #define PFS_MAX_SOCKET_CLASS 10
77 #endif
78 #ifndef PFS_MAX_STAGE_CLASS
79 #define PFS_MAX_STAGE_CLASS 175
80 #endif
81 #ifndef PFS_STATEMENTS_STACK_SIZE
82 #define PFS_STATEMENTS_STACK_SIZE 10
83 #endif
84 #ifndef PFS_MAX_MEMORY_CLASS
85 #define PFS_MAX_MEMORY_CLASS 450
86 #endif
87 
88 #ifndef PFS_MAX_GLOBAL_SERVER_ERRORS
89 #define PFS_MAX_GLOBAL_SERVER_ERRORS \
90  (1 + pfs_session_error_stat_count + pfs_global_error_stat_count)
91 #endif
92 
93 #ifndef PFS_MAX_SESSION_SERVER_ERRORS
94 #define PFS_MAX_SESSION_SERVER_ERRORS (1 + pfs_session_error_stat_count)
95 #endif
96 
97 /** Sizing hints, from the server configuration. */
99  /** Value of @c Sys_table_def_size */
101  /** Value of @c Sys_table_cache_size */
103  /** Value of @c Sys_max_connections */
105  /** Value of @c Sys_open_files_limit */
107  /** Value of @c Sys_max_prepared_stmt_count */
109 };
110 
111 /** Performance schema global sizing parameters. */
113  /** True if the performance schema is enabled. */
114  bool m_enabled;
115  /** Default values for SETUP_CONSUMERS. */
131 
132  /** True if SHOW PROCESSLIST is enabeld in the performance schema. */
134 
135  /** Default instrument configuration option. */
137 
138  /**
139  Maximum number of instrumented mutex classes.
140  @sa mutex_class_lost.
141  */
143  /**
144  Maximum number of instrumented rwlock classes.
145  @sa rwlock_class_lost.
146  */
148  /**
149  Maximum number of instrumented cond classes.
150  @sa cond_class_lost.
151  */
153  /**
154  Maximum number of instrumented thread classes.
155  @sa thread_class_lost.
156  */
158  /**
159  Maximum number of instrumented table share.
160  @sa table_share_lost.
161  */
163  /**
164  Maximum number of lock statistics collected for tables.
165  @sa table_lock_stat_lost.
166  */
168  /**
169  Maximum number of index statistics collected for tables.
170  @sa table_index_lost.
171  */
173  /**
174  Maximum number of instrumented file classes.
175  @sa file_class_lost.
176  */
178  /**
179  Maximum number of instrumented mutex instances.
180  @sa mutex_lost.
181  */
183  /**
184  Maximum number of instrumented rwlock instances.
185  @sa rwlock_lost.
186  */
188  /**
189  Maximum number of instrumented cond instances.
190  @sa cond_lost.
191  */
193  /**
194  Maximum number of instrumented thread instances.
195  @sa thread_lost.
196  */
198  /**
199  Maximum number of instrumented table handles.
200  @sa table_lost.
201  */
203  /**
204  Maximum number of instrumented file instances.
205  @sa file_lost.
206  */
208  /**
209  Maximum number of instrumented file handles.
210  @sa file_handle_lost.
211  */
213  /**
214  Maximum number of instrumented socket instances
215  @sa socket_lost
216  */
218  /**
219  Maximum number of instrumented socket classes.
220  @sa socket_class_lost.
221  */
223  /** Maximum number of rows per thread in table EVENTS_WAITS_HISTORY. */
225  /** Maximum number of rows in table EVENTS_WAITS_HISTORY_LONG. */
227  /** Maximum number of rows in table SETUP_ACTORS. */
229  /** Maximum number of rows in table SETUP_OBJECTS. */
231  /** Maximum number of rows in table HOSTS. */
233  /** Maximum number of rows in table USERS. */
235  /** Maximum number of rows in table ACCOUNTS. */
237  /**
238  Maximum number of instrumented stage classes.
239  @sa stage_class_lost.
240  */
242  /** Maximum number of rows per thread in table EVENTS_STAGES_HISTORY. */
244  /** Maximum number of rows in table EVENTS_STAGES_HISTORY_LONG. */
246  /**
247  Maximum number of instrumented statement classes.
248  @sa statement_class_lost.
249  */
251  /** Maximum number of rows per thread in table EVENTS_STATEMENTS_HISTORY. */
253  /** Maximum number of rows in table EVENTS_STATEMENTS_HISTORY_LONG. */
255  /** Maximum number of digests to be captured */
257  /** Maximum number of programs to be captured */
259  /** Maximum number of prepared statements to be captured */
261  /** Maximum number of rows per thread in table EVENTS_TRANSACTIONS_HISTORY. */
263  /** Maximum number of rows in table EVENTS_TRANSACTIONS_HISTORY_LONG. */
265 
266  /** Maximum number of session attribute strings per thread */
268  /** Maximum size of statement stack */
270 
271  /**
272  Maximum number of instrumented memory classes.
273  @sa memory_class_lost.
274  */
276 
278 
281 
282  /** Maximum age in seconds for a query sample. */
284 
285  /** Maximum number of error instrumented */
287 
288  /** Sizing hints, for auto tuning. */
290 };
291 
292 /**
293  Performance schema sizing values for the server.
294  This global variable is set when parsing server startup options.
295 */
297 
298 /**
299  Global flag used to enable and disable SHOW PROCESSLIST in the
300  performance schema. This flag only takes effect if the performance schema
301  is configured to support SHOW PROCESSLIST.
302  @sa performance-schema-enable-processlist
303 */
304 extern bool pfs_processlist_enabled;
305 
306 /**
307  Null initialization.
308  Disable all instrumentation, size all internal buffers to 0.
309  This pre initialization step is needed to ensure that events can be collected
310  and discarded, until such time @c initialize_performance_schema() is called.
311 */
313 
314 /**
315  Initialize the performance schema.
316  The performance schema implement several instrumentation services.
317  Each instrumentation service is versioned, and accessible through
318  a bootstrap structure, returned as output parameter.
319  @param param Size parameters to use.
320  @param [out] thread_bootstrap Thread instrumentation service bootstrap
321  @param [out] mutex_bootstrap Mutex instrumentation service bootstrap
322  @param [out] rwlock_bootstrap Rwlock instrumentation service bootstrap
323  @param [out] cond_bootstrap Condition instrumentation service bootstrap
324  @param [out] file_bootstrap File instrumentation service bootstrap
325  @param [out] socket_bootstrap Socket instrumentation service bootstrap
326  @param [out] table_bootstrap Table instrumentation service bootstrap
327  @param [out] mdl_bootstrap Metadata Lock instrumentation service bootstrap
328  @param [out] idle_bootstrap Idle instrumentation service bootstrap
329  @param [out] stage_bootstrap Stage instrumentation service bootstrap
330  @param [out] statement_bootstrap Statement instrumentation service bootstrap
331  @param [out] transaction_bootstrap Transaction instrumentation service
332  bootstrap
333  @param [out] memory_bootstrap Memory instrumentation service bootstrap
334  @param [out] error_bootstrap Error instrumentation service bootstrap
335  @param [out] data_lock_bootstrap Data Lock instrumentation service bootstrap
336  @param [out] system_bootstrap System instrumentation service bootstrap
337  @param [out] tls_channel_bootstrap TLS channel instrumentation service
338  bootstrap
339  @returns
340  @retval 0 success
341 */
343  PFS_global_param *param, PSI_thread_bootstrap **thread_bootstrap,
344  PSI_mutex_bootstrap **mutex_bootstrap,
345  PSI_rwlock_bootstrap **rwlock_bootstrap,
346  PSI_cond_bootstrap **cond_bootstrap, PSI_file_bootstrap **file_bootstrap,
347  PSI_socket_bootstrap **socket_bootstrap,
348  PSI_table_bootstrap **table_bootstrap, PSI_mdl_bootstrap **mdl_bootstrap,
349  PSI_idle_bootstrap **idle_bootstrap, PSI_stage_bootstrap **stage_bootstrap,
350  PSI_statement_bootstrap **statement_bootstrap,
351  PSI_transaction_bootstrap **transaction_bootstrap,
352  PSI_memory_bootstrap **memory_bootstrap,
353  PSI_error_bootstrap **error_bootstrap,
354  PSI_data_lock_bootstrap **data_lock_bootstrap,
355  PSI_system_bootstrap **system_bootstrap,
356  PSI_tls_channel_bootstrap **tls_channel_bootstrap);
357 
359 
360 /**
361  Initialize the performance schema ACL.
362  ACL is strictly enforced when the server is running in normal mode,
363  to enforce that only legal operations are allowed.
364  When running in bootstrap mode, ACL restrictions are relaxed,
365  to allow the bootstrap scripts to DROP / CREATE performance schema tables.
366  @sa ACL_internal_schema_registry
367  @param bootstrap True if the server is starting in bootstrap mode.
368 */
370 
371 /**
372  Reset the aggregated status counter stats.
373 */
375 
376 /**
377  Initialize the dynamic array holding individual instrument settings collected
378  from the server configuration options.
379 */
381 
382 /**
383  Process one PFS_INSTRUMENT configuration string.
384 */
385 int add_pfs_instr_to_array(const char *name, const char *value);
386 
387 /**
388  Register/unregister notification service.
389 */
392 
393 /**
394  Register/unregister resource group service.
395 */
398 
399 /**
400  Shutdown the performance schema.
401 */
403 
404 #endif /* HAVE_PSI_INTERFACE */
405 
406 #endif /* PFS_SERVER_H */
bool pfs_processlist_enabled
Global flag used to enable and disable SHOW PROCESSLIST in the performance schema.
Definition: pfs_instr_class.cc:75
void initialize_performance_schema_acl(bool bootstrap)
Initialize the performance schema ACL.
Definition: pfs_engine_table.cc:994
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
Definition: bootstrap.cc:69
const string value("\"Value\"")
void reset_pfs_status_stats()
Reset the aggregated status counter stats.
Definition: pfs_variable.cc:1469
void shutdown_performance_schema()
Shutdown the performance schema.
Definition: pfs_server.cc:343
void init_pfs_instrument_array()
Initialize the dynamic array holding individual instrument settings collected from the server configu...
Definition: pfs_server.cc:377
void pfs_automated_sizing(PFS_global_param *param)
Definition: pfs_autosize.cc:157
int register_pfs_notification_service()
Register/unregister notification service.
Definition: service_pfs_notification.cc:483
void pre_initialize_performance_schema()
Null initialization.
Definition: pfs_server.cc:68
int add_pfs_instr_to_array(const char *name, const char *value)
Process one PFS_INSTRUMENT configuration string.
Definition: pfs_server.cc:402
int unregister_pfs_notification_service()
Unregister the Notification service.
Definition: service_pfs_notification.cc:511
int register_pfs_resource_group_service()
Register/unregister resource group service.
Definition: service_pfs_resource_group.cc:84
PFS_global_param pfs_param
Performance schema sizing values for the server.
Definition: pfs_server.cc:61
int unregister_pfs_resource_group_service()
Unregister the Resource Group service.
Definition: service_pfs_resource_group.cc:113
int initialize_performance_schema(PFS_global_param *param, PSI_thread_bootstrap **thread_bootstrap, PSI_mutex_bootstrap **mutex_bootstrap, PSI_rwlock_bootstrap **rwlock_bootstrap, PSI_cond_bootstrap **cond_bootstrap, PSI_file_bootstrap **file_bootstrap, PSI_socket_bootstrap **socket_bootstrap, PSI_table_bootstrap **table_bootstrap, PSI_mdl_bootstrap **mdl_bootstrap, PSI_idle_bootstrap **idle_bootstrap, PSI_stage_bootstrap **stage_bootstrap, PSI_statement_bootstrap **statement_bootstrap, PSI_transaction_bootstrap **transaction_bootstrap, PSI_memory_bootstrap **memory_bootstrap, PSI_error_bootstrap **error_bootstrap, PSI_data_lock_bootstrap **data_lock_bootstrap, PSI_system_bootstrap **system_bootstrap, PSI_tls_channel_bootstrap **tls_channel_bootstrap)
Initialize the performance schema.
Definition: pfs_server.cc:91
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
case opt name
Definition: sslopt-case.h:32
Performance schema global sizing parameters.
Definition: pfs_server.h:112
long m_events_stages_history_long_sizing
Maximum number of rows in table EVENTS_STAGES_HISTORY_LONG.
Definition: pfs_server.h:245
ulong m_memory_class_sizing
Maximum number of instrumented memory classes.
Definition: pfs_server.h:275
long m_socket_sizing
Maximum number of instrumented socket instances.
Definition: pfs_server.h:217
long m_session_connect_attrs_sizing
Maximum number of session attribute strings per thread.
Definition: pfs_server.h:267
long m_events_transactions_history_long_sizing
Maximum number of rows in table EVENTS_TRANSACTIONS_HISTORY_LONG.
Definition: pfs_server.h:264
bool m_consumer_events_stages_history_enabled
Definition: pfs_server.h:117
ulong m_max_digest_sample_age
Maximum age in seconds for a query sample.
Definition: pfs_server.h:283
long m_account_sizing
Maximum number of rows in table ACCOUNTS.
Definition: pfs_server.h:236
long m_user_sizing
Maximum number of rows in table USERS.
Definition: pfs_server.h:234
long m_events_waits_history_long_sizing
Maximum number of rows in table EVENTS_WAITS_HISTORY_LONG.
Definition: pfs_server.h:226
long m_index_stat_sizing
Maximum number of index statistics collected for tables.
Definition: pfs_server.h:172
long m_prepared_stmt_sizing
Maximum number of prepared statements to be captured.
Definition: pfs_server.h:260
bool m_consumer_events_transactions_history_enabled
Definition: pfs_server.h:123
bool m_consumer_thread_instrumentation_enabled
Definition: pfs_server.h:129
long m_events_stages_history_sizing
Maximum number of rows per thread in table EVENTS_STAGES_HISTORY.
Definition: pfs_server.h:243
bool m_consumer_events_statements_history_enabled
Definition: pfs_server.h:120
bool m_consumer_events_stages_current_enabled
Default values for SETUP_CONSUMERS.
Definition: pfs_server.h:116
bool m_consumer_events_waits_current_enabled
Definition: pfs_server.h:125
long m_table_share_sizing
Maximum number of instrumented table share.
Definition: pfs_server.h:162
long m_digest_sizing
Maximum number of digests to be captured.
Definition: pfs_server.h:256
bool m_consumer_events_statements_current_enabled
Definition: pfs_server.h:119
ulong m_mutex_class_sizing
Maximum number of instrumented mutex classes.
Definition: pfs_server.h:142
long m_program_sizing
Maximum number of programs to be captured.
Definition: pfs_server.h:258
bool m_consumer_events_transactions_history_long_enabled
Definition: pfs_server.h:124
bool m_consumer_events_stages_history_long_enabled
Definition: pfs_server.h:118
long m_file_sizing
Maximum number of instrumented file instances.
Definition: pfs_server.h:207
long m_events_statements_history_long_sizing
Maximum number of rows in table EVENTS_STATEMENTS_HISTORY_LONG.
Definition: pfs_server.h:254
ulong m_socket_class_sizing
Maximum number of instrumented socket classes.
Definition: pfs_server.h:222
long m_rwlock_sizing
Maximum number of instrumented rwlock instances.
Definition: pfs_server.h:187
bool m_consumer_events_statements_history_long_enabled
Definition: pfs_server.h:121
long m_file_handle_sizing
Maximum number of instrumented file handles.
Definition: pfs_server.h:212
bool m_enabled
True if the performance schema is enabled.
Definition: pfs_server.h:114
ulong m_file_class_sizing
Maximum number of instrumented file classes.
Definition: pfs_server.h:177
long m_metadata_lock_sizing
Definition: pfs_server.h:277
long m_setup_object_sizing
Maximum number of rows in table SETUP_OBJECTS.
Definition: pfs_server.h:230
ulong m_rwlock_class_sizing
Maximum number of instrumented rwlock classes.
Definition: pfs_server.h:147
long m_events_waits_history_sizing
Maximum number of rows per thread in table EVENTS_WAITS_HISTORY.
Definition: pfs_server.h:224
ulong m_max_sql_text_length
Definition: pfs_server.h:280
long m_events_transactions_history_sizing
Maximum number of rows per thread in table EVENTS_TRANSACTIONS_HISTORY.
Definition: pfs_server.h:262
bool m_consumer_events_waits_history_long_enabled
Definition: pfs_server.h:127
long m_cond_sizing
Maximum number of instrumented cond instances.
Definition: pfs_server.h:192
long m_max_digest_length
Definition: pfs_server.h:279
PFS_sizing_hints m_hints
Sizing hints, for auto tuning.
Definition: pfs_server.h:289
ulong m_thread_class_sizing
Maximum number of instrumented thread classes.
Definition: pfs_server.h:157
ulong m_error_sizing
Maximum number of error instrumented.
Definition: pfs_server.h:286
ulong m_statement_class_sizing
Maximum number of instrumented statement classes.
Definition: pfs_server.h:250
long m_mutex_sizing
Maximum number of instrumented mutex instances.
Definition: pfs_server.h:182
bool m_consumer_events_waits_history_enabled
Definition: pfs_server.h:126
ulong m_statement_stack_sizing
Maximum size of statement stack.
Definition: pfs_server.h:269
bool m_processlist_enabled
True if SHOW PROCESSLIST is enabeld in the performance schema.
Definition: pfs_server.h:133
char * m_pfs_instrument
Default instrument configuration option.
Definition: pfs_server.h:136
long m_setup_actor_sizing
Maximum number of rows in table SETUP_ACTORS.
Definition: pfs_server.h:228
long m_events_statements_history_sizing
Maximum number of rows per thread in table EVENTS_STATEMENTS_HISTORY.
Definition: pfs_server.h:252
long m_table_lock_stat_sizing
Maximum number of lock statistics collected for tables.
Definition: pfs_server.h:167
long m_thread_sizing
Maximum number of instrumented thread instances.
Definition: pfs_server.h:197
long m_host_sizing
Maximum number of rows in table HOSTS.
Definition: pfs_server.h:232
ulong m_stage_class_sizing
Maximum number of instrumented stage classes.
Definition: pfs_server.h:241
long m_table_sizing
Maximum number of instrumented table handles.
Definition: pfs_server.h:202
bool m_consumer_global_instrumentation_enabled
Definition: pfs_server.h:128
bool m_consumer_events_transactions_current_enabled
Definition: pfs_server.h:122
ulong m_cond_class_sizing
Maximum number of instrumented cond classes.
Definition: pfs_server.h:152
bool m_consumer_statement_digest_enabled
Definition: pfs_server.h:130
Sizing hints, from the server configuration.
Definition: pfs_server.h:98
ulong m_table_definition_cache
Value of Sys_table_def_size.
Definition: pfs_server.h:100
long m_max_prepared_stmt_count
Value of Sys_max_prepared_stmt_count.
Definition: pfs_server.h:108
long m_open_files_limit
Value of Sys_open_files_limit.
Definition: pfs_server.h:106
long m_max_connections
Value of Sys_max_connections.
Definition: pfs_server.h:104
long m_table_open_cache
Value of Sys_table_cache_size.
Definition: pfs_server.h:102
Entry point for the performance schema interface.
Definition: psi_cond.h:45
Entry point for the performance schema interface.
Definition: psi_data_lock.h:81
Entry point for the performance schema interface.
Definition: psi_error.h:58
Entry point for the performance schema interface.
Definition: psi_file.h:65
Entry point for the performance schema interface.
Definition: psi_idle.h:59
Entry point for the performance schema interface.
Definition: psi_mdl.h:67
Entry point for the performance schema interface.
Definition: psi_memory.h:84
Entry point for the performance schema interface.
Definition: psi_mutex.h:45
Entry point for the performance schema interface.
Definition: psi_rwlock.h:52
Entry point for the performance schema interface.
Definition: psi_socket.h:51
Entry point for the performance schema interface.
Definition: psi_stage.h:45
Entry point for the performance schema interface.
Definition: psi_statement.h:45
Entry point for the performance schema interface.
Definition: psi_system.h:59
Entry point for the performance schema interface.
Definition: psi_table.h:59
Entry point for the performance schema interface.
Definition: psi_thread.h:87
Entry point for the performance schema interface.
Definition: psi_tls_channel.h:45
Entry point for the performance schema interface.
Definition: psi_transaction.h:59