1 /* Copyright (c) 2008, 2015, 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 Foundation, 21 51 Franklin Street, Suite 500, Boston, MA 02110-1335 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 #ifndef PFS_MAX_MUTEX_CLASS 32 #define PFS_MAX_MUTEX_CLASS 200 33 #endif 34 #ifndef PFS_MAX_RWLOCK_CLASS 35 #define PFS_MAX_RWLOCK_CLASS 40 36 #endif 37 #ifndef PFS_MAX_COND_CLASS 38 #define PFS_MAX_COND_CLASS 80 39 #endif 40 #ifndef PFS_MAX_THREAD_CLASS 41 #define PFS_MAX_THREAD_CLASS 50 42 #endif 43 #ifndef PFS_MAX_FILE_CLASS 44 #define PFS_MAX_FILE_CLASS 50 45 #endif 46 #ifndef PFS_MAX_FILE_HANDLE 47 #define PFS_MAX_FILE_HANDLE 32768 48 #endif 49 #ifndef PFS_MAX_SOCKET_CLASS 50 #define PFS_MAX_SOCKET_CLASS 10 51 #endif 52 #ifndef PFS_MAX_SETUP_ACTOR 53 #define PFS_MAX_SETUP_ACTOR 100 54 #endif 55 #ifndef PFS_MAX_SETUP_OBJECT 56 #define PFS_MAX_SETUP_OBJECT 100 57 #endif 58 #ifndef PFS_MAX_STAGE_CLASS 59 #define PFS_MAX_STAGE_CLASS 150 60 #endif 61 #ifndef PFS_STATEMENTS_STACK_SIZE 62 #define PFS_STATEMENTS_STACK_SIZE 10 63 #endif 64 65 struct PFS_sizing_hints 66 { 67 long m_table_definition_cache; 68 long m_table_open_cache; 69 long m_max_connections; 70 long m_open_files_limit; 71 }; 72 73 /** Performance schema global sizing parameters. */ 74 struct PFS_global_param 75 { 76 /** True if the performance schema is enabled. */ 77 bool m_enabled; 78 /** Default values for SETUP_CONSUMERS. */ 79 bool m_consumer_events_stages_current_enabled; 80 bool m_consumer_events_stages_history_enabled; 81 bool m_consumer_events_stages_history_long_enabled; 82 bool m_consumer_events_statements_current_enabled; 83 bool m_consumer_events_statements_history_enabled; 84 bool m_consumer_events_statements_history_long_enabled; 85 bool m_consumer_events_waits_current_enabled; 86 bool m_consumer_events_waits_history_enabled; 87 bool m_consumer_events_waits_history_long_enabled; 88 bool m_consumer_global_instrumentation_enabled; 89 bool m_consumer_thread_instrumentation_enabled; 90 bool m_consumer_statement_digest_enabled; 91 92 /** Default instrument configuration option. */ 93 char *m_pfs_instrument; 94 95 /** 96 Maximum number of instrumented mutex classes. 97 @sa mutex_class_lost. 98 */ 99 ulong m_mutex_class_sizing; 100 /** 101 Maximum number of instrumented rwlock classes. 102 @sa rwlock_class_lost. 103 */ 104 ulong m_rwlock_class_sizing; 105 /** 106 Maximum number of instrumented cond classes. 107 @sa cond_class_lost. 108 */ 109 ulong m_cond_class_sizing; 110 /** 111 Maximum number of instrumented thread classes. 112 @sa thread_class_lost. 113 */ 114 ulong m_thread_class_sizing; 115 /** 116 Maximum number of instrumented table share. 117 @sa table_share_lost. 118 */ 119 long m_table_share_sizing; 120 /** 121 Maximum number of instrumented file classes. 122 @sa file_class_lost. 123 */ 124 ulong m_file_class_sizing; 125 /** 126 Maximum number of instrumented mutex instances. 127 @sa mutex_lost. 128 */ 129 long m_mutex_sizing; 130 /** 131 Maximum number of instrumented rwlock instances. 132 @sa rwlock_lost. 133 */ 134 long m_rwlock_sizing; 135 /** 136 Maximum number of instrumented cond instances. 137 @sa cond_lost. 138 */ 139 long m_cond_sizing; 140 /** 141 Maximum number of instrumented thread instances. 142 @sa thread_lost. 143 */ 144 long m_thread_sizing; 145 /** 146 Maximum number of instrumented table handles. 147 @sa table_lost. 148 */ 149 long m_table_sizing; 150 /** 151 Maximum number of instrumented file instances. 152 @sa file_lost. 153 */ 154 long m_file_sizing; 155 /** 156 Maximum number of instrumented file handles. 157 @sa file_handle_lost. 158 */ 159 long m_file_handle_sizing; 160 /** 161 Maxium number of instrumented socket instances 162 @sa socket_lost 163 */ 164 long m_socket_sizing; 165 /** 166 Maximum number of instrumented socket classes. 167 @sa socket_class_lost. 168 */ 169 ulong m_socket_class_sizing; 170 /** Maximum number of rows per thread in table EVENTS_WAITS_HISTORY. */ 171 long m_events_waits_history_sizing; 172 /** Maximum number of rows in table EVENTS_WAITS_HISTORY_LONG. */ 173 long m_events_waits_history_long_sizing; 174 /** Maximum number of rows in table SETUP_ACTORS. */ 175 ulong m_setup_actor_sizing; 176 /** Maximum number of rows in table SETUP_OBJECTS. */ 177 ulong m_setup_object_sizing; 178 /** Maximum number of rows in table HOSTS. */ 179 long m_host_sizing; 180 /** Maximum number of rows in table USERS. */ 181 long m_user_sizing; 182 /** Maximum number of rows in table ACCOUNTS. */ 183 long m_account_sizing; 184 /** 185 Maximum number of instrumented stage classes. 186 @sa stage_class_lost. 187 */ 188 ulong m_stage_class_sizing; 189 /** Maximum number of rows per thread in table EVENTS_STAGES_HISTORY. */ 190 long m_events_stages_history_sizing; 191 /** Maximum number of rows in table EVENTS_STAGES_HISTORY_LONG. */ 192 long m_events_stages_history_long_sizing; 193 /** 194 Maximum number of instrumented statement classes. 195 @sa statement_class_lost. 196 */ 197 ulong m_statement_class_sizing; 198 /** Maximum number of rows per thread in table EVENTS_STATEMENT_HISTORY. */ 199 long m_events_statements_history_sizing; 200 /** Maximum number of rows in table EVENTS_STATEMENTS_HISTORY_LONG. */ 201 long m_events_statements_history_long_sizing; 202 /** Maximum number of digests to be captured */ 203 long m_digest_sizing; 204 /** Maximum number of session attribute strings per thread */ 205 long m_session_connect_attrs_sizing; 206 207 long m_max_digest_length; 208 209 /** Sizing hints, for auto tuning. */ 210 PFS_sizing_hints m_hints; 211 }; 212 213 /** 214 Performance schema sizing values for the server. 215 This global variable is set when parsing server startup options. 216 */ 217 extern PFS_global_param pfs_param; 218 219 /** 220 Initialize the performance schema. 221 @param param Size parameters to use. 222 @return A boostrap handle, or NULL. 223 */ 224 struct PSI_bootstrap* 225 initialize_performance_schema(PFS_global_param *param); 226 227 void pfs_automated_sizing(PFS_global_param *param); 228 229 /** 230 Initialize the performance schema ACL. 231 ACL is strictly enforced when the server is running in normal mode, 232 to enforce that only legal operations are allowed. 233 When running in boostrap mode, ACL restrictions are relaxed, 234 to allow the boostrap scripts to DROP / CREATE performance schema tables. 235 @sa ACL_internal_schema_registry 236 @param bootstrap True if the server is starting in bootstrap mode. 237 */ 238 void initialize_performance_schema_acl(bool bootstrap); 239 240 void check_performance_schema(); 241 242 /** 243 Initialize the dynamic array holding individual instrument settings collected 244 from the server configuration options. 245 */ 246 void init_pfs_instrument_array(); 247 248 /** 249 Process one PFS_INSTRUMENT configuration string. 250 */ 251 int add_pfs_instr_to_array(const char* name, const char* value); 252 253 /** 254 Shutdown the performance schema. 255 */ 256 void shutdown_performance_schema(); 257 258 #endif 259