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