2848
2840
static trinary_constraint srv_flush_log_at_trx_commit;
2849
2841
typedef constrained_check<uint16_t, 6, 0> force_recovery_constraint;
2850
2842
static force_recovery_constraint innobase_force_recovery;
2843
typedef constrained_check<int64_t, INT64_MAX, 1024*1024, 1024*1024> log_file_constraint;
2844
static log_file_constraint haildb_log_file_size;
2851
2846
static io_capacity_constraint srv_io_capacity;
2853
static long innobase_open_files;
2854
static long innobase_log_buffer_size;
2855
static char default_haildb_data_file_path[]= "ibdata1:10M:autoextend";
2856
static char* haildb_data_file_path= NULL;
2858
static int64_t haildb_log_file_size;
2859
static int64_t haildb_log_files_in_group;
2847
typedef constrained_check<unsigned int, 100, 2> log_files_in_group_constraint;
2848
static log_files_in_group_constraint haildb_log_files_in_group;
2849
typedef constrained_check<unsigned int, 1024*1024*1024, 1> lock_wait_constraint;
2850
static lock_wait_constraint innobase_lock_wait_timeout;
2851
typedef constrained_check<long, LONG_MAX, 256*1024, 1024> log_buffer_size_constraint;
2852
static log_buffer_size_constraint innobase_log_buffer_size;
2853
typedef constrained_check<unsigned int, 97, 5> lru_old_blocks_constraint;
2854
static lru_old_blocks_constraint innobase_lru_old_blocks_pct;
2855
typedef constrained_check<unsigned int, 99, 0> max_dirty_pages_constraint;
2856
static max_dirty_pages_constraint haildb_max_dirty_pages_pct;
2857
static uint64_constraint haildb_max_purge_lag;
2858
static uint64_constraint haildb_sync_spin_loops;
2859
typedef constrained_check<uint32_t, UINT32_MAX, 10> open_files_constraint;
2860
static open_files_constraint haildb_open_files;
2861
typedef constrained_check<unsigned int, 64, 1> io_threads_constraint;
2862
static io_threads_constraint haildb_read_io_threads;
2863
static io_threads_constraint haildb_write_io_threads;
2866
static uint32_t innobase_lru_block_access_recency;
2861
2870
static int haildb_file_format_name_validate(Session*, set_var *var)
2896
2929
innobase_print_verbose_log= (vm.count("disable-print-verbose-log")) ? false : true;
2897
2930
srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
2899
if (vm.count("log-file-size"))
2901
if (haildb_log_file_size > INT64_MAX || haildb_log_file_size < 1*1024*1024L)
2903
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-file-size"));
2906
haildb_log_file_size/= 1024*1024L;
2907
haildb_log_file_size*= 1024*1024L;
2910
if (vm.count("log-files-in-group"))
2912
if (haildb_log_files_in_group > 100 || haildb_log_files_in_group < 2)
2914
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-files-in-group"));
2919
if (vm.count("lock-wait-timeout"))
2921
if (innobase_lock_wait_timeout > 1024*1024*1024 || innobase_lock_wait_timeout < 1)
2923
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lock-wait-timeout"));
2928
if (vm.count("log-buffer-size"))
2930
if (innobase_log_buffer_size > LONG_MAX || innobase_log_buffer_size < 256*1024L)
2932
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-buffer-size"));
2935
innobase_log_buffer_size/= 1024;
2936
innobase_log_buffer_size*= 1024;
2939
if (vm.count("lru-old-blocks-pct"))
2941
if (innobase_lru_old_blocks_pct > 95 || innobase_lru_old_blocks_pct < 5)
2943
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-old-blocks-pct"));
2948
if (vm.count("lru-block-access-recency"))
2950
if (innobase_lru_block_access_recency > ULONG_MAX)
2952
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-block-access-recency"));
2957
if (vm.count("max-dirty-pages-pct"))
2959
if (srv_max_buf_pool_modified_pct > 99)
2961
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-dirty-pages-pct"));
2966
if (vm.count("max-purge-lag"))
2968
if (srv_max_purge_lag > (unsigned long)~0L)
2970
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-purge-lag"));
2975
if (vm.count("open-files"))
2977
if (innobase_open_files > LONG_MAX || innobase_open_files < 10L)
2979
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of open-files"));
2984
if (vm.count("read-io-threads"))
2986
if (innobase_read_io_threads > 64 || innobase_read_io_threads < 1)
2988
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of read-io-threads"));
2993
if (vm.count("sync-spin-loops"))
2995
if (srv_n_spin_wait_rounds > (unsigned long)~0L)
2997
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of sync_spin_loops"));
3002
if (vm.count("data-file-path"))
3004
haildb_data_file_path= const_cast<char *>(vm["data-file-path"].as<string>().c_str());
3185
3108
&innobase_use_checksums));
3186
3109
context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite",
3187
3110
&innobase_use_doublewrite));
3111
context.registerVariable(new sys_var_const_string_val("data_file_path",
3112
vm["data-file-path"].as<string>()));
3188
3113
context.registerVariable(new sys_var_const_string_val("data_home_dir",
3189
vm.count("data-home-dir") ? vm["data-home-dir"].as<string>() : ""));
3114
vm["data-home-dir"].as<string>()));
3190
3115
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("io_capacity", srv_io_capacity));
3191
3116
context.registerVariable(new sys_var_constrained_value_readonly<uint16_t>("fast_shutdown", innobase_fast_shutdown));
3192
3117
context.registerVariable(new sys_var_bool_ptr_readonly("file_per_table",
3193
3118
&srv_file_per_table));
3194
context.registerVariable(new sys_var_std_string("file-format",
3119
context.registerVariable(new sys_var_bool_ptr_readonly("rollback_on_timeout",
3120
&innobase_rollback_on_timeout));
3121
context.registerVariable(new sys_var_bool_ptr_readonly("print_verbose_log",
3122
&innobase_print_verbose_log));
3123
context.registerVariable(new sys_var_bool_ptr("status_file",
3124
&innobase_create_status_file,
3125
haildb_status_file_update));
3126
context.registerVariable(new sys_var_bool_ptr_readonly("use_sys_malloc",
3127
&srv_use_sys_malloc));
3128
context.registerVariable(new sys_var_std_string("file_format",
3195
3129
innobase_file_format_name,
3196
3130
haildb_file_format_name_validate));
3197
3131
context.registerVariable(new sys_var_constrained_value_readonly<uint16_t>("flush_log_at_trx_commit", srv_flush_log_at_trx_commit));
3200
3134
context.registerVariable(new sys_var_constrained_value_readonly<uint16_t>("force_recovery", innobase_force_recovery));
3201
3135
context.registerVariable(new sys_var_const_string_val("log_group_home_dir",
3202
3136
vm.count("log-group-home-dir") ? vm["log-group-home-dir"].as<string>() : ""));
3137
context.registerVariable(new sys_var_constrained_value<int64_t>("log_file_size", haildb_log_file_size));
3138
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("log_files_in_group", haildb_log_files_in_group));
3139
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("lock_wait_timeout", innobase_lock_wait_timeout));
3140
context.registerVariable(new sys_var_constrained_value_readonly<long>("log_buffer_size", innobase_log_buffer_size));
3141
context.registerVariable(new sys_var_constrained_value<unsigned int>("lru_old_blocks_pct", innobase_lru_old_blocks_pct, haildb_lru_old_blocks_pct_update));
3142
context.registerVariable(new sys_var_uint32_t_ptr("lru_block_access_recency",
3143
&innobase_lru_block_access_recency,
3144
haildb_lru_block_access_recency_update));
3145
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("max_dirty_pages_pct", haildb_max_dirty_pages_pct));
3146
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("max_purge_lag", haildb_max_purge_lag));
3147
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("sync_spin_loops", haildb_sync_spin_loops));
3148
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("open_files", haildb_open_files));
3149
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("read_io_threads", haildb_read_io_threads));
3150
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("write_io_threads", haildb_write_io_threads));
3204
3152
haildb_datadict_dump_func_initialize(context);
3205
3153
config_table_function_initialize(context);
3236
static void haildb_lru_old_blocks_pct_update(Session*, drizzle_sys_var*,
3243
pct= *static_cast<const unsigned long*>(save);
3245
ib_err_t err= ib_cfg_set_int("lru_old_blocks_pct", pct);
3246
if (err == DB_SUCCESS)
3247
innobase_lru_old_blocks_pct= pct;
3250
static void haildb_lru_block_access_recency_update(Session*, drizzle_sys_var*,
3257
ms= *static_cast<const unsigned long*>(save);
3259
ib_err_t err= ib_cfg_set_int("lru_block_access_recency", ms);
3261
if (err == DB_SUCCESS)
3262
innobase_lru_block_access_recency= ms;
3265
static void haildb_status_file_update(Session*, drizzle_sys_var*,
3270
bool status_file_enabled;
3273
status_file_enabled= *static_cast<const bool*>(save);
3276
if (status_file_enabled)
3277
err= ib_cfg_set_bool_on("status_file");
3279
err= ib_cfg_set_bool_off("status_file");
3281
if (err == DB_SUCCESS)
3282
innobase_create_status_file= status_file_enabled;
3285
static DRIZZLE_SYSVAR_STR(data_file_path, haildb_data_file_path,
3286
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3287
"Path to individual files and their sizes.",
3290
static DRIZZLE_SYSVAR_LONGLONG(log_file_size, haildb_log_file_size,
3291
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3292
"Size of each log file in a log group.",
3293
NULL, NULL, 20*1024*1024L, 1*1024*1024L, INT64_MAX, 1024*1024L);
3295
static DRIZZLE_SYSVAR_LONGLONG(log_files_in_group, haildb_log_files_in_group,
3296
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3297
"Number of log files in the log group. HailDB writes to the files in a circular fashion. Value 3 is recommended here.",
3298
NULL, NULL, 2, 2, 100, 0);
3300
static DRIZZLE_SYSVAR_ULONG(lock_wait_timeout, innobase_lock_wait_timeout,
3301
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3302
"Timeout in seconds an HailDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
3303
NULL, NULL, 5, 1, 1024 * 1024 * 1024, 0);
3305
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
3306
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3307
"The size of the buffer which HailDB uses to write log to the log files on disk.",
3308
NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
3310
static DRIZZLE_SYSVAR_ULONG(lru_old_blocks_pct, innobase_lru_old_blocks_pct,
3311
PLUGIN_VAR_RQCMDARG,
3312
"Sets the point in the LRU list from where all pages are classified as "
3313
"old (Advanced users)",
3315
haildb_lru_old_blocks_pct_update, 37, 5, 95, 0);
3317
static DRIZZLE_SYSVAR_ULONG(lru_block_access_recency, innobase_lru_block_access_recency,
3318
PLUGIN_VAR_RQCMDARG,
3319
"Milliseconds between accesses to a block at which it is made young. "
3320
"0=disabled (Advanced users)",
3322
haildb_lru_block_access_recency_update, 0, 0, ULONG_MAX, 0);
3325
static DRIZZLE_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
3326
PLUGIN_VAR_RQCMDARG,
3327
"Percentage of dirty pages allowed in bufferpool.",
3328
NULL, NULL, 75, 0, 99, 0);
3330
static DRIZZLE_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
3331
PLUGIN_VAR_RQCMDARG,
3332
"Desired maximum length of the purge queue (0 = no limit)",
3333
NULL, NULL, 0, 0, ~0L, 0);
3335
static DRIZZLE_SYSVAR_BOOL(rollback_on_timeout, innobase_rollback_on_timeout,
3336
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
3337
"Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)",
3340
static DRIZZLE_SYSVAR_LONG(open_files, innobase_open_files,
3341
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3342
"How many files at the maximum HailDB keeps open at the same time.",
3343
NULL, NULL, 300L, 10L, LONG_MAX, 0);
3345
static DRIZZLE_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
3346
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3347
"Number of background read I/O threads in HailDB.",
3348
NULL, NULL, 4, 1, 64, 0);
3350
static DRIZZLE_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
3351
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3352
"Number of background write I/O threads in HailDB.",
3353
NULL, NULL, 4, 1, 64, 0);
3355
static DRIZZLE_SYSVAR_BOOL(print_verbose_log, innobase_print_verbose_log,
3356
PLUGIN_VAR_NOCMDARG,
3357
"Disable if you want to reduce the number of messages written to the log (default: enabled).",
3360
static DRIZZLE_SYSVAR_BOOL(status_file, innobase_create_status_file,
3361
PLUGIN_VAR_OPCMDARG,
3362
"Enable SHOW HAILDB STATUS output in the log",
3363
NULL, haildb_status_file_update, false);
3365
static DRIZZLE_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
3366
PLUGIN_VAR_RQCMDARG,
3367
"Count of spin-loop rounds in HailDB mutexes (30 by default)",
3368
NULL, NULL, 30L, 0L, ~0L, 0);
3370
static DRIZZLE_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
3371
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
3372
"Use OS memory allocator instead of HailDB's internal memory allocator",
3375
3184
static void init_options(drizzled::module::option_context &context)
3377
3186
context("disable-adaptive-hash-index",
3416
3225
po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
3417
3226
N_("Helps to save your data in case the disk image of the database becomes corrupt."));
3418
3227
context("data-file-path",
3419
po::value<string>(),
3228
po::value<string>()->default_value("ibdata1:10M:autoextend"),
3420
3229
N_("Path to individual files and their sizes."));
3421
3230
context("log-group-home-dir",
3422
3231
po::value<string>(),
3423
3232
N_("Path to HailDB log files."));
3424
3233
context("log-file-size",
3425
po::value<int64_t>(&haildb_log_file_size)->default_value(20*1024*1024L),
3234
po::value<log_file_constraint>(&haildb_log_file_size)->default_value(20*1024*1024L),
3426
3235
N_("Size of each log file in a log group."));
3427
3236
context("haildb-log-files-in-group",
3428
po::value<int64_t>(&haildb_log_files_in_group)->default_value(2),
3237
po::value<log_files_in_group_constraint>(&haildb_log_files_in_group)->default_value(2),
3429
3238
N_("Number of log files in the log group. HailDB writes to the files in a circular fashion. Value 3 is recommended here."));
3430
3239
context("lock-wait-timeout",
3431
po::value<unsigned long>(&innobase_lock_wait_timeout)->default_value(5),
3240
po::value<lock_wait_constraint>(&innobase_lock_wait_timeout)->default_value(5),
3432
3241
N_("Timeout in seconds an HailDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
3433
3242
context("log-buffer-size",
3434
po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
3243
po::value<log_buffer_size_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
3435
3244
N_("The size of the buffer which HailDB uses to write log to the log files on disk."));
3436
3245
context("lru-old-blocks-pct",
3437
po::value<unsigned long>(&innobase_lru_old_blocks_pct)->default_value(37),
3246
po::value<lru_old_blocks_constraint>(&innobase_lru_old_blocks_pct)->default_value(37),
3438
3247
N_("Sets the point in the LRU list from where all pages are classified as old (Advanced users)"));
3439
3248
context("lru-block-access-recency",
3440
po::value<unsigned long>(&innobase_lru_block_access_recency)->default_value(0),
3249
po::value<uint32_t>(&innobase_lru_block_access_recency)->default_value(0),
3441
3250
N_("Milliseconds between accesses to a block at which it is made young. 0=disabled (Advanced users)"));
3442
3251
context("max-dirty-pages-pct",
3443
po::value<unsigned long>(&srv_max_buf_pool_modified_pct)->default_value(75),
3252
po::value<max_dirty_pages_constraint>(&haildb_max_dirty_pages_pct)->default_value(75),
3444
3253
N_("Percentage of dirty pages allowed in bufferpool."));
3445
3254
context("max-purge-lag",
3446
po::value<unsigned long>(&srv_max_purge_lag)->default_value(0),
3255
po::value<uint64_constraint>(&haildb_max_purge_lag)->default_value(0),
3447
3256
N_("Desired maximum length of the purge queue (0 = no limit)"));
3448
3257
context("rollback-on-timeout",
3449
3258
po::value<bool>(&innobase_rollback_on_timeout)->default_value(false)->zero_tokens(),
3450
3259
N_("Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)"));
3451
3260
context("open-files",
3452
po::value<long>(&innobase_open_files)->default_value(300),
3261
po::value<open_files_constraint>(&haildb_open_files)->default_value(300),
3453
3262
N_("How many files at the maximum HailDB keeps open at the same time."));
3454
3263
context("read-io-threads",
3455
po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
3264
po::value<io_threads_constraint>(&haildb_read_io_threads)->default_value(4),
3456
3265
N_("Number of background read I/O threads in HailDB."));
3457
3266
context("write-io-threads",
3458
po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
3267
po::value<io_threads_constraint>(&haildb_write_io_threads)->default_value(4),
3459
3268
N_("Number of background write I/O threads in HailDB."));
3460
3269
context("disable-print-verbose-log",
3461
3270
N_("Disable if you want to reduce the number of messages written to the log (default: enabled)."));
3463
3272
po::value<bool>(&innobase_create_status_file)->default_value(false)->zero_tokens(),
3464
3273
N_("Enable SHOW HAILDB STATUS output in the log"));
3465
3274
context("sync-spin-loops",
3466
po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
3275
po::value<uint64_constraint>(&haildb_sync_spin_loops)->default_value(30L),
3467
3276
N_("Count of spin-loop rounds in HailDB mutexes (30 by default)"));
3468
3277
context("use-internal-malloc",
3469
3278
N_("Use HailDB's internal memory allocator instead of the OS memory allocator"));
3472
static drizzle_sys_var* innobase_system_variables[]= {
3473
DRIZZLE_SYSVAR(data_file_path),
3474
DRIZZLE_SYSVAR(lock_wait_timeout),
3475
DRIZZLE_SYSVAR(log_file_size),
3476
DRIZZLE_SYSVAR(log_files_in_group),
3477
DRIZZLE_SYSVAR(log_buffer_size),
3478
DRIZZLE_SYSVAR(lru_old_blocks_pct),
3479
DRIZZLE_SYSVAR(lru_block_access_recency),
3480
DRIZZLE_SYSVAR(max_dirty_pages_pct),
3481
DRIZZLE_SYSVAR(max_purge_lag),
3482
DRIZZLE_SYSVAR(open_files),
3483
DRIZZLE_SYSVAR(read_io_threads),
3484
DRIZZLE_SYSVAR(rollback_on_timeout),
3485
DRIZZLE_SYSVAR(write_io_threads),
3486
DRIZZLE_SYSVAR(print_verbose_log),
3487
DRIZZLE_SYSVAR(status_file),
3488
DRIZZLE_SYSVAR(sync_spin_loops),
3489
DRIZZLE_SYSVAR(use_sys_malloc),
3493
3281
DRIZZLE_DECLARE_PLUGIN
3495
3283
DRIZZLE_VERSION_ID,