160
154
#endif /* MYSQL_DYNAMIC_PLUGIN && __WIN__ */
162
156
static plugin::XaStorageEngine* innodb_engine_ptr= NULL;
164
typedef constrained_check<uint32_t, UINT32_MAX, 10> open_files_constraint;
165
static open_files_constraint innobase_open_files;
166
typedef constrained_check<uint32_t, 10, 1> mirrored_log_groups_constraint;
167
static mirrored_log_groups_constraint innobase_mirrored_log_groups;
168
typedef constrained_check<uint32_t, 100, 2> log_files_in_group_constraint;
169
static log_files_in_group_constraint innobase_log_files_in_group;
170
typedef constrained_check<uint32_t, 6, 0> force_recovery_constraint;
171
force_recovery_constraint innobase_force_recovery;
172
typedef constrained_check<size_t, SIZE_MAX, 256*1024, 1024> log_buffer_constraint;
173
static log_buffer_constraint innobase_log_buffer_size;
174
typedef constrained_check<size_t, SIZE_MAX, 512*1024, 1024> additional_mem_pool_constraint;
175
static additional_mem_pool_constraint innobase_additional_mem_pool_size;
176
typedef constrained_check<unsigned int, 1000, 1> autoextend_constraint;
177
static autoextend_constraint innodb_auto_extend_increment;
178
typedef constrained_check<size_t, SIZE_MAX, 5242880, 1048576> buffer_pool_constraint;
179
static buffer_pool_constraint innobase_buffer_pool_size;
180
typedef constrained_check<uint32_t, MAX_BUFFER_POOLS, 1> buffer_pool_instances_constraint;
181
static buffer_pool_instances_constraint innobase_buffer_pool_instances;
182
typedef constrained_check<uint32_t, UINT32_MAX, 100> io_capacity_constraint;
183
static io_capacity_constraint innodb_io_capacity;
184
typedef constrained_check<uint32_t, 5000, 1> purge_batch_constraint;
185
static purge_batch_constraint innodb_purge_batch_size;
186
typedef constrained_check<uint32_t, 1, 0> purge_threads_constraint;
187
static purge_threads_constraint innodb_n_purge_threads;
188
typedef constrained_check<uint32_t, 2, 0> trinary_constraint;
189
static trinary_constraint innodb_flush_log_at_trx_commit;
190
typedef constrained_check<unsigned int, 99, 0> max_dirty_pages_constraint;
191
static max_dirty_pages_constraint innodb_max_dirty_pages_pct;
192
static uint64_constraint innodb_max_purge_lag;
193
static uint64_nonzero_constraint innodb_stats_sample_pages;
194
typedef constrained_check<uint32_t, 64, 1> io_threads_constraint;
195
static io_threads_constraint innobase_read_io_threads;
196
static io_threads_constraint innobase_write_io_threads;
198
typedef constrained_check<uint32_t, 1000, 0> concurrency_constraint;
199
static concurrency_constraint innobase_commit_concurrency;
200
static concurrency_constraint innobase_thread_concurrency;
201
static uint32_nonzero_constraint innodb_concurrency_tickets;
203
typedef constrained_check<int64_t, INT64_MAX, 1024*1024, 1024*1024> log_file_constraint;
204
static log_file_constraint innobase_log_file_size;
206
static uint64_constraint innodb_replication_delay;
157
static plugin::TableFunction* status_table_function_ptr= NULL;
158
static plugin::TableFunction* cmp_tool= NULL;
159
static plugin::TableFunction* cmp_reset_tool= NULL;
160
static plugin::TableFunction* cmp_mem_tool= NULL;
161
static plugin::TableFunction* cmp_mem_reset_tool= NULL;
162
static plugin::TableFunction* innodb_trx_tool= NULL;
163
static plugin::TableFunction* innodb_locks_tool= NULL;
164
static plugin::TableFunction* innodb_lock_waits_tool= NULL;
166
static long innobase_mirrored_log_groups, innobase_log_files_in_group,
167
innobase_log_buffer_size,
168
innobase_force_recovery, innobase_open_files;
169
static long innobase_additional_mem_pool_size= 8*1024*1024L;
170
static ulong innobase_commit_concurrency = 0;
171
static ulong innobase_read_io_threads;
172
static ulong innobase_write_io_threads;
175
* @TODO: Turn this into size_t as soon as we have a Variable<size_t>
177
static int64_t innobase_buffer_pool_size= 128*1024*1024;
178
static int64_t innobase_log_file_size;
208
180
/** Percentage of the buffer pool to reserve for 'old' blocks.
209
181
Connected to buf_LRU_old_ratio. */
210
typedef constrained_check<uint32_t, 95, 5> old_blocks_constraint;
211
static old_blocks_constraint innobase_old_blocks_pct;
213
static uint32_constraint innodb_sync_spin_loops;
214
static uint32_constraint innodb_spin_wait_delay;
215
static uint32_constraint innodb_thread_sleep_delay;
217
typedef constrained_check<uint32_t, 64, 0> read_ahead_threshold_constraint;
218
static read_ahead_threshold_constraint innodb_read_ahead_threshold;
182
static uint innobase_old_blocks_pct;
220
184
/* The default values for the following char* start-up parameters
221
185
are determined in innobase_init below: */
223
std::string innobase_data_home_dir;
224
std::string innobase_data_file_path;
225
std::string innobase_log_group_home_dir;
226
static string innobase_file_format_name;
227
static string innobase_change_buffering;
229
/* The highest file format being used in the database. The value can be
230
set by user, however, it will be adjusted to the newer file format if
231
a table of such format is created/opened. */
232
static string innobase_file_format_max;
187
static char* innobase_data_home_dir = NULL;
188
static char* innobase_data_file_path = NULL;
189
static char* innobase_log_group_home_dir = NULL;
190
static char* innobase_file_format_name = NULL;
191
static char* innobase_change_buffering = NULL;
193
/* Note: This variable can be set to on/off and any of the supported
194
file formats in the configuration file, but can only be set to any
195
of the supported file formats during runtime. */
196
static char* innobase_file_format_check = NULL;
198
static char* innobase_file_flush_method = NULL;
234
200
/* Below we have boolean-valued start-up parameters, and their default
237
typedef constrained_check<uint32_t, 2, 0> trinary_constraint;
238
static trinary_constraint innobase_fast_shutdown;
240
/* "innobase_file_format_check" decides whether we would continue
241
booting the server if the file format stamped on the system
242
table space exceeds the maximum file format supported
243
by the server. Can be set during server startup at command
244
line or configure file, and a read only variable after
247
/* If a new file format is introduced, the file format
248
name needs to be updated accordingly. Please refer to
249
file_format_name_map[] defined in trx0sys.c for the next
252
static my_bool innobase_file_format_check = TRUE;
203
static ulong innobase_fast_shutdown = 1;
204
#ifdef UNIV_LOG_ARCHIVE
205
static my_bool innobase_log_archive = FALSE;
206
static char* innobase_log_arch_dir = NULL;
207
#endif /* UNIV_LOG_ARCHIVE */
253
208
static my_bool innobase_use_doublewrite = TRUE;
254
209
static my_bool innobase_use_checksums = TRUE;
255
210
static my_bool innobase_rollback_on_timeout = FALSE;
256
211
static my_bool innobase_create_status_file = FALSE;
257
static bool innobase_use_replication_log;
258
static bool support_xa;
259
static bool strict_mode;
260
typedef constrained_check<uint32_t, 1024*1024*1024, 1> lock_wait_constraint;
261
static lock_wait_constraint lock_wait_timeout;
263
213
static char* internal_innobase_data_file_path = NULL;
215
static char* innodb_version_str = (char*) INNODB_VERSION_STR;
265
217
/* The following counter is used to convey information to InnoDB
266
218
about server activity: in selects it is not sensible to call
267
219
srv_active_wake_master_thread after each fetch or search, we only do
1806
1786
value= value - (value % align_val);
1809
static void auto_extend_update(Session *, sql_var_t)
1811
srv_auto_extend_increment= innodb_auto_extend_increment.get();
1814
static void io_capacity_update(Session *, sql_var_t)
1816
srv_io_capacity= innodb_io_capacity.get();
1819
static void purge_batch_update(Session *, sql_var_t)
1821
srv_purge_batch_size= innodb_purge_batch_size.get();
1824
static void purge_threads_update(Session *, sql_var_t)
1826
srv_n_purge_threads= innodb_n_purge_threads.get();
1829
static void innodb_adaptive_hash_index_update(Session *, sql_var_t)
1831
if (btr_search_enabled)
1833
btr_search_enable();
1835
btr_search_disable();
1839
static void innodb_old_blocks_pct_update(Session *, sql_var_t)
1841
innobase_old_blocks_pct= buf_LRU_old_ratio_update(innobase_old_blocks_pct.get(), TRUE);
1844
static void innodb_thread_concurrency_update(Session *, sql_var_t)
1846
srv_thread_concurrency= innobase_thread_concurrency.get();
1849
static void innodb_sync_spin_loops_update(Session *, sql_var_t)
1851
srv_n_spin_wait_rounds= innodb_sync_spin_loops.get();
1854
static void innodb_spin_wait_delay_update(Session *, sql_var_t)
1856
srv_spin_wait_delay= innodb_spin_wait_delay.get();
1859
static void innodb_thread_sleep_delay_update(Session *, sql_var_t)
1861
srv_thread_sleep_delay= innodb_thread_sleep_delay.get();
1864
static void innodb_read_ahead_threshold_update(Session *, sql_var_t)
1866
srv_read_ahead_threshold= innodb_read_ahead_threshold.get();
1870
static int innodb_commit_concurrency_validate(Session *session, set_var *var)
1872
uint64_t new_value= var->getInteger();
1874
if ((innobase_commit_concurrency.get() == 0 && new_value != 0) ||
1875
(innobase_commit_concurrency.get() != 0 && new_value == 0))
1877
push_warning_printf(session,
1878
DRIZZLE_ERROR::WARN_LEVEL_WARN,
1880
_("Once InnoDB is running, innodb_commit_concurrency "
1881
"must not change between zero and nonzero."));
1887
/*************************************************************//**
1888
Check if it is a valid file format. This function is registered as
1889
a callback with MySQL.
1890
@return 0 for valid file format */
1893
innodb_file_format_name_validate(
1894
/*=============================*/
1895
Session* , /*!< in: thread handle */
1898
const char *file_format_input = var->value->str_value.ptr();
1899
if (file_format_input == NULL)
1902
if (file_format_input != NULL) {
1905
format_id = innobase_file_format_name_lookup(
1908
if (format_id <= DICT_TF_FORMAT_MAX) {
1909
innobase_file_format_name =
1910
trx_sys_file_format_id_to_name(format_id);
1919
/*************************************************************//**
1920
Check if it is a valid value of innodb_change_buffering. This function is
1921
registered as a callback with MySQL.
1922
@return 0 for valid innodb_change_buffering */
1925
innodb_change_buffering_validate(
1926
/*=============================*/
1927
Session* , /*!< in: thread handle */
1930
const char *change_buffering_input = var->value->str_value.ptr();
1932
if (change_buffering_input == NULL)
1938
use < UT_ARR_SIZE(innobase_change_buffering_values);
1940
if (!innobase_strcasecmp(change_buffering_input,
1941
innobase_change_buffering_values[use]))
1943
ibuf_use= static_cast<ibuf_use_t>(use);
1952
/*************************************************************//**
1953
Check if valid argument to innodb_file_format_max. This function
1954
is registered as a callback with MySQL.
1955
@return 0 for valid file format */
1958
innodb_file_format_max_validate(
1959
/*==============================*/
1960
Session* session, /*!< in: thread handle */
1963
const char *file_format_input = var->value->str_value.ptr();
1964
if (file_format_input == NULL)
1967
if (file_format_input != NULL) {
1968
int format_id = innobase_file_format_validate_and_set(file_format_input);
1970
if (format_id > DICT_TF_FORMAT_MAX) {
1971
/* DEFAULT is "on", which is invalid at runtime. */
1975
if (format_id >= 0) {
1976
innobase_file_format_max.assign(
1977
trx_sys_file_format_id_to_name((uint)format_id));
1979
/* Update the max format id in the system tablespace. */
1980
const char *name_buff;
1982
if (trx_sys_file_format_max_set(format_id, &name_buff))
1984
errmsg_printf(error::WARN,
1985
" [Info] InnoDB: the file format in the system "
1986
"tablespace is now set to %s.\n", name_buff);
1987
innobase_file_format_max= name_buff;
1992
push_warning_printf(session,
1993
DRIZZLE_ERROR::WARN_LEVEL_WARN,
1995
"InnoDB: invalid innodb_file_format_max "
1996
"value; can be any format up to %s "
1997
"or equivalent id of %d",
1998
trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX),
1999
DICT_TF_FORMAT_MAX);
2007
1789
/*********************************************************************//**
2008
1790
Opens an InnoDB database.
2009
1791
@return 0 on success, error code on failure */
2019
1801
InnobaseEngine *actuall_engine_ptr;
2020
1802
const module::option_map &vm= context.getOptions();
2022
srv_auto_extend_increment= innodb_auto_extend_increment.get();
2023
srv_io_capacity= innodb_io_capacity.get();
2024
srv_purge_batch_size= innodb_purge_batch_size.get();
2025
srv_n_purge_threads= innodb_n_purge_threads.get();
2026
srv_flush_log_at_trx_commit= innodb_flush_log_at_trx_commit.get();
2027
srv_max_buf_pool_modified_pct= innodb_max_dirty_pages_pct.get();
2028
srv_max_purge_lag= innodb_max_purge_lag.get();
2029
srv_stats_sample_pages= innodb_stats_sample_pages.get();
2030
srv_n_free_tickets_to_enter= innodb_concurrency_tickets.get();
2031
srv_replication_delay= innodb_replication_delay.get();
2032
srv_thread_concurrency= innobase_thread_concurrency.get();
2033
srv_n_spin_wait_rounds= innodb_sync_spin_loops.get();
2034
srv_spin_wait_delay= innodb_spin_wait_delay.get();
2035
srv_thread_sleep_delay= innodb_thread_sleep_delay.get();
2036
srv_read_ahead_threshold= innodb_read_ahead_threshold.get();
2038
1804
/* Inverted Booleans */
2040
1806
innobase_use_checksums= (vm.count("disable-checksums")) ? false : true;
2041
1807
innobase_use_doublewrite= (vm.count("disable-doublewrite")) ? false : true;
2042
1808
srv_adaptive_flushing= (vm.count("disable-adaptive-flushing")) ? false : true;
2043
1809
srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
2044
srv_use_native_aio= (vm.count("disable-native-aio")) ? false : true;
2045
support_xa= (vm.count("disable-xa")) ? false : true;
2046
btr_search_enabled= (vm.count("disable-adaptive-hash-index")) ? false : true;
2049
/* Hafta do this here because we need to late-bind the default value */
1810
(SessionVAR(NULL,support_xa))= (vm.count("disable-xa")) ? false : true;
1811
(SessionVAR(NULL,table_locks))= (vm.count("disable-table-locks")) ? false : true;
1813
if (vm.count("io-capacity"))
1815
if (srv_io_capacity < 100)
1817
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for io-capacity\n"));
2050
1822
if (vm.count("data-home-dir"))
2052
innobase_data_home_dir= vm["data-home-dir"].as<string>();
2056
innobase_data_home_dir= getDataHome().file_string();
1824
innobase_data_home_dir= strdup(vm["data-home-dir"].as<string>().c_str());
1828
innobase_data_home_dir= strdup(getDataHome().file_string().c_str());
1831
if (vm.count("fast-shutdown"))
1833
if (innobase_fast_shutdown > 2)
1835
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for fast-shutdown\n"));
1840
if (vm.count("file-format-check"))
1842
innobase_file_format_check= const_cast<char *>(vm["file-format-check"].as<string>().c_str());
1845
if (vm.count("flush-log-at-trx-commit"))
1847
if (srv_flush_log_at_trx_commit > 2)
1849
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for flush-log-at-trx-commit\n"));
1854
if (vm.count("flush-method"))
1856
innobase_file_flush_method= const_cast<char *>(vm["flush-method"].as<string>().c_str());
1860
innobase_file_flush_method= NULL;
1863
#ifdef UNIV_LOG_ARCHIVE
1864
if (vm.count("log-arch-dir"))
1866
innobase_log_arch_dir= const_cast<char *>(vm["log-arch-dir"].as<string>().c_str());
1871
innobase_log_arch_dir= NULL;
1873
#endif /* UNIV_LOG_ARCHIVE */
1875
if (vm.count("max-dirty-pages-pct"))
1877
if (srv_max_buf_pool_modified_pct > 99)
1879
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for max-dirty-pages-pct\n"));
1884
if (vm.count("stats-sample-pages"))
1886
if (srv_stats_sample_pages < 8)
1888
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for stats-sample-pages\n"));
1893
if (vm.count("additional-mem-pool-size"))
1895
align_value(innobase_additional_mem_pool_size);
1897
if (innobase_additional_mem_pool_size < 512*1024L)
1899
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for additional-mem-pool-size\n"));
1905
if (vm.count("autoextend-increment"))
1907
if (srv_auto_extend_increment < 1 || srv_auto_extend_increment > 1000)
1909
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for autoextend-increment\n"));
1914
if (vm.count("buffer-pool-size"))
1916
align_value(innobase_buffer_pool_size, 1024*1024);
1917
if (innobase_buffer_pool_size < 5*1024*1024)
1919
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for buffer-pool-size\n"));
1925
if (vm.count("commit-concurrency"))
1927
if (srv_replication_delay > 1000)
1929
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for commit-concurrency\n"));
1934
if (vm.count("concurrency-tickets"))
1936
if (srv_n_free_tickets_to_enter < 1)
1938
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for concurrency-tickets\n"));
1943
if (vm.count("read-io-threads"))
1945
if (innobase_read_io_threads < 1 || innobase_read_io_threads > 64)
1947
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-io-threads\n"));
1952
if (vm.count("write-io-threads"))
1954
if (innobase_write_io_threads < 1 || innobase_write_io_threads > 64)
1956
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for write-io-threads\n"));
1961
if (vm.count("force-recovery"))
1963
if (innobase_force_recovery > 6)
1965
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for force-recovery\n"));
1970
if (vm.count("log-buffer-size"))
1972
align_value(innobase_log_buffer_size);
1973
if (innobase_log_buffer_size < 256*1024L)
1975
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
1980
if (vm.count("log-file-size"))
1982
align_value(innobase_log_file_size, 1024*1024);
1983
if (innobase_log_file_size < 1*1024*1024L)
1985
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
1990
if (vm.count("log-files-in-group"))
1992
if (innobase_log_files_in_group < 2 || innobase_log_files_in_group > 100)
1994
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-files-in-group\n"));
1999
if (vm.count("mirrored-log-groups"))
2001
if (innobase_mirrored_log_groups < 1 || innobase_mirrored_log_groups > 10)
2003
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for mirrored-log-groups\n"));
2008
if (vm.count("open-files"))
2010
if (innobase_open_files < 10)
2012
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for open-files\n"));
2017
if (vm.count("thread-concurrency"))
2019
if (srv_thread_concurrency > 1000)
2021
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for thread-concurrency\n"));
2060
2026
if (vm.count("data-file-path"))
2062
innobase_data_file_path= vm["data-file-path"].as<string>();
2028
innobase_data_file_path= const_cast<char *>(vm["data-file-path"].as<string>().c_str());
2032
innobase_data_file_path= NULL;
2035
if (vm.count("version"))
2037
innodb_version_str= const_cast<char *>(vm["version"].as<string>().c_str());
2040
if (vm.count("read-ahead-threshold"))
2042
if (srv_read_ahead_threshold > 64)
2044
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-ahead-threshold\n"));
2049
if (vm.count("strict-mode"))
2051
(SessionVAR(NULL,strict_mode))= vm["strict-mode"].as<bool>();
2054
if (vm.count("lock-wait-timeout"))
2056
if (vm["lock-wait-timeout"].as<unsigned long>() < 1 || vm["lock-wait-timeout"].as<unsigned long>() > 1024*1024*1024)
2058
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for lock-wait-timeout\n"));
2062
(SessionVAR(NULL,lock_wait_timeout))= vm["lock-wait-timeout"].as<unsigned long>();
2066
2065
innodb_engine_ptr= actuall_engine_ptr= new InnobaseEngine(innobase_engine_name);
2269
2310
err = innobase_start_or_create_for_mysql();
2271
if (err != DB_SUCCESS)
2273
goto mem_free_and_error;
2276
err = dict_create_sys_replication_log();
2278
2312
if (err != DB_SUCCESS) {
2279
2313
goto mem_free_and_error;
2283
innobase_old_blocks_pct = buf_LRU_old_ratio_update(innobase_old_blocks_pct.get(),
2286
2316
innobase_open_tables = hash_create(200);
2317
pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST);
2318
pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
2319
pthread_mutex_init(&commit_threads_m, MY_MUTEX_INIT_FAST);
2320
pthread_mutex_init(&commit_cond_m, MY_MUTEX_INIT_FAST);
2321
pthread_cond_init(&commit_cond, NULL);
2287
2322
innodb_inited= 1;
2289
2324
actuall_engine_ptr->dropTemporarySchema();
2291
context.add(new InnodbStatusTool);
2326
status_table_function_ptr= new InnodbStatusTool;
2293
2328
context.add(innodb_engine_ptr);
2295
context.add(new(std::nothrow)CmpTool(false));
2297
context.add(new(std::nothrow)CmpTool(true));
2299
context.add(new(std::nothrow)CmpmemTool(false));
2301
context.add(new(std::nothrow)CmpmemTool(true));
2303
context.add(new(std::nothrow)InnodbTrxTool("INNODB_TRX"));
2305
context.add(new(std::nothrow)InnodbTrxTool("INNODB_LOCKS"));
2307
context.add(new(std::nothrow)InnodbTrxTool("INNODB_LOCK_WAITS"));
2309
context.add(new(std::nothrow)InnodbSysTablesTool());
2311
context.add(new(std::nothrow)InnodbSysTableStatsTool());
2313
context.add(new(std::nothrow)InnodbSysIndexesTool());
2315
context.add(new(std::nothrow)InnodbSysColumnsTool());
2317
context.add(new(std::nothrow)InnodbSysFieldsTool());
2319
context.add(new(std::nothrow)InnodbSysForeignTool());
2321
context.add(new(std::nothrow)InnodbSysForeignColsTool());
2330
context.add(status_table_function_ptr);
2332
cmp_tool= new(std::nothrow)CmpTool(false);
2333
context.add(cmp_tool);
2335
cmp_reset_tool= new(std::nothrow)CmpTool(true);
2336
context.add(cmp_reset_tool);
2338
cmp_mem_tool= new(std::nothrow)CmpmemTool(false);
2339
context.add(cmp_mem_tool);
2341
cmp_mem_reset_tool= new(std::nothrow)CmpmemTool(true);
2342
context.add(cmp_mem_reset_tool);
2344
innodb_trx_tool= new(std::nothrow)InnodbTrxTool("INNODB_TRX");
2345
context.add(innodb_trx_tool);
2347
innodb_locks_tool= new(std::nothrow)InnodbTrxTool("INNODB_LOCKS");
2348
context.add(innodb_locks_tool);
2350
innodb_lock_waits_tool= new(std::nothrow)InnodbTrxTool("INNODB_LOCK_WAITS");
2351
context.add(innodb_lock_waits_tool);
2323
2353
context.add(new(std::nothrow)InnodbInternalTables());
2324
context.add(new(std::nothrow)InnodbReplicationTable());
2326
if (innobase_use_replication_log)
2328
ReplicationLog *replication_logger= new(std::nothrow)ReplicationLog();
2329
context.add(replication_logger);
2330
ReplicationLog::setup(replication_logger);
2333
context.registerVariable(new sys_var_const_string_val("data-home-dir", innobase_data_home_dir));
2334
context.registerVariable(new sys_var_const_string_val("flush-method",
2335
vm.count("flush-method") ? vm["flush-method"].as<string>() : ""));
2336
context.registerVariable(new sys_var_const_string_val("log-group-home-dir", innobase_log_group_home_dir));
2337
context.registerVariable(new sys_var_const_string_val("data-file-path", innobase_data_file_path));
2338
context.registerVariable(new sys_var_const_string_val("version", vm["version"].as<string>()));
2341
context.registerVariable(new sys_var_bool_ptr_readonly("replication_log", &innobase_use_replication_log));
2342
context.registerVariable(new sys_var_bool_ptr_readonly("checksums", &innobase_use_checksums));
2343
context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite", &innobase_use_doublewrite));
2344
context.registerVariable(new sys_var_bool_ptr("file-per-table", &srv_file_per_table));
2345
context.registerVariable(new sys_var_bool_ptr_readonly("file-format-check", &innobase_file_format_check));
2346
context.registerVariable(new sys_var_bool_ptr("adaptive-flushing", &srv_adaptive_flushing));
2347
context.registerVariable(new sys_var_bool_ptr("status-file", &innobase_create_status_file));
2348
context.registerVariable(new sys_var_bool_ptr_readonly("use-sys-malloc", &srv_use_sys_malloc));
2349
context.registerVariable(new sys_var_bool_ptr_readonly("use-native-aio", &srv_use_native_aio));
2351
context.registerVariable(new sys_var_bool_ptr("support-xa", &support_xa));
2352
context.registerVariable(new sys_var_bool_ptr("strict_mode", &strict_mode));
2353
context.registerVariable(new sys_var_constrained_value<uint32_t>("lock_wait_timeout", lock_wait_timeout));
2355
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
2356
context.registerVariable(new sys_var_constrained_value<uint32_t>("autoextend_increment",
2357
innodb_auto_extend_increment,
2358
auto_extend_update));
2359
context.registerVariable(new sys_var_constrained_value<uint32_t>("io_capacity",
2361
io_capacity_update));
2362
context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_batch_size",
2363
innodb_purge_batch_size,
2364
purge_batch_update));
2365
context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_threads",
2366
innodb_n_purge_threads,
2367
purge_threads_update));
2368
context.registerVariable(new sys_var_constrained_value<uint32_t>("fast_shutdown", innobase_fast_shutdown));
2369
context.registerVariable(new sys_var_std_string("file_format",
2370
innobase_file_format_name,
2371
innodb_file_format_name_validate));
2372
context.registerVariable(new sys_var_std_string("change_buffering",
2373
innobase_change_buffering,
2374
innodb_change_buffering_validate));
2375
context.registerVariable(new sys_var_std_string("file_format_max",
2376
innobase_file_format_max,
2377
innodb_file_format_max_validate));
2378
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("buffer_pool_size", innobase_buffer_pool_size));
2379
context.registerVariable(new sys_var_constrained_value_readonly<int64_t>("log_file_size", innobase_log_file_size));
2380
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("flush_log_at_trx_commit",
2381
innodb_flush_log_at_trx_commit));
2382
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("max_dirty_pages_pct",
2383
innodb_max_dirty_pages_pct));
2384
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("max_purge_lag", innodb_max_purge_lag));
2385
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("stats_sample_pages", innodb_stats_sample_pages));
2386
context.registerVariable(new sys_var_bool_ptr("adaptive_hash_index", &btr_search_enabled, innodb_adaptive_hash_index_update));
2388
context.registerVariable(new sys_var_constrained_value<uint32_t>("commit_concurrency",
2389
innobase_commit_concurrency,
2390
innodb_commit_concurrency_validate));
2391
context.registerVariable(new sys_var_constrained_value<uint32_t>("concurrency_tickets",
2392
innodb_concurrency_tickets));
2393
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("read_io_threads", innobase_read_io_threads));
2394
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("write_io_threads", innobase_write_io_threads));
2395
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("replication_delay", innodb_replication_delay));
2396
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("force_recovery", innobase_force_recovery));
2397
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("log_buffer_size", innobase_log_buffer_size));
2398
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("log_files_in_group", innobase_log_files_in_group));
2399
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("mirrored_log_groups", innobase_mirrored_log_groups));
2400
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("open_files", innobase_open_files));
2401
context.registerVariable(new sys_var_constrained_value<uint32_t>("old_blocks_pct",
2402
innobase_old_blocks_pct,
2403
innodb_old_blocks_pct_update));
2404
context.registerVariable(new sys_var_uint32_t_ptr("old_blocks_time", &buf_LRU_old_threshold_ms));
2405
context.registerVariable(new sys_var_constrained_value<uint32_t>("sync_spin_loops", innodb_sync_spin_loops, innodb_sync_spin_loops_update));
2406
context.registerVariable(new sys_var_constrained_value<uint32_t>("spin_wait_delay", innodb_spin_wait_delay, innodb_spin_wait_delay_update));
2407
context.registerVariable(new sys_var_constrained_value<uint32_t>("thread_sleep_delay", innodb_thread_sleep_delay, innodb_thread_sleep_delay_update));
2408
context.registerVariable(new sys_var_constrained_value<uint32_t>("thread_concurrency",
2409
innobase_thread_concurrency,
2410
innodb_thread_concurrency_update));
2411
context.registerVariable(new sys_var_constrained_value<uint32_t>("read_ahead_threshold",
2412
innodb_read_ahead_threshold,
2413
innodb_read_ahead_threshold_update));
2414
2355
/* Get the current high water mark format. */
2415
innobase_file_format_max = trx_sys_file_format_max_get();
2416
btr_search_fully_disabled = (!btr_search_enabled);
2356
innobase_file_format_check = (char*) trx_sys_file_format_max_get();
9103
8994
/************************************************************//**
8995
Validate the file format check value, is it one of "on" or "off",
8996
as a side effect it sets the srv_check_file_format_at_startup variable.
8997
@return true if config value one of "on" or "off" */
9000
innobase_file_format_check_on_off(
9001
/*==============================*/
9002
const char* format_check) /*!< in: parameter value */
9006
if (!innobase_strcasecmp(format_check, "off")) {
9008
/* Set the value to disable checking. */
9009
srv_check_file_format_at_startup = DICT_TF_FORMAT_MAX + 1;
9011
} else if (!innobase_strcasecmp(format_check, "on")) {
9013
/* Set the value to the lowest supported format. */
9014
srv_check_file_format_at_startup = DICT_TF_FORMAT_51;
9022
/************************************************************//**
9104
9023
Validate the file format check config parameters, as a side effect it
9105
sets the srv_max_file_format_at_startup variable.
9024
sets the srv_check_file_format_at_startup variable.
9106
9025
@return the format_id if valid config value, otherwise, return -1 */
9109
9028
innobase_file_format_validate_and_set(
9110
9029
/*================================*/
9111
const char* format_max) /*!< in: parameter value */
9030
const char* format_check) /*!< in: parameter value */
9113
9032
uint format_id;
9115
format_id = innobase_file_format_name_lookup(format_max);
9034
format_id = innobase_file_format_name_lookup(format_check);
9117
9036
if (format_id < DICT_TF_FORMAT_MAX + 1) {
9118
srv_max_file_format_at_startup = format_id;
9037
srv_check_file_format_at_startup = format_id;
9119
9038
return((int) format_id);
9044
/*************************************************************//**
9045
Check if it is a valid file format. This function is registered as
9046
a callback with MySQL.
9047
@return 0 for valid file format */
9050
innodb_file_format_name_validate(
9051
/*=============================*/
9052
Session* , /*!< in: thread handle */
9053
drizzle_sys_var* , /*!< in: pointer to system
9055
void* save, /*!< out: immediate result
9056
for update function */
9057
drizzle_value* value) /*!< in: incoming string */
9059
const char* file_format_input;
9060
char buff[STRING_BUFFER_USUAL_SIZE];
9061
int len = sizeof(buff);
9064
ut_a(value != NULL);
9066
file_format_input = value->val_str(value, buff, &len);
9068
if (file_format_input != NULL) {
9071
format_id = innobase_file_format_name_lookup(
9074
if (format_id <= DICT_TF_FORMAT_MAX) {
9075
/* Save a pointer to the name in the
9076
'file_format_name_map' constant array. */
9077
*static_cast<const char**>(save) =
9078
trx_sys_file_format_id_to_name(format_id);
9084
*static_cast<const char**>(save) = NULL;
9088
/****************************************************************//**
9089
Update the system variable innodb_file_format using the "saved"
9090
value. This function is registered as a callback with MySQL. */
9093
innodb_file_format_name_update(
9094
/*===========================*/
9095
Session* , /*!< in: thread handle */
9096
drizzle_sys_var* , /*!< in: pointer to
9098
void* var_ptr, /*!< out: where the
9099
formal string goes */
9100
const void* save) /*!< in: immediate result
9101
from check function */
9103
const char* format_name;
9105
ut_a(var_ptr != NULL);
9108
format_name = *static_cast<const char*const*>(save);
9113
format_id = innobase_file_format_name_lookup(format_name);
9115
if (format_id <= DICT_TF_FORMAT_MAX) {
9116
srv_file_format = format_id;
9120
*static_cast<const char**>(var_ptr)
9121
= trx_sys_file_format_id_to_name(srv_file_format);
9124
/*************************************************************//**
9125
Check if valid argument to innodb_file_format_check. This
9126
function is registered as a callback with MySQL.
9127
@return 0 for valid file format */
9130
innodb_file_format_check_validate(
9131
/*==============================*/
9132
Session* session, /*!< in: thread handle */
9133
drizzle_sys_var* , /*!< in: pointer to system
9135
void* save, /*!< out: immediate result
9136
for update function */
9137
drizzle_value* value) /*!< in: incoming string */
9139
const char* file_format_input;
9140
char buff[STRING_BUFFER_USUAL_SIZE];
9141
int len = sizeof(buff);
9145
ut_a(value != NULL);
9147
file_format_input = value->val_str(value, buff, &len);
9149
if (file_format_input != NULL) {
9151
/* Check if user set on/off, we want to print a suitable
9152
message if they did so. */
9154
if (innobase_file_format_check_on_off(file_format_input)) {
9155
push_warning_printf(session,
9156
DRIZZLE_ERROR::WARN_LEVEL_WARN,
9158
"InnoDB: invalid innodb_file_format_check "
9159
"value; on/off can only be set at startup or "
9160
"in the configuration file");
9162
format_id = innobase_file_format_validate_and_set(file_format_input);
9163
if (format_id >= 0) {
9164
/* Save a pointer to the name in the
9165
'file_format_name_map' constant array. */
9166
*static_cast<const char**>(save) =
9167
trx_sys_file_format_id_to_name(
9173
push_warning_printf(session,
9174
DRIZZLE_ERROR::WARN_LEVEL_WARN,
9176
"InnoDB: invalid innodb_file_format_check "
9177
"value; can be any format up to %s "
9178
"or its equivalent numeric id",
9179
trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX));
9184
*static_cast<const char**>(save) = NULL;
9188
/****************************************************************//**
9189
Update the system variable innodb_file_format_check using the "saved"
9190
value. This function is registered as a callback with MySQL. */
9193
innodb_file_format_check_update(
9194
/*============================*/
9195
Session* session, /*!< in: thread handle */
9196
drizzle_sys_var* , /*!< in: pointer to
9198
void* var_ptr, /*!< out: where the
9199
formal string goes */
9200
const void* save) /*!< in: immediate result
9201
from check function */
9203
const char* format_name_in;
9204
const char** format_name_out;
9208
ut_a(var_ptr != NULL);
9210
format_name_in = *static_cast<const char*const*>(save);
9212
if (!format_name_in) {
9217
format_id = innobase_file_format_name_lookup(format_name_in);
9219
if (format_id > DICT_TF_FORMAT_MAX) {
9220
/* DEFAULT is "on", which is invalid at runtime. */
9221
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
9223
"Ignoring SET innodb_file_format=%s",
9228
format_name_out = static_cast<const char**>(var_ptr);
9230
/* Update the max format id in the system tablespace. */
9231
if (trx_sys_file_format_max_set(format_id, format_name_out)) {
9232
ut_print_timestamp(stderr);
9234
" [Info] InnoDB: the file format in the system "
9235
"tablespace is now set to %s.\n", *format_name_out);
9239
/****************************************************************//**
9240
Update the system variable innodb_adaptive_hash_index using the "saved"
9241
value. This function is registered as a callback with MySQL. */
9244
innodb_adaptive_hash_index_update(
9245
/*==============================*/
9246
Session* , /*!< in: thread handle */
9247
drizzle_sys_var* , /*!< in: pointer to
9249
void* , /*!< out: where the
9250
formal string goes */
9251
const void* save) /*!< in: immediate result
9252
from check function */
9254
if (*(bool*) save) {
9255
btr_search_enable();
9257
btr_search_disable();
9261
/****************************************************************//**
9262
Update the system variable innodb_old_blocks_pct using the "saved"
9263
value. This function is registered as a callback with MySQL. */
9266
innodb_old_blocks_pct_update(
9267
/*=========================*/
9268
Session* , /*!< in: thread handle */
9269
drizzle_sys_var* , /*!< in: pointer to
9271
void* ,/*!< out: where the
9272
formal string goes */
9273
const void* save) /*!< in: immediate result
9274
from check function */
9276
innobase_old_blocks_pct = buf_LRU_old_ratio_update(
9277
*static_cast<const uint*>(save), TRUE);
9280
/*************************************************************//**
9281
Check if it is a valid value of innodb_change_buffering. This function is
9282
registered as a callback with MySQL.
9283
@return 0 for valid innodb_change_buffering */
9286
innodb_change_buffering_validate(
9287
/*=============================*/
9288
Session* , /*!< in: thread handle */
9289
drizzle_sys_var* , /*!< in: pointer to system
9291
void* save, /*!< out: immediate result
9292
for update function */
9293
drizzle_value* value) /*!< in: incoming string */
9295
const char* change_buffering_input;
9296
char buff[STRING_BUFFER_USUAL_SIZE];
9297
int len = sizeof(buff);
9300
ut_a(value != NULL);
9302
change_buffering_input = value->val_str(value, buff, &len);
9304
if (change_buffering_input != NULL) {
9307
for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values);
9309
if (!innobase_strcasecmp(
9310
change_buffering_input,
9311
innobase_change_buffering_values[use])) {
9312
*(ibuf_use_t*) save = (ibuf_use_t) use;
9321
/****************************************************************//**
9322
Update the system variable innodb_change_buffering using the "saved"
9323
value. This function is registered as a callback with MySQL. */
9326
innodb_change_buffering_update(
9327
/*===========================*/
9328
Session* , /*!< in: thread handle */
9329
drizzle_sys_var* , /*!< in: pointer to
9331
void* var_ptr, /*!< out: where the
9332
formal string goes */
9333
const void* save) /*!< in: immediate result
9334
from check function */
9336
ut_a(var_ptr != NULL);
9338
ut_a((*(ibuf_use_t*) save) < IBUF_USE_COUNT);
9340
ibuf_use = *(const ibuf_use_t*) save;
9342
*(const char**) var_ptr = innobase_change_buffering_values[ibuf_use];
9345
/* plugin options */
9346
static DRIZZLE_SYSVAR_BOOL(checksums, innobase_use_checksums,
9347
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
9348
"Enable InnoDB checksums validation (enabled by default). ",
9351
static DRIZZLE_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
9352
PLUGIN_VAR_READONLY,
9353
"The common part for InnoDB table spaces.",
9356
static DRIZZLE_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
9357
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
9358
"Enable InnoDB doublewrite buffer (enabled by default). ",
9361
static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
9362
PLUGIN_VAR_RQCMDARG,
9363
"Number of IOPs the server can do. Tunes the background IO rate",
9364
NULL, NULL, 200, 100, ~0L, 0);
9366
static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
9367
PLUGIN_VAR_OPCMDARG,
9368
"Speeds up the shutdown process of the InnoDB storage engine. Possible "
9369
"values are 0, 1 (faster)"
9370
" or 2 (fastest - crash-like)"
9372
NULL, NULL, 1, 0, 2, 0);
9374
static DRIZZLE_SYSVAR_BOOL(file_per_table, srv_file_per_table,
9375
PLUGIN_VAR_NOCMDARG,
9376
"Stores each InnoDB table to an .ibd file in the database dir.",
9379
static DRIZZLE_SYSVAR_STR(file_format, innobase_file_format_name,
9380
PLUGIN_VAR_RQCMDARG,
9381
"File format to use for new tables in .ibd files.",
9382
innodb_file_format_name_validate,
9383
innodb_file_format_name_update, "Antelope");
9385
/* If a new file format is introduced, the file format
9386
name needs to be updated accordingly. Please refer to
9387
file_format_name_map[] defined in trx0sys.c for the next
9388
file format name. */
9389
static DRIZZLE_SYSVAR_STR(file_format_check, innobase_file_format_check,
9390
PLUGIN_VAR_OPCMDARG,
9391
"The highest file format in the tablespace.",
9392
innodb_file_format_check_validate,
9393
innodb_file_format_check_update,
9396
static DRIZZLE_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
9397
PLUGIN_VAR_OPCMDARG,
9398
"Set to 0 (write and flush once per second),"
9399
" 1 (write and flush at each commit)"
9400
" or 2 (write at commit, flush once per second).",
9401
NULL, NULL, 1, 0, 2, 0);
9403
static DRIZZLE_SYSVAR_STR(flush_method, innobase_file_flush_method,
9404
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9405
"With which method to flush data.", NULL, NULL, NULL);
9407
#ifdef UNIV_LOG_ARCHIVE
9408
static DRIZZLE_SYSVAR_STR(log_arch_dir, innobase_log_arch_dir,
9409
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9410
"Where full logs should be archived.", NULL, NULL, NULL);
9412
static DRIZZLE_SYSVAR_BOOL(log_archive, innobase_log_archive,
9413
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
9414
"Set to 1 if you want to have logs archived.", NULL, NULL, FALSE);
9415
#endif /* UNIV_LOG_ARCHIVE */
9417
static DRIZZLE_SYSVAR_STR(log_group_home_dir, innobase_log_group_home_dir,
9418
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9419
"Path to InnoDB log files.", NULL, NULL, NULL);
9421
static DRIZZLE_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
9422
PLUGIN_VAR_RQCMDARG,
9423
"Percentage of dirty pages allowed in bufferpool.",
9424
NULL, NULL, 75, 0, 99, 0);
9426
static DRIZZLE_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
9427
PLUGIN_VAR_NOCMDARG,
9428
"Attempt flushing dirty pages to avoid IO bursts at checkpoints.",
9431
static DRIZZLE_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
9432
PLUGIN_VAR_RQCMDARG,
9433
"Desired maximum length of the purge queue (0 = no limit)",
9434
NULL, NULL, 0, 0, ~0L, 0);
9436
static DRIZZLE_SYSVAR_BOOL(status_file, innobase_create_status_file,
9437
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_NOSYSVAR,
9438
"Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
9441
static DRIZZLE_SYSVAR_ULONGLONG(stats_sample_pages, srv_stats_sample_pages,
9442
PLUGIN_VAR_RQCMDARG,
9443
"The number of index pages to sample when calculating statistics (default 8)",
9444
NULL, NULL, 8, 1, ~0ULL, 0);
9446
static DRIZZLE_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
9447
PLUGIN_VAR_OPCMDARG,
9448
"Enable InnoDB adaptive hash index (enabled by default).",
9449
NULL, innodb_adaptive_hash_index_update, TRUE);
9451
static DRIZZLE_SYSVAR_ULONG(replication_delay, srv_replication_delay,
9452
PLUGIN_VAR_RQCMDARG,
9453
"Replication thread delay (ms) on the slave server if "
9454
"innodb_thread_concurrency is reached (0 by default)",
9455
NULL, NULL, 0, 0, ~0UL, 0);
9457
static DRIZZLE_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
9458
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9459
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
9460
NULL, NULL, 8*1024*1024L, 512*1024L, LONG_MAX, 1024);
9462
static DRIZZLE_SYSVAR_UINT(autoextend_increment, srv_auto_extend_increment,
9463
PLUGIN_VAR_RQCMDARG,
9464
"Data file autoextend increment in megabytes",
9465
NULL, NULL, 8L, 1L, 1000L, 0);
9467
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
9468
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9469
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
9470
NULL, NULL, 128*1024*1024L, 5*1024*1024L, INT64_MAX, 1024*1024L);
9472
static DRIZZLE_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency,
9473
PLUGIN_VAR_RQCMDARG,
9474
"Helps in performance tuning in heavily concurrent environments.",
9475
innobase_commit_concurrency_validate, NULL, 0, 0, 1000, 0);
9477
static DRIZZLE_SYSVAR_ULONG(concurrency_tickets, srv_n_free_tickets_to_enter,
9478
PLUGIN_VAR_RQCMDARG,
9479
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket",
9480
NULL, NULL, 500L, 1L, ~0L, 0);
9482
static DRIZZLE_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
9483
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9484
"Number of background read I/O threads in InnoDB.",
9485
NULL, NULL, 4, 1, 64, 0);
9487
static DRIZZLE_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
9488
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9489
"Number of background write I/O threads in InnoDB.",
9490
NULL, NULL, 4, 1, 64, 0);
9492
static DRIZZLE_SYSVAR_LONG(force_recovery, innobase_force_recovery,
9493
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9494
"Helps to save your data in case the disk image of the database becomes corrupt.",
9495
NULL, NULL, 0, 0, 6, 0);
9497
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
9498
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9499
"The size of the buffer which InnoDB uses to write log to the log files on disk.",
9500
NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
9502
static DRIZZLE_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
9503
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9504
"Size of each log file in a log group.",
9505
NULL, NULL, 20*1024*1024L, 1*1024*1024L, INT64_MAX, 1024*1024L);
9507
static DRIZZLE_SYSVAR_LONG(log_files_in_group, innobase_log_files_in_group,
9508
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9509
"Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here.",
9510
NULL, NULL, 2, 2, 100, 0);
9512
static DRIZZLE_SYSVAR_LONG(mirrored_log_groups, innobase_mirrored_log_groups,
9513
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9514
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.",
9515
NULL, NULL, 1, 1, 10, 0);
9517
static DRIZZLE_SYSVAR_UINT(old_blocks_pct, innobase_old_blocks_pct,
9518
PLUGIN_VAR_RQCMDARG,
9519
"Percentage of the buffer pool to reserve for 'old' blocks.",
9520
NULL, innodb_old_blocks_pct_update, 100 * 3 / 8, 5, 95, 0);
9522
static DRIZZLE_SYSVAR_UINT(old_blocks_time, buf_LRU_old_threshold_ms,
9523
PLUGIN_VAR_RQCMDARG,
9524
"Move blocks to the 'new' end of the buffer pool if the first access"
9525
" was at least this many milliseconds ago."
9526
" The timeout is disabled if 0 (the default).",
9527
NULL, NULL, 0, 0, UINT32_MAX, 0);
9529
static DRIZZLE_SYSVAR_LONG(open_files, innobase_open_files,
9530
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9531
"How many files at the maximum InnoDB keeps open at the same time.",
9532
NULL, NULL, 300L, 10L, LONG_MAX, 0);
9534
static DRIZZLE_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
9535
PLUGIN_VAR_RQCMDARG,
9536
"Count of spin-loop rounds in InnoDB mutexes (30 by default)",
9537
NULL, NULL, 30L, 0L, ~0L, 0);
9539
static DRIZZLE_SYSVAR_ULONG(spin_wait_delay, srv_spin_wait_delay,
9540
PLUGIN_VAR_OPCMDARG,
9541
"Maximum delay between polling for a spin lock (6 by default)",
9542
NULL, NULL, 6L, 0L, ~0L, 0);
9544
static DRIZZLE_SYSVAR_ULONG(thread_concurrency, srv_thread_concurrency,
9545
PLUGIN_VAR_RQCMDARG,
9546
"Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.",
9547
NULL, NULL, 0, 0, 1000, 0);
9549
static DRIZZLE_SYSVAR_ULONG(thread_sleep_delay, srv_thread_sleep_delay,
9550
PLUGIN_VAR_RQCMDARG,
9551
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep",
9552
NULL, NULL, 10000L, 0L, ~0L, 0);
9554
static DRIZZLE_SYSVAR_STR(data_file_path, innobase_data_file_path,
9555
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9556
"Path to individual files and their sizes.",
9559
static DRIZZLE_SYSVAR_STR(version, innodb_version_str,
9560
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
9561
"InnoDB version", NULL, NULL, INNODB_VERSION_STR);
9563
static DRIZZLE_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
9564
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
9565
"Use OS memory allocator instead of InnoDB's internal memory allocator",
9568
static DRIZZLE_SYSVAR_STR(change_buffering, innobase_change_buffering,
9569
PLUGIN_VAR_RQCMDARG,
9570
"Buffer changes to reduce random access: "
9571
"OFF, ON, none, inserts.",
9572
innodb_change_buffering_validate,
9573
innodb_change_buffering_update, NULL);
9575
static DRIZZLE_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold,
9576
PLUGIN_VAR_RQCMDARG,
9577
"Number of pages that must be accessed sequentially for InnoDB to "
9578
"trigger a readahead.",
9579
NULL, NULL, 56, 0, 64, 0);
9127
9581
static void init_options(drizzled::module::option_context &context)
9181
9633
context("disable-stats-on-metadata",
9182
9634
"Disable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)");
9183
9635
context("stats-sample-pages",
9184
po::value<uint64_nonzero_constraint>(&innodb_stats_sample_pages)->default_value(8),
9636
po::value<uint64_t>(&srv_stats_sample_pages)->default_value(8),
9185
9637
"The number of index pages to sample when calculating statistics (default 8)");
9186
9638
context("disable-adaptive-hash-index",
9187
9639
"Enable InnoDB adaptive hash index (enabled by default)");
9188
9640
context("replication-delay",
9189
po::value<uint64_constraint>(&innodb_replication_delay)->default_value(0),
9641
po::value<unsigned long>(&srv_replication_delay)->default_value(0),
9190
9642
"Replication thread delay (ms) on the slave server if innodb_thread_concurrency is reached (0 by default)");
9191
9643
context("additional-mem-pool-size",
9192
po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9644
po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9193
9645
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.");
9194
9646
context("autoextend-increment",
9195
po::value<autoextend_constraint>(&innodb_auto_extend_increment)->default_value(64L),
9647
po::value<uint32_t>(&srv_auto_extend_increment)->default_value(8L),
9196
9648
"Data file autoextend increment in megabytes");
9197
9649
context("buffer-pool-size",
9198
po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9650
po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9199
9651
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.");
9200
context("buffer-pool-instances",
9201
po::value<buffer_pool_instances_constraint>(&innobase_buffer_pool_instances)->default_value(1),
9202
"Number of buffer pool instances, set to higher value on high-end machines to increase scalability");
9204
9652
context("commit-concurrency",
9205
po::value<concurrency_constraint>(&innobase_commit_concurrency)->default_value(0),
9653
po::value<unsigned long>(&innobase_commit_concurrency)->default_value(0),
9206
9654
"Helps in performance tuning in heavily concurrent environments.");
9207
9655
context("concurrency-tickets",
9208
po::value<uint32_nonzero_constraint>(&innodb_concurrency_tickets)->default_value(500L),
9656
po::value<unsigned long>(&srv_n_free_tickets_to_enter)->default_value(500L),
9209
9657
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket");
9210
9658
context("read-io-threads",
9211
po::value<io_threads_constraint>(&innobase_read_io_threads)->default_value(4),
9659
po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
9212
9660
"Number of background read I/O threads in InnoDB.");
9213
9661
context("write-io-threads",
9214
po::value<io_threads_constraint>(&innobase_write_io_threads)->default_value(4),
9662
po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
9215
9663
"Number of background write I/O threads in InnoDB.");
9216
9664
context("force-recovery",
9217
po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
9665
po::value<long>(&innobase_force_recovery)->default_value(0),
9218
9666
"Helps to save your data in case the disk image of the database becomes corrupt.");
9219
9667
context("log-buffer-size",
9220
po::value<log_buffer_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9668
po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9221
9669
"The size of the buffer which InnoDB uses to write log to the log files on disk.");
9222
9670
context("log-file-size",
9223
po::value<log_file_constraint>(&innobase_log_file_size)->default_value(20*1024*1024L),
9671
po::value<int64_t>(&innobase_log_file_size)->default_value(20*1024*1024L),
9224
9672
"The size of the buffer which InnoDB uses to write log to the log files on disk.");
9225
9673
context("log-files-in-group",
9226
po::value<log_files_in_group_constraint>(&innobase_log_files_in_group)->default_value(2),
9674
po::value<long>(&innobase_log_files_in_group)->default_value(2),
9227
9675
"Number of log files in the log group. InnoDB writes to the files in a circular fashion.");
9228
9676
context("mirrored-log-groups",
9229
po::value<mirrored_log_groups_constraint>(&innobase_mirrored_log_groups)->default_value(1),
9677
po::value<long>(&innobase_mirrored_log_groups)->default_value(1),
9230
9678
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.");
9231
9679
context("open-files",
9232
po::value<open_files_constraint>(&innobase_open_files)->default_value(300L),
9680
po::value<long>(&innobase_open_files)->default_value(300L),
9233
9681
"How many files at the maximum InnoDB keeps open at the same time.");
9234
9682
context("sync-spin-loops",
9235
po::value<uint32_constraint>(&innodb_sync_spin_loops)->default_value(30L),
9683
po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
9236
9684
"Count of spin-loop rounds in InnoDB mutexes (30 by default)");
9237
9685
context("spin-wait-delay",
9238
po::value<uint32_constraint>(&innodb_spin_wait_delay)->default_value(6L),
9686
po::value<unsigned long>(&srv_spin_wait_delay)->default_value(6L),
9239
9687
"Maximum delay between polling for a spin lock (6 by default)");
9240
9688
context("thread-concurrency",
9241
po::value<concurrency_constraint>(&innobase_thread_concurrency)->default_value(0),
9689
po::value<unsigned long>(&srv_thread_concurrency)->default_value(0),
9242
9690
"Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.");
9243
9691
context("thread-sleep-delay",
9244
po::value<uint32_constraint>(&innodb_thread_sleep_delay)->default_value(10000L),
9692
po::value<unsigned long>(&srv_thread_sleep_delay)->default_value(10000L),
9245
9693
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep");
9246
9694
context("data-file-path",
9247
9695
po::value<string>(),
9251
9699
"InnoDB version");
9252
9700
context("use-internal-malloc",
9253
9701
"Use InnoDB's internal memory allocator instal of the OS memory allocator.");
9254
context("disable-native-aio",
9255
_("Do not use Native AIO library for IO, even if available"));
9256
9702
context("change-buffering",
9257
po::value<string>(&innobase_change_buffering),
9703
po::value<string>(),
9258
9704
"Buffer changes to reduce random access: OFF, ON, inserting, deleting, changing, or purging.");
9259
9705
context("read-ahead-threshold",
9260
po::value<read_ahead_threshold_constraint>(&innodb_read_ahead_threshold)->default_value(56),
9706
po::value<unsigned long>(&srv_read_ahead_threshold)->default_value(56),
9261
9707
"Number of pages that must be accessed sequentially for InnoDB to trigger a readahead.");
9262
9708
context("disable-xa",
9263
9709
"Disable InnoDB support for the XA two-phase commit");
9264
9710
context("disable-table-locks",
9265
9711
"Disable InnoDB locking in LOCK TABLES");
9266
9712
context("strict-mode",
9267
po::value<bool>(&strict_mode)->default_value(false)->zero_tokens(),
9713
po::value<bool>()->default_value(false)->zero_tokens(),
9268
9714
"Use strict mode when evaluating create options.");
9269
context("replication-log",
9270
po::value<bool>(&innobase_use_replication_log)->default_value(false),
9271
_("Enable internal replication log."));
9272
9715
context("lock-wait-timeout",
9273
po::value<lock_wait_constraint>(&lock_wait_timeout)->default_value(50),
9274
_("Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
9275
context("old-blocks-pct",
9276
po::value<old_blocks_constraint>(&innobase_old_blocks_pct)->default_value(100 * 3 / 8),
9277
_("Percentage of the buffer pool to reserve for 'old' blocks."));
9278
context("old-blocks-time",
9279
po::value<uint32_t>(&buf_LRU_old_threshold_ms)->default_value(0),
9280
_("ove blocks to the 'new' end of the buffer pool if the first access"
9281
" was at least this many milliseconds ago."
9282
" The timeout is disabled if 0 (the default)."));
9716
po::value<unsigned long>()->default_value(50),
9717
"Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.");
9720
static drizzle_sys_var* innobase_system_variables[]= {
9721
DRIZZLE_SYSVAR(additional_mem_pool_size),
9722
DRIZZLE_SYSVAR(autoextend_increment),
9723
DRIZZLE_SYSVAR(buffer_pool_size),
9724
DRIZZLE_SYSVAR(checksums),
9725
DRIZZLE_SYSVAR(commit_concurrency),
9726
DRIZZLE_SYSVAR(concurrency_tickets),
9727
DRIZZLE_SYSVAR(data_file_path),
9728
DRIZZLE_SYSVAR(data_home_dir),
9729
DRIZZLE_SYSVAR(doublewrite),
9730
DRIZZLE_SYSVAR(fast_shutdown),
9731
DRIZZLE_SYSVAR(read_io_threads),
9732
DRIZZLE_SYSVAR(write_io_threads),
9733
DRIZZLE_SYSVAR(file_per_table),
9734
DRIZZLE_SYSVAR(file_format),
9735
DRIZZLE_SYSVAR(file_format_check),
9736
DRIZZLE_SYSVAR(flush_log_at_trx_commit),
9737
DRIZZLE_SYSVAR(flush_method),
9738
DRIZZLE_SYSVAR(force_recovery),
9739
DRIZZLE_SYSVAR(lock_wait_timeout),
9740
#ifdef UNIV_LOG_ARCHIVE
9741
DRIZZLE_SYSVAR(log_arch_dir),
9742
DRIZZLE_SYSVAR(log_archive),
9743
#endif /* UNIV_LOG_ARCHIVE */
9744
DRIZZLE_SYSVAR(log_buffer_size),
9745
DRIZZLE_SYSVAR(log_file_size),
9746
DRIZZLE_SYSVAR(log_files_in_group),
9747
DRIZZLE_SYSVAR(log_group_home_dir),
9748
DRIZZLE_SYSVAR(max_dirty_pages_pct),
9749
DRIZZLE_SYSVAR(max_purge_lag),
9750
DRIZZLE_SYSVAR(adaptive_flushing),
9751
DRIZZLE_SYSVAR(mirrored_log_groups),
9752
DRIZZLE_SYSVAR(old_blocks_pct),
9753
DRIZZLE_SYSVAR(old_blocks_time),
9754
DRIZZLE_SYSVAR(open_files),
9755
DRIZZLE_SYSVAR(stats_sample_pages),
9756
DRIZZLE_SYSVAR(adaptive_hash_index),
9757
DRIZZLE_SYSVAR(replication_delay),
9758
DRIZZLE_SYSVAR(status_file),
9759
DRIZZLE_SYSVAR(strict_mode),
9760
DRIZZLE_SYSVAR(support_xa),
9761
DRIZZLE_SYSVAR(sync_spin_loops),
9762
DRIZZLE_SYSVAR(spin_wait_delay),
9763
DRIZZLE_SYSVAR(table_locks),
9764
DRIZZLE_SYSVAR(thread_concurrency),
9765
DRIZZLE_SYSVAR(thread_sleep_delay),
9766
DRIZZLE_SYSVAR(version),
9767
DRIZZLE_SYSVAR(use_sys_malloc),
9768
DRIZZLE_SYSVAR(change_buffering),
9769
DRIZZLE_SYSVAR(read_ahead_threshold),
9770
DRIZZLE_SYSVAR(io_capacity),
9287
9774
DRIZZLE_DECLARE_PLUGIN