2015
1987
tuple= ib_tuple_clear(tuple);
2016
1988
ib_tuple_delete(tuple);
2018
1989
err= ib_cursor_reset(cursor);
2023
int HailDBCursor::doUpdateRecord(const unsigned char *old_data,
2024
unsigned char *new_data)
1994
int HailDBCursor::doUpdateRecord(const unsigned char *,
2026
1997
ib_tpl_t update_tuple;
2028
bool created_tuple= false;
2030
2000
update_tuple= ib_clust_read_tuple_create(cursor);
2034
ib_trx_t transaction= *get_trx(getTable()->in_use);
2036
if (cursor_is_sec_index)
2038
err= ib_cursor_close(cursor);
2039
assert(err == DB_SUCCESS);
2041
err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2043
if (err != DB_SUCCESS)
2044
return ib_err_t_to_drizzle_error(err);
2045
cursor_is_sec_index= false;
2049
ib_cursor_attach_trx(cursor, transaction);
2052
store_key_value_from_haildb(getTable()->key_info + getTable()->getShare()->getPrimaryKey(),
2053
ref, ref_length, old_data);
2055
ib_tpl_t search_tuple= ib_clust_search_tuple_create(cursor);
2057
fill_ib_search_tpl_from_drizzle_key(search_tuple,
2058
getTable()->key_info + 0,
2061
err= ib_cursor_set_lock_mode(cursor, IB_LOCK_X);
2062
assert(err == DB_SUCCESS);
2065
err= ib_cursor_moveto(cursor, search_tuple, IB_CUR_GE, &res);
2066
assert(err == DB_SUCCESS);
2068
tuple= ib_clust_read_tuple_create(cursor);
2070
err= ib_cursor_read_row(cursor, tuple);
2071
assert(err == DB_SUCCESS);// FIXME
2073
created_tuple= true;
2076
2002
err= ib_tuple_copy(update_tuple, tuple);
2077
2003
assert(err == DB_SUCCESS);
2079
write_row_to_haildb_tuple(new_data, getTable()->getFields(), update_tuple);
2005
write_row_to_haildb_tuple(table->getFields(), update_tuple);
2081
2007
err= ib_cursor_update_row(cursor, tuple, update_tuple);
2083
2009
ib_tuple_delete(update_tuple);
2087
ib_err_t ib_err= ib_cursor_reset(cursor); //fixme check error
2088
assert(ib_err == DB_SUCCESS);
2089
tuple= ib_tuple_clear(tuple);
2090
ib_tuple_delete(tuple);
2094
2011
advance_cursor= true;
2096
return ib_err_t_to_drizzle_error(err);
2013
if (err == DB_SUCCESS)
2015
else if (err == DB_DUPLICATE_KEY)
2016
return HA_ERR_FOUND_DUPP_KEY;
2099
2021
int HailDBCursor::doDeleteRecord(const unsigned char *)
2103
assert(ib_cursor_is_positioned(cursor) == IB_TRUE);
2104
2025
err= ib_cursor_delete_row(cursor);
2026
if (err != DB_SUCCESS)
2106
2029
advance_cursor= true;
2108
return ib_err_t_to_drizzle_error(err);
2111
2033
int HailDBCursor::delete_all_rows(void)
2113
2035
/* I *think* ib_truncate is non-transactional....
2114
2036
so only support TRUNCATE and not DELETE FROM t;
2115
(this is what ha_innodb does)
2037
(this is what ha_haildb does)
2117
if (session_sql_command(getTable()->in_use) != SQLCOM_TRUNCATE)
2039
if (session_sql_command(table->in_use) != SQLCOM_TRUNCATE)
2118
2040
return HA_ERR_WRONG_COMMAND;
2473
2354
double HailDBCursor::scan_time()
2475
ib_table_stats_t table_stats;
2478
err= ib_get_table_statistics(cursor, &table_stats, sizeof(table_stats));
2480
/* Approximate I/O seeks for full table scan */
2481
return (double) (table_stats.stat_clustered_index_size / 16384);
2484
2359
int HailDBCursor::info(uint32_t flag)
2486
ib_table_stats_t table_stats;
2489
if (flag & HA_STATUS_VARIABLE)
2491
err= ib_get_table_statistics(cursor, &table_stats, sizeof(table_stats));
2493
stats.records= table_stats.stat_n_rows;
2495
if (table_stats.stat_n_rows < 2)
2499
stats.data_file_length= table_stats.stat_clustered_index_size;
2500
stats.index_file_length= table_stats.stat_sum_of_other_index_sizes;
2502
stats.mean_rec_length= stats.data_file_length / stats.records;
2505
2363
if (flag & HA_STATUS_AUTO)
2506
2364
stats.auto_increment_value= 1;
2508
if (flag & HA_STATUS_ERRKEY) {
2509
const char *err_table_name;
2510
const char *err_index_name;
2512
ib_trx_t transaction= *get_trx(getTable()->in_use);
2514
err= ib_get_duplicate_key(transaction, &err_table_name, &err_index_name);
2518
for (unsigned int i = 0; i < getTable()->getShare()->keys; i++)
2520
if (strcmp(err_index_name, getTable()->key_info[i].name) == 0)
2532
2368
int HailDBCursor::doStartIndexScan(uint32_t keynr, bool)
2535
ib_trx_t transaction= *get_trx(getTable()->in_use);
2370
ib_trx_t transaction= *get_trx(table->in_use);
2537
2372
active_index= keynr;
2374
ib_cursor_attach_trx(cursor, transaction);
2539
2376
if (active_index == 0 && ! share->has_hidden_primary_key)
2541
if (cursor_is_sec_index)
2543
err= ib_cursor_close(cursor);
2544
assert(err == DB_SUCCESS);
2546
err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2548
if (err != DB_SUCCESS)
2549
return ib_err_t_to_drizzle_error(err);
2554
ib_cursor_attach_trx(cursor, transaction);
2557
cursor_is_sec_index= false;
2558
2378
tuple= ib_clust_read_tuple_create(cursor);
2562
2383
ib_id_t index_id;
2563
err= ib_index_get_id(table_path_to_haildb_name(getShare()->getPath()),
2564
getShare()->getKeyInfo(keynr).name,
2384
err= ib_index_get_id(table_path_to_haildb_name(table_share->getPath()),
2385
table_share->getKeyInfo(keynr).name,
2566
2387
if (err != DB_SUCCESS)
2567
return ib_err_t_to_drizzle_error(err);
2569
2390
err= ib_cursor_close(cursor);
2570
2391
assert(err == DB_SUCCESS);
2572
2392
err= ib_cursor_open_index_using_id(index_id, transaction, &cursor);
2574
2394
if (err != DB_SUCCESS)
2575
return ib_err_t_to_drizzle_error(err);
2577
cursor_is_sec_index= true;
2579
2397
tuple= ib_clust_read_tuple_create(cursor);
2580
2398
ib_cursor_set_cluster_access(cursor);
2583
err= ib_cursor_set_lock_mode(cursor, ib_lock_mode);
2401
ib_err_t err= ib_cursor_set_lock_mode(cursor, ib_lock_mode);
2584
2402
assert(err == DB_SUCCESS);
2586
2404
advance_cursor= false;
2991
2814
static bool innobase_rollback_on_timeout;
2992
2815
static bool innobase_create_status_file;
2993
2816
static bool srv_use_sys_malloc;
2994
static string innobase_file_format_name;
2995
typedef constrained_check<unsigned int, 1000, 1> autoextend_constraint;
2996
static autoextend_constraint srv_auto_extend_increment;
2997
typedef constrained_check<size_t, SIZE_MAX, 5242880, 1048576> buffer_pool_constraint;
2998
static buffer_pool_constraint innobase_buffer_pool_size;
2999
typedef constrained_check<size_t, SIZE_MAX, 512, 1024> additional_mem_pool_constraint;
3000
static additional_mem_pool_constraint innobase_additional_mem_pool_size;
3001
static bool innobase_use_checksums= true;
3002
typedef constrained_check<unsigned int, UINT_MAX, 100> io_capacity_constraint;
3003
typedef constrained_check<uint32_t, 2, 0> trinary_constraint;
3004
static trinary_constraint innobase_fast_shutdown;
3005
static trinary_constraint srv_flush_log_at_trx_commit;
3006
typedef constrained_check<uint32_t, 6, 0> force_recovery_constraint;
3007
static force_recovery_constraint innobase_force_recovery;
3008
typedef constrained_check<int64_t, INT64_MAX, 1024*1024, 1024*1024> log_file_constraint;
3009
static log_file_constraint haildb_log_file_size;
3011
static io_capacity_constraint srv_io_capacity;
3012
typedef constrained_check<unsigned int, 100, 2> log_files_in_group_constraint;
3013
static log_files_in_group_constraint haildb_log_files_in_group;
3014
typedef constrained_check<unsigned int, 1024*1024*1024, 1> lock_wait_constraint;
3015
static lock_wait_constraint innobase_lock_wait_timeout;
3016
typedef constrained_check<long, LONG_MAX, 256*1024, 1024> log_buffer_size_constraint;
3017
static log_buffer_size_constraint innobase_log_buffer_size;
3018
typedef constrained_check<unsigned int, 97, 5> lru_old_blocks_constraint;
3019
static lru_old_blocks_constraint innobase_lru_old_blocks_pct;
3020
typedef constrained_check<unsigned int, 99, 0> max_dirty_pages_constraint;
3021
static max_dirty_pages_constraint haildb_max_dirty_pages_pct;
3022
static uint64_constraint haildb_max_purge_lag;
3023
static uint64_constraint haildb_sync_spin_loops;
3024
typedef constrained_check<uint32_t, UINT32_MAX, 10> open_files_constraint;
3025
static open_files_constraint haildb_open_files;
3026
typedef constrained_check<unsigned int, 64, 1> io_threads_constraint;
3027
static io_threads_constraint haildb_read_io_threads;
3028
static io_threads_constraint haildb_write_io_threads;
3031
static uint32_t innobase_lru_block_access_recency;
3035
static int haildb_file_format_name_validate(Session*, set_var *var)
3038
const char *format= var->value->str_value.ptr();
3042
ib_err_t err= ib_cfg_set_text("file_format", format);
3044
if (err == DB_SUCCESS)
3046
innobase_file_format_name= format;
3053
static void haildb_lru_old_blocks_pct_update(Session*, sql_var_t)
3055
int ret= ib_cfg_set_int("lru_old_blocks_pct", static_cast<uint32_t>(innobase_lru_old_blocks_pct));
3059
static void haildb_lru_block_access_recency_update(Session*, sql_var_t)
3061
int ret= ib_cfg_set_int("lru_block_access_recency", static_cast<uint32_t>(innobase_lru_block_access_recency));
3065
static void haildb_status_file_update(Session*, sql_var_t)
3069
if (innobase_create_status_file)
3070
err= ib_cfg_set_bool_on("status_file");
3072
err= ib_cfg_set_bool_off("status_file");
3076
extern "C" int haildb_errmsg_callback(ib_msg_stream_t, const char *fmt, ...);
3079
extern bool volatile shutdown_in_progress;
3082
extern "C" int haildb_errmsg_callback(ib_msg_stream_t, const char *fmt, ...)
3086
va_start(args, fmt);
3087
if (! shutdown_in_progress)
3088
r= plugin::ErrorMessage::vprintf(NULL, ERRMSG_LVL_WARN, fmt, args);
3090
vfprintf(stderr, fmt, args);
2817
static char* innobase_file_format_name = const_cast<char *>("Barracuda");
2818
static char* innobase_unix_file_flush_method = NULL;
2819
static unsigned long srv_flush_log_at_trx_commit;
2820
static unsigned long srv_max_buf_pool_modified_pct;
2821
static unsigned long srv_max_purge_lag;
2822
static unsigned long innobase_lru_old_blocks_pct;
2823
static unsigned long innobase_lru_block_access_recency;
2824
static unsigned long innobase_read_io_threads;
2825
static unsigned long innobase_write_io_threads;
2826
static unsigned int srv_auto_extend_increment;
2827
static unsigned long innobase_lock_wait_timeout;
2828
static unsigned long srv_n_spin_wait_rounds;
2829
static int64_t innobase_buffer_pool_size;
2830
static long innobase_open_files;
2831
static long innobase_additional_mem_pool_size;
2832
static long innobase_force_recovery;
2833
static long innobase_log_buffer_size;
2834
static char default_haildb_data_file_path[]= "ibdata1:10M:autoextend";
2835
static char* haildb_data_file_path= NULL;
2837
static int64_t haildb_log_file_size;
2838
static int64_t haildb_log_files_in_group;
3096
2840
static int haildb_init(drizzled::module::Context &context)
3113
2857
innobase_print_verbose_log= (vm.count("disable-print-verbose-log")) ? false : true;
3114
2858
srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
2860
if (vm.count("additional-mem-pool-size"))
2862
if (innobase_additional_mem_pool_size > LONG_MAX || innobase_additional_mem_pool_size < 512*1024L)
2864
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of additional-mem-pool-size"));
2867
innobase_additional_mem_pool_size/= 1024;
2868
innobase_additional_mem_pool_size*= 1024;
2871
if (vm.count("autoextend-increment"))
2873
if (srv_auto_extend_increment > 1000L || srv_auto_extend_increment < 1L)
2875
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of autoextend-increment"));
2880
if (vm.count("buffer-pool-size"))
2882
if (innobase_buffer_pool_size > INT64_MAX || innobase_buffer_pool_size < 5*1024*1024L)
2884
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of buffer-pool-size"));
2887
innobase_buffer_pool_size/= 1024*1024L;
2888
innobase_buffer_pool_size*= 1024*1024L;
2891
if (vm.count("io-capacity"))
2893
if (srv_io_capacity > (unsigned long)~0L || srv_io_capacity < 100)
2895
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of io-capacity"));
2900
if (vm.count("fast-shutdown"))
2902
if (innobase_fast_shutdown > 2)
2904
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of fast-shutdown"));
2909
if (vm.count("flush-log-at-trx-commit"))
2911
if (srv_flush_log_at_trx_commit > 2)
2913
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of flush-log-at-trx-commit"));
2918
if (vm.count("force-recovery"))
2920
if (innobase_force_recovery > 6)
2922
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of force-recovery"));
2927
if (vm.count("log-file-size"))
2929
if (haildb_log_file_size > INT64_MAX || haildb_log_file_size < 1*1024*1024L)
2931
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-file-size"));
2934
haildb_log_file_size/= 1024*1024L;
2935
haildb_log_file_size*= 1024*1024L;
2938
if (vm.count("log-files-in-group"))
2940
if (haildb_log_files_in_group > 100 || haildb_log_files_in_group < 2)
2942
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-files-in-group"));
2947
if (vm.count("lock-wait-timeout"))
2949
if (innobase_lock_wait_timeout > 1024*1024*1024 || innobase_lock_wait_timeout < 1)
2951
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lock-wait-timeout"));
2956
if (vm.count("log-buffer-size"))
2958
if (innobase_log_buffer_size > LONG_MAX || innobase_log_buffer_size < 256*1024L)
2960
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-buffer-size"));
2963
innobase_log_buffer_size/= 1024;
2964
innobase_log_buffer_size*= 1024;
2967
if (vm.count("lru-old-blocks-pct"))
2969
if (innobase_lru_old_blocks_pct > 95 || innobase_lru_old_blocks_pct < 5)
2971
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-old-blocks-pct"));
2976
if (vm.count("lru-block-access-recency"))
2978
if (innobase_lru_block_access_recency > ULONG_MAX)
2980
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-block-access-recency"));
2985
if (vm.count("max-dirty-pages-pct"))
2987
if (srv_max_buf_pool_modified_pct > 99)
2989
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-dirty-pages-pct"));
2994
if (vm.count("max-purge-lag"))
2996
if (srv_max_purge_lag > (unsigned long)~0L)
2998
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-purge-lag"));
3003
if (vm.count("open-files"))
3005
if (innobase_open_files > LONG_MAX || innobase_open_files < 10L)
3007
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of open-files"));
3012
if (vm.count("read-io-threads"))
3014
if (innobase_read_io_threads > 64 || innobase_read_io_threads < 1)
3016
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of read-io-threads"));
3021
if (vm.count("sync-spin-loops"))
3023
if (srv_n_spin_wait_rounds > (unsigned long)~0L)
3025
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of sync_spin_loops"));
3030
if (vm.count("data-home-dir"))
3032
innobase_data_home_dir= const_cast<char *>(vm["data-home-dir"].as<string>().c_str());
3035
if (vm.count("file-format"))
3037
innobase_file_format_name= const_cast<char *>(vm["file-format"].as<string>().c_str());
3040
if (vm.count("log-group-home-dir"))
3042
innobase_log_group_home_dir= const_cast<char *>(vm["log-group-home-dir"].as<string>().c_str());
3045
if (vm.count("flush-method"))
3047
innobase_unix_file_flush_method= const_cast<char *>(vm["flush-method"].as<string>().c_str());
3050
if (vm.count("data-file-path"))
3052
haildb_data_file_path= const_cast<char *>(vm["data-file-path"].as<string>().c_str());
3283
3219
haildb_engine= new HailDBEngine("InnoDB");
3284
3220
context.add(haildb_engine);
3285
context.registerVariable(new sys_var_bool_ptr_readonly("adaptive_hash_index",
3286
&innobase_adaptive_hash_index));
3287
context.registerVariable(new sys_var_bool_ptr_readonly("adaptive_flushing",
3288
&srv_adaptive_flushing));
3289
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
3290
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("autoextend_increment", srv_auto_extend_increment));
3291
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("buffer_pool_size", innobase_buffer_pool_size));
3292
context.registerVariable(new sys_var_bool_ptr_readonly("checksums",
3293
&innobase_use_checksums));
3294
context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite",
3295
&innobase_use_doublewrite));
3296
context.registerVariable(new sys_var_const_string_val("data_file_path",
3297
vm["data-file-path"].as<string>()));
3298
context.registerVariable(new sys_var_const_string_val("data_home_dir",
3299
vm["data-home-dir"].as<string>()));
3300
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("io_capacity", srv_io_capacity));
3301
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("fast_shutdown", innobase_fast_shutdown));
3302
context.registerVariable(new sys_var_bool_ptr_readonly("file_per_table",
3303
&srv_file_per_table));
3304
context.registerVariable(new sys_var_bool_ptr_readonly("rollback_on_timeout",
3305
&innobase_rollback_on_timeout));
3306
context.registerVariable(new sys_var_bool_ptr_readonly("print_verbose_log",
3307
&innobase_print_verbose_log));
3308
context.registerVariable(new sys_var_bool_ptr("status_file",
3309
&innobase_create_status_file,
3310
haildb_status_file_update));
3311
context.registerVariable(new sys_var_bool_ptr_readonly("use_sys_malloc",
3312
&srv_use_sys_malloc));
3313
context.registerVariable(new sys_var_std_string("file_format",
3314
innobase_file_format_name,
3315
haildb_file_format_name_validate));
3316
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("flush_log_at_trx_commit", srv_flush_log_at_trx_commit));
3317
context.registerVariable(new sys_var_const_string_val("flush_method",
3318
vm.count("flush-method") ? vm["flush-method"].as<string>() : ""));
3319
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("force_recovery", innobase_force_recovery));
3320
context.registerVariable(new sys_var_const_string_val("log_group_home_dir",
3321
vm.count("log-group-home-dir") ? vm["log-group-home-dir"].as<string>() : ""));
3322
context.registerVariable(new sys_var_constrained_value<int64_t>("log_file_size", haildb_log_file_size));
3323
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("log_files_in_group", haildb_log_files_in_group));
3324
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("lock_wait_timeout", innobase_lock_wait_timeout));
3325
context.registerVariable(new sys_var_constrained_value_readonly<long>("log_buffer_size", innobase_log_buffer_size));
3326
context.registerVariable(new sys_var_constrained_value<unsigned int>("lru_old_blocks_pct", innobase_lru_old_blocks_pct, haildb_lru_old_blocks_pct_update));
3327
context.registerVariable(new sys_var_uint32_t_ptr("lru_block_access_recency",
3328
&innobase_lru_block_access_recency,
3329
haildb_lru_block_access_recency_update));
3330
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("max_dirty_pages_pct", haildb_max_dirty_pages_pct));
3331
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("max_purge_lag", haildb_max_purge_lag));
3332
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("sync_spin_loops", haildb_sync_spin_loops));
3333
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("open_files", haildb_open_files));
3334
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("read_io_threads", haildb_read_io_threads));
3335
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("write_io_threads", haildb_write_io_threads));
3222
haildb_version_func_initialize(context);
3337
3223
haildb_datadict_dump_func_initialize(context);
3338
3224
config_table_function_initialize(context);
3339
3225
status_table_function_initialize(context);
3254
static char haildb_file_format_name_storage[100];
3256
static int haildb_file_format_name_validate(Session*, drizzle_sys_var*,
3258
drizzle_value *value)
3262
int len= sizeof(buff);
3263
const char *format= value->val_str(value, buff, &len);
3265
*static_cast<const char**>(save)= NULL;
3270
err= ib_cfg_set_text("file_format", format);
3272
if (err == DB_SUCCESS)
3274
strncpy(haildb_file_format_name_storage, format, sizeof(haildb_file_format_name_storage));;
3275
haildb_file_format_name_storage[sizeof(haildb_file_format_name_storage)-1]= 0;
3277
*static_cast<const char**>(save)= haildb_file_format_name_storage;
3284
static void haildb_file_format_name_update(Session*, drizzle_sys_var*,
3291
assert(var_ptr != NULL);
3292
assert(save != NULL);
3294
format= *static_cast<const char*const*>(save);
3296
/* Format is already set in validate */
3297
memmove(haildb_file_format_name_storage, format, sizeof(haildb_file_format_name_storage));;
3298
haildb_file_format_name_storage[sizeof(haildb_file_format_name_storage)-1]= 0;
3300
*static_cast<const char**>(var_ptr)= haildb_file_format_name_storage;
3303
static void haildb_lru_old_blocks_pct_update(Session*, drizzle_sys_var*,
3310
pct= *static_cast<const unsigned long*>(save);
3312
ib_err_t err= ib_cfg_set_int("lru_old_blocks_pct", pct);
3313
if (err == DB_SUCCESS)
3314
innobase_lru_old_blocks_pct= pct;
3317
static void haildb_lru_block_access_recency_update(Session*, drizzle_sys_var*,
3324
ms= *static_cast<const unsigned long*>(save);
3326
ib_err_t err= ib_cfg_set_int("lru_block_access_recency", ms);
3328
if (err == DB_SUCCESS)
3329
innobase_lru_block_access_recency= ms;
3332
static void haildb_status_file_update(Session*, drizzle_sys_var*,
3337
bool status_file_enabled;
3340
status_file_enabled= *static_cast<const bool*>(save);
3343
if (status_file_enabled)
3344
err= ib_cfg_set_bool_on("status_file");
3346
err= ib_cfg_set_bool_off("status_file");
3348
if (err == DB_SUCCESS)
3349
innobase_create_status_file= status_file_enabled;
3352
static DRIZZLE_SYSVAR_BOOL(adaptive_hash_index, innobase_adaptive_hash_index,
3353
PLUGIN_VAR_NOCMDARG,
3354
"Enable HailDB adaptive hash index (enabled by default). ",
3357
static DRIZZLE_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
3358
PLUGIN_VAR_NOCMDARG,
3359
"Attempt flushing dirty pages to avoid IO bursts at checkpoints.",
3362
static DRIZZLE_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
3363
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3364
"Size of a memory pool HailDB uses to store data dictionary information and other internal data structures.",
3365
NULL, NULL, 8*1024*1024L, 512*1024L, LONG_MAX, 1024);
3367
static DRIZZLE_SYSVAR_UINT(autoextend_increment, srv_auto_extend_increment,
3368
PLUGIN_VAR_RQCMDARG,
3369
"Data file autoextend increment in megabytes",
3370
NULL, NULL, 8L, 1L, 1000L, 0);
3372
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
3373
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3374
"The size of the memory buffer HailDB uses to cache data and indexes of its tables.",
3375
NULL, NULL, 128*1024*1024L, 5*1024*1024L, INT64_MAX, 1024*1024L);
3377
static DRIZZLE_SYSVAR_BOOL(checksums, innobase_use_checksums,
3378
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
3379
"Enable HailDB checksums validation (enabled by default). "
3380
"Disable with --skip-haildb-checksums.",
3383
static DRIZZLE_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
3384
PLUGIN_VAR_READONLY,
3385
"The common part for HailDB table spaces.",
3388
static DRIZZLE_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
3389
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
3390
"Enable HailDB doublewrite buffer (enabled by default). "
3391
"Disable with --skip-haildb-doublewrite.",
3394
static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
3395
PLUGIN_VAR_RQCMDARG,
3396
"Number of IOPs the server can do. Tunes the background IO rate",
3397
NULL, NULL, 200, 100, ~0L, 0);
3399
static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
3400
PLUGIN_VAR_OPCMDARG,
3401
"Speeds up the shutdown process of the HailDB storage engine. Possible "
3402
"values are 0, 1 (faster)"
3403
" or 2 (fastest - crash-like)"
3405
NULL, NULL, 1, 0, 2, 0);
3407
static DRIZZLE_SYSVAR_BOOL(file_per_table, srv_file_per_table,
3408
PLUGIN_VAR_NOCMDARG,
3409
"Stores each HailDB table to an .ibd file in the database dir.",
3412
static DRIZZLE_SYSVAR_STR(file_format, innobase_file_format_name,
3413
PLUGIN_VAR_RQCMDARG,
3414
"File format to use for new tables in .ibd files.",
3415
haildb_file_format_name_validate,
3416
haildb_file_format_name_update, "Barracuda");
3418
static DRIZZLE_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
3419
PLUGIN_VAR_OPCMDARG,
3420
"Set to 0 (write and flush once per second),"
3421
" 1 (write and flush at each commit)"
3422
" or 2 (write at commit, flush once per second).",
3423
NULL, NULL, 1, 0, 2, 0);
3425
static DRIZZLE_SYSVAR_STR(flush_method, innobase_unix_file_flush_method,
3426
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3427
"With which method to flush data.", NULL, NULL, NULL);
3429
static DRIZZLE_SYSVAR_LONG(force_recovery, innobase_force_recovery,
3430
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3431
"Helps to save your data in case the disk image of the database becomes corrupt.",
3432
NULL, NULL, 0, 0, 6, 0);
3434
static DRIZZLE_SYSVAR_STR(data_file_path, haildb_data_file_path,
3435
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3436
"Path to individual files and their sizes.",
3439
static DRIZZLE_SYSVAR_STR(log_group_home_dir, innobase_log_group_home_dir,
3440
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3441
"Path to HailDB log files.", NULL, NULL, NULL);
3443
static DRIZZLE_SYSVAR_LONGLONG(log_file_size, haildb_log_file_size,
3444
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3445
"Size of each log file in a log group.",
3446
NULL, NULL, 20*1024*1024L, 1*1024*1024L, INT64_MAX, 1024*1024L);
3448
static DRIZZLE_SYSVAR_LONGLONG(log_files_in_group, haildb_log_files_in_group,
3449
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3450
"Number of log files in the log group. HailDB writes to the files in a circular fashion. Value 3 is recommended here.",
3451
NULL, NULL, 2, 2, 100, 0);
3453
static DRIZZLE_SYSVAR_ULONG(lock_wait_timeout, innobase_lock_wait_timeout,
3454
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3455
"Timeout in seconds an HailDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
3456
NULL, NULL, 5, 1, 1024 * 1024 * 1024, 0);
3458
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
3459
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3460
"The size of the buffer which HailDB uses to write log to the log files on disk.",
3461
NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
3463
static DRIZZLE_SYSVAR_ULONG(lru_old_blocks_pct, innobase_lru_old_blocks_pct,
3464
PLUGIN_VAR_RQCMDARG,
3465
"Sets the point in the LRU list from where all pages are classified as "
3466
"old (Advanced users)",
3468
haildb_lru_old_blocks_pct_update, 37, 5, 95, 0);
3470
static DRIZZLE_SYSVAR_ULONG(lru_block_access_recency, innobase_lru_block_access_recency,
3471
PLUGIN_VAR_RQCMDARG,
3472
"Milliseconds between accesses to a block at which it is made young. "
3473
"0=disabled (Advanced users)",
3475
haildb_lru_block_access_recency_update, 0, 0, ULONG_MAX, 0);
3478
static DRIZZLE_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
3479
PLUGIN_VAR_RQCMDARG,
3480
"Percentage of dirty pages allowed in bufferpool.",
3481
NULL, NULL, 75, 0, 99, 0);
3483
static DRIZZLE_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
3484
PLUGIN_VAR_RQCMDARG,
3485
"Desired maximum length of the purge queue (0 = no limit)",
3486
NULL, NULL, 0, 0, ~0L, 0);
3488
static DRIZZLE_SYSVAR_BOOL(rollback_on_timeout, innobase_rollback_on_timeout,
3489
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
3490
"Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)",
3493
static DRIZZLE_SYSVAR_LONG(open_files, innobase_open_files,
3494
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3495
"How many files at the maximum HailDB keeps open at the same time.",
3496
NULL, NULL, 300L, 10L, LONG_MAX, 0);
3498
static DRIZZLE_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
3499
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3500
"Number of background read I/O threads in HailDB.",
3501
NULL, NULL, 4, 1, 64, 0);
3503
static DRIZZLE_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
3504
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3505
"Number of background write I/O threads in HailDB.",
3506
NULL, NULL, 4, 1, 64, 0);
3508
static DRIZZLE_SYSVAR_BOOL(print_verbose_log, innobase_print_verbose_log,
3509
PLUGIN_VAR_NOCMDARG,
3510
"Disable if you want to reduce the number of messages written to the log (default: enabled).",
3513
static DRIZZLE_SYSVAR_BOOL(status_file, innobase_create_status_file,
3514
PLUGIN_VAR_OPCMDARG,
3515
"Enable SHOW HAILDB STATUS output in the log",
3516
NULL, haildb_status_file_update, false);
3518
static DRIZZLE_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
3519
PLUGIN_VAR_RQCMDARG,
3520
"Count of spin-loop rounds in HailDB mutexes (30 by default)",
3521
NULL, NULL, 30L, 0L, ~0L, 0);
3523
static DRIZZLE_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
3524
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
3525
"Use OS memory allocator instead of HailDB's internal memory allocator",
3369
3528
static void init_options(drizzled::module::option_context &context)
3373
3532
context("disable-adaptive-flushing",
3374
3533
N_("Do not attempt to flush dirty pages to avoid IO bursts at checkpoints."));
3375
3534
context("additional-mem-pool-size",
3376
po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
3535
po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
3377
3536
N_("Size of a memory pool HailDB uses to store data dictionary information and other internal data structures."));
3378
3537
context("autoextend-increment",
3379
po::value<autoextend_constraint>(&srv_auto_extend_increment)->default_value(8),
3538
po::value<unsigned int>(&srv_auto_extend_increment)->default_value(8L),
3380
3539
N_("Data file autoextend increment in megabytes"));
3381
3540
context("buffer-pool-size",
3382
po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
3541
po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
3383
3542
N_("The size of the memory buffer HailDB uses to cache data and indexes of its tables."));
3384
3543
context("data-home-dir",
3385
po::value<string>()->default_value(""),
3544
po::value<string>(),
3386
3545
N_("The common part for HailDB table spaces."));
3387
3546
context("disable-checksums",
3388
3547
N_("Disable HailDB checksums validation (enabled by default)."));
3389
3548
context("disable-doublewrite",
3390
3549
N_("Disable HailDB doublewrite buffer (enabled by default)."));
3391
3550
context("io-capacity",
3392
po::value<io_capacity_constraint>(&srv_io_capacity)->default_value(200),
3551
po::value<unsigned long>(&srv_io_capacity)->default_value(200),
3393
3552
N_("Number of IOPs the server can do. Tunes the background IO rate"));
3394
3553
context("fast-shutdown",
3395
po::value<trinary_constraint>(&innobase_fast_shutdown)->default_value(1),
3554
po::value<unsigned long>(&innobase_fast_shutdown)->default_value(1),
3396
3555
N_("Speeds up the shutdown process of the HailDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like)."));
3397
3556
context("file-per-table",
3398
3557
po::value<bool>(&srv_file_per_table)->default_value(false)->zero_tokens(),
3399
3558
N_("Stores each HailDB table to an .ibd file in the database dir."));
3400
3559
context("file-format",
3401
po::value<string>(&innobase_file_format_name)->default_value("Barracuda"),
3560
po::value<string>(),
3402
3561
N_("File format to use for new tables in .ibd files."));
3403
3562
context("flush-log-at-trx-commit",
3404
po::value<trinary_constraint>(&srv_flush_log_at_trx_commit)->default_value(1),
3563
po::value<unsigned long>(&srv_flush_log_at_trx_commit)->default_value(1),
3405
3564
N_("Set to 0 (write and flush once per second),1 (write and flush at each commit) or 2 (write at commit, flush once per second)."));
3406
3565
context("flush-method",
3407
3566
po::value<string>(),
3408
3567
N_("With which method to flush data."));
3409
3568
context("force-recovery",
3410
po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
3569
po::value<long>(&innobase_force_recovery)->default_value(0),
3411
3570
N_("Helps to save your data in case the disk image of the database becomes corrupt."));
3412
3571
context("data-file-path",
3413
po::value<string>()->default_value("ibdata1:10M:autoextend"),
3572
po::value<string>(),
3573
N_("Path to individual files and their sizes."));
3574
context("log-group-home-dir",
3575
po::value<string>(),
3414
3576
N_("Path to individual files and their sizes."));
3415
3577
context("log-group-home-dir",
3416
3578
po::value<string>(),
3417
3579
N_("Path to HailDB log files."));
3418
3580
context("log-file-size",
3419
po::value<log_file_constraint>(&haildb_log_file_size)->default_value(20*1024*1024L),
3581
po::value<int64_t>(&haildb_log_file_size)->default_value(20*1024*1024L),
3420
3582
N_("Size of each log file in a log group."));
3421
3583
context("haildb-log-files-in-group",
3422
po::value<log_files_in_group_constraint>(&haildb_log_files_in_group)->default_value(2),
3584
po::value<int64_t>(&haildb_log_files_in_group)->default_value(2),
3423
3585
N_("Number of log files in the log group. HailDB writes to the files in a circular fashion. Value 3 is recommended here."));
3424
3586
context("lock-wait-timeout",
3425
po::value<lock_wait_constraint>(&innobase_lock_wait_timeout)->default_value(5),
3587
po::value<unsigned long>(&innobase_lock_wait_timeout)->default_value(5),
3426
3588
N_("Timeout in seconds an HailDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
3427
3589
context("log-buffer-size",
3428
po::value<log_buffer_size_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
3590
po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
3429
3591
N_("The size of the buffer which HailDB uses to write log to the log files on disk."));
3430
3592
context("lru-old-blocks-pct",
3431
po::value<lru_old_blocks_constraint>(&innobase_lru_old_blocks_pct)->default_value(37),
3593
po::value<unsigned long>(&innobase_lru_old_blocks_pct)->default_value(37),
3432
3594
N_("Sets the point in the LRU list from where all pages are classified as old (Advanced users)"));
3433
3595
context("lru-block-access-recency",
3434
po::value<uint32_t>(&innobase_lru_block_access_recency)->default_value(0),
3596
po::value<unsigned long>(&innobase_lru_block_access_recency)->default_value(0),
3435
3597
N_("Milliseconds between accesses to a block at which it is made young. 0=disabled (Advanced users)"));
3436
3598
context("max-dirty-pages-pct",
3437
po::value<max_dirty_pages_constraint>(&haildb_max_dirty_pages_pct)->default_value(75),
3599
po::value<unsigned long>(&srv_max_buf_pool_modified_pct)->default_value(75),
3438
3600
N_("Percentage of dirty pages allowed in bufferpool."));
3439
3601
context("max-purge-lag",
3440
po::value<uint64_constraint>(&haildb_max_purge_lag)->default_value(0),
3602
po::value<unsigned long>(&srv_max_purge_lag)->default_value(0),
3441
3603
N_("Desired maximum length of the purge queue (0 = no limit)"));
3442
3604
context("rollback-on-timeout",
3443
3605
po::value<bool>(&innobase_rollback_on_timeout)->default_value(false)->zero_tokens(),
3444
3606
N_("Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)"));
3445
3607
context("open-files",
3446
po::value<open_files_constraint>(&haildb_open_files)->default_value(300),
3608
po::value<long>(&innobase_open_files)->default_value(300),
3447
3609
N_("How many files at the maximum HailDB keeps open at the same time."));
3448
3610
context("read-io-threads",
3449
po::value<io_threads_constraint>(&haildb_read_io_threads)->default_value(4),
3611
po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
3450
3612
N_("Number of background read I/O threads in HailDB."));
3451
3613
context("write-io-threads",
3452
po::value<io_threads_constraint>(&haildb_write_io_threads)->default_value(4),
3614
po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
3453
3615
N_("Number of background write I/O threads in HailDB."));
3454
3616
context("disable-print-verbose-log",
3455
3617
N_("Disable if you want to reduce the number of messages written to the log (default: enabled)."));
3457
3619
po::value<bool>(&innobase_create_status_file)->default_value(false)->zero_tokens(),
3458
3620
N_("Enable SHOW HAILDB STATUS output in the log"));
3459
3621
context("sync-spin-loops",
3460
po::value<uint64_constraint>(&haildb_sync_spin_loops)->default_value(30L),
3622
po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
3461
3623
N_("Count of spin-loop rounds in HailDB mutexes (30 by default)"));
3462
3624
context("use-internal-malloc",
3463
3625
N_("Use HailDB's internal memory allocator instead of the OS memory allocator"));
3628
static drizzle_sys_var* innobase_system_variables[]= {
3629
DRIZZLE_SYSVAR(adaptive_hash_index),
3630
DRIZZLE_SYSVAR(adaptive_flushing),
3631
DRIZZLE_SYSVAR(additional_mem_pool_size),
3632
DRIZZLE_SYSVAR(autoextend_increment),
3633
DRIZZLE_SYSVAR(buffer_pool_size),
3634
DRIZZLE_SYSVAR(checksums),
3635
DRIZZLE_SYSVAR(data_home_dir),
3636
DRIZZLE_SYSVAR(doublewrite),
3637
DRIZZLE_SYSVAR(io_capacity),
3638
DRIZZLE_SYSVAR(fast_shutdown),
3639
DRIZZLE_SYSVAR(file_per_table),
3640
DRIZZLE_SYSVAR(file_format),
3641
DRIZZLE_SYSVAR(flush_log_at_trx_commit),
3642
DRIZZLE_SYSVAR(flush_method),
3643
DRIZZLE_SYSVAR(force_recovery),
3644
DRIZZLE_SYSVAR(log_group_home_dir),
3645
DRIZZLE_SYSVAR(data_file_path),
3646
DRIZZLE_SYSVAR(lock_wait_timeout),
3647
DRIZZLE_SYSVAR(log_file_size),
3648
DRIZZLE_SYSVAR(log_files_in_group),
3649
DRIZZLE_SYSVAR(log_buffer_size),
3650
DRIZZLE_SYSVAR(lru_old_blocks_pct),
3651
DRIZZLE_SYSVAR(lru_block_access_recency),
3652
DRIZZLE_SYSVAR(max_dirty_pages_pct),
3653
DRIZZLE_SYSVAR(max_purge_lag),
3654
DRIZZLE_SYSVAR(open_files),
3655
DRIZZLE_SYSVAR(read_io_threads),
3656
DRIZZLE_SYSVAR(rollback_on_timeout),
3657
DRIZZLE_SYSVAR(write_io_threads),
3658
DRIZZLE_SYSVAR(print_verbose_log),
3659
DRIZZLE_SYSVAR(status_file),
3660
DRIZZLE_SYSVAR(sync_spin_loops),
3661
DRIZZLE_SYSVAR(use_sys_malloc),
3466
3665
DRIZZLE_DECLARE_PLUGIN
3468
3667
DRIZZLE_VERSION_ID,