Skip to content

Commit e8c0a6e

Browse files
committed
wl#9193 : Autoscale InnoDB resources based on system resources by default
Details: Added a new global bool system variable 'innodb_dedicated_server' with default value ON. When this variable is set to ON, then innodb_buffer_pool_size and innodb_log_file_size are autoscaled based on system memory. Also innodb_flush_method is set to O_DIRECT_NO_FSYNC if supported. A new component service 'system_variable_source' is also added which exposes a method named 'get' which could be used to get the SOURCE of a given system variable name. Reviewed by : [email protected] [email protected] [email protected] RB : 16832
1 parent 7676a74 commit e8c0a6e

File tree

90 files changed

+1813
-86
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1813
-86
lines changed

components/mysql_server/server_component.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2525

2626
#include "component_status_var_service.h"
2727
#include "component_sys_var_service.h"
28+
#include "system_variable_source_imp.h"
2829
#include "dynamic_loader.h"
2930
#include "dynamic_loader_path_filter.h"
3031
#include "dynamic_loader_scheme_file.h"
@@ -272,6 +273,10 @@ BEGIN_SERVICE_IMPLEMENTATION(mysql_server, status_variable_registration)
272273
mysql_status_variable_registration_imp::unregister_variable
273274
END_SERVICE_IMPLEMENTATION()
274275

276+
BEGIN_SERVICE_IMPLEMENTATION(mysql_server, system_variable_source)
277+
mysql_system_variable_source_imp::get
278+
END_SERVICE_IMPLEMENTATION()
279+
275280
BEGIN_COMPONENT_PROVIDES(mysql_server)
276281
PROVIDES_SERVICE(mysql_server, registry)
277282
PROVIDES_SERVICE(mysql_server, registry_registration)
@@ -307,6 +312,7 @@ BEGIN_COMPONENT_PROVIDES(mysql_server)
307312
PROVIDES_SERVICE(mysql_server, mysql_mutex_v1)
308313
PROVIDES_SERVICE(mysql_server, mysql_rwlock_v1)
309314
PROVIDES_SERVICE(mysql_server, status_variable_registration)
315+
PROVIDES_SERVICE(mysql_server, system_variable_source)
310316
END_COMPONENT_PROVIDES()
311317

312318
static BEGIN_COMPONENT_REQUIRES(mysql_server)

components/mysql_server/server_component.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ void dynamic_loader_scheme_file_deinit();
4848
void mysql_string_services_init();
4949
void mysql_comp_status_var_services_init();
5050
void mysql_comp_sys_var_services_init();
51+
void mysql_comp_system_variable_source_init();
5152

5253
/* implementation of the built-in components */
5354

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* Copyright (c) 2017, 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
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA */
15+
16+
#ifndef SYSTEM_VARIABLE_SOURCE_IMP_H
17+
#define SYSTEM_VARIABLE_SOURCE_IMP_H
18+
19+
#include <mysql/components/services/system_variable_source.h>
20+
#include <mysql/components/service_implementation.h>
21+
22+
/**
23+
An implementation of the service method to give the source of given
24+
system variable.
25+
*/
26+
27+
class mysql_system_variable_source_imp
28+
{
29+
public:
30+
/**
31+
Get source information of given system variable.
32+
33+
@param [in] name Name of system variable
34+
@param [in] length Name length of system variable
35+
@param [out] source Source of system variable
36+
@return Status of performance operation
37+
@retval false Success
38+
@retval true Failure
39+
*/
40+
41+
static DEFINE_BOOL_METHOD(get,
42+
(const char* name, unsigned int length,
43+
enum enum_variable_source* source));
44+
45+
};
46+
#endif /* SYSTEM_VARIABLE_SOURCE_IMP_H */

components/test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,7 @@ MYSQL_ADD_COMPONENT(test_status_var_service_unreg_only
9494
test_status_var_service_unreg_only.cc
9595
TEST MODULE)
9696

97+
MYSQL_ADD_COMPONENT(test_system_variable_source
98+
test_system_variable_source.cc
99+
TEST MODULE)
100+
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
/* Copyright (c) 2017, 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
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15+
16+
#include <mysql/components/component_implementation.h>
17+
#include <mysql/components/service_implementation.h>
18+
#include <mysql/components/services/system_variable_source.h>
19+
#include "../../components/mysql_server/system_variable_source_imp.h"
20+
21+
#include <fcntl.h>
22+
#include <stdio.h>
23+
#include <typelib.h>
24+
25+
#define MAX_BUFFER_LENGTH 100
26+
int log_text_len= 0;
27+
char log_text[MAX_BUFFER_LENGTH];
28+
FILE *outfile;
29+
const char *filename= "test_system_variable_source.log";
30+
31+
#define WRITE_LOG(lit_log_text) \
32+
log_text_len= sprintf(log_text, "%s", lit_log_text); \
33+
fwrite((uchar*)log_text, sizeof(char), log_text_len, outfile)
34+
35+
REQUIRES_SERVICE_PLACEHOLDER(system_variable_source);
36+
37+
/**
38+
This file contains a test (example) component, which tests the services of
39+
"system_variable_source" service provided by "mysql_server" component.
40+
*/
41+
42+
/**
43+
Initialization entry method for test component. It executes the tests of
44+
the service.
45+
*/
46+
static mysql_service_status_t test_system_variable_source_init()
47+
{
48+
outfile= fopen(filename, "w+");
49+
50+
WRITE_LOG("test_system_variable_source_init start:\n");
51+
52+
enum enum_variable_source source;
53+
if (mysql_service_system_variable_source->get(
54+
"innodb_buffer_pool_size", 23,
55+
&source))
56+
{
57+
WRITE_LOG ("get failed for innodb_buffer_pool_size.\n");
58+
}
59+
else
60+
{
61+
WRITE_LOG ("Source of innodb_buffer_pool_size : ");
62+
switch(source)
63+
{
64+
case COMPILED:
65+
WRITE_LOG(" COMPILED.\n");
66+
break;
67+
case GLOBAL:
68+
WRITE_LOG(" GLOBAL.\n");
69+
break;
70+
case SERVER:
71+
WRITE_LOG(" SERVER.\n");
72+
break;
73+
case EXPLICIT:
74+
WRITE_LOG(" EXPLICIT.\n");
75+
break;
76+
case EXTRA:
77+
WRITE_LOG(" EXTRA.\n");
78+
break;
79+
case MYSQL_USER:
80+
WRITE_LOG(" MYSQL_USER.\n");
81+
break;
82+
case LOGIN:
83+
WRITE_LOG(" LOGIN.\n");
84+
break;
85+
case COMMAND_LINE:
86+
WRITE_LOG(" COMMAND_LINE.\n");
87+
break;
88+
case PERSISTED:
89+
WRITE_LOG(" PERSISTED.\n");
90+
break;
91+
case DYNAMIC:
92+
WRITE_LOG(" DYNAMIC.\n");
93+
break;
94+
default: /* We should never reach here */
95+
WRITE_LOG(" INVALID.\n");
96+
break;
97+
}
98+
}
99+
100+
WRITE_LOG("test_system_variable_source_init end:\n\n");
101+
fclose(outfile);
102+
103+
return false;
104+
}
105+
106+
/**
107+
De-initialization method for Component.
108+
*/
109+
static mysql_service_status_t test_system_variable_source_deinit()
110+
{
111+
/* Nothing to do */
112+
return false;
113+
}
114+
115+
/* An empty list as no service is provided. */
116+
BEGIN_COMPONENT_PROVIDES(test_system_variable_source)
117+
END_COMPONENT_PROVIDES()
118+
119+
/* A list of required services. */
120+
BEGIN_COMPONENT_REQUIRES(test_system_variable_source)
121+
REQUIRES_SERVICE(system_variable_source)
122+
END_COMPONENT_REQUIRES()
123+
124+
/* A list of metadata to describe the Component. */
125+
BEGIN_COMPONENT_METADATA(test_system_variable_source)
126+
METADATA("mysql.author", "Oracle Corporation")
127+
METADATA("mysql.license", "GPL")
128+
METADATA("test_system_variable_source", "1")
129+
END_COMPONENT_METADATA()
130+
131+
/* Declaration of the Component. */
132+
DECLARE_COMPONENT(test_system_variable_source, "mysql:test_system_variable_source")
133+
test_system_variable_source_init,
134+
test_system_variable_source_deinit
135+
END_DECLARE_COMPONENT()
136+
137+
/* Defines list of Components contained in this library. Note that for now we
138+
assume that library will have exactly one Component. */
139+
DECLARE_LIBRARY_COMPONENTS
140+
&COMPONENT_REF(test_system_variable_source)
141+
END_DECLARE_LIBRARY_COMPONENTS

include/my_getopt.h

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "my_inttypes.h"
2929
#include "my_macros.h"
3030
#include "my_sys.h" /* loglevel */
31+
#include <mysql/components/services/system_variable_source_type.h> /* enum_variable_source */
3132

3233
C_MODE_START
3334

@@ -70,27 +71,6 @@ C_MODE_START
7071
*/
7172
enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
7273

73-
/**
74-
Enumeration of the my_option::arg_source.m_source attribute. This enum values
75-
define how system variables are set. For example if a variable is set by
76-
global option file /etc/my.cnf then my_option::arg_source.m_source
77-
will be set to GLOBAL, or if a variable is set from command line then
78-
my_option::arg_source.m_source will hold value as COMMAND_LINE.
79-
*/
80-
enum enum_variable_source
81-
{
82-
COMPILED= 1,
83-
GLOBAL,
84-
SERVER,
85-
EXPLICIT,
86-
EXTRA,
87-
MYSQL_USER,
88-
LOGIN,
89-
COMMAND_LINE,
90-
PERSISTED,
91-
DYNAMIC
92-
};
93-
9474
struct get_opt_arg_source
9575
{
9676
/**
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* Copyright (c) 2017, 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
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA */
15+
16+
#ifndef SYSTEM_VARIABLE_SOURCE_H
17+
#define SYSTEM_VARIABLE_SOURCE_H
18+
19+
#include <mysql/components/service.h>
20+
#include "system_variable_source_type.h"
21+
22+
/**
23+
A service to deal with source of system variable. A system variable
24+
could be set from different sources for eg: Command line, Configuration
25+
file etc. This service exposes method to get the source information of
26+
a given system variable.
27+
*/
28+
BEGIN_SERVICE_DEFINITION(system_variable_source)
29+
30+
/**
31+
Get source information of given system variable.
32+
33+
@param [in] name Name of sytem variable in system charset
34+
@param [in] length Name length of sytem variable
35+
@param [out] source Source of system variable
36+
@return Status of performance operation
37+
@retval false Success
38+
@retval true Failure
39+
*/
40+
41+
DECLARE_BOOL_METHOD(get,
42+
(const char* name, unsigned int length,
43+
enum enum_variable_source* source));
44+
45+
END_SERVICE_DEFINITION(system_variable_source)
46+
47+
#endif /* SYSTEM_VARIABLE_SOURCE_H */
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3+
4+
This program is free software; you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation; version 2 of the License.
7+
8+
This program is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program; if not, write to the Free Software
15+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16+
17+
#ifndef SYSTEM_VARIABLE_SOURCE_TYPE_H
18+
#define SYSTEM_VARIABLE_SOURCE_TYPE_H
19+
/**
20+
This enum values define how system variables are set. For example if a
21+
variable is set by global option file /etc/my.cnf then source will be
22+
set to GLOBAL, or if a variable is set from command line then source
23+
will hold value as COMMAND_LINE.
24+
*/
25+
enum enum_variable_source
26+
{
27+
COMPILED= 1,
28+
GLOBAL,
29+
SERVER,
30+
EXPLICIT,
31+
EXTRA,
32+
MYSQL_USER,
33+
LOGIN,
34+
COMMAND_LINE,
35+
PERSISTED,
36+
DYNAMIC
37+
};
38+
39+
#endif /* SYSTEM_VARIABLE_SOURCE_TYPE_H */

include/mysql/services.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef MYSQL_SERVICES_INCLUDED
2-
/* Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
2+
/* Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by

libservices/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by

0 commit comments

Comments
 (0)