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