~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/embedded_innodb/embedded_innodb_engine.cc

Merged in innodb changes. Fixed the buffer pool size default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
#include "config_table_function.h"
94
94
#include "status_table_function.h"
95
95
 
96
 
#include "embedded_innodb-1.0/innodb.h"
 
96
#if defined(HAVE_HAILDB_H)
 
97
# include <haildb.h>
 
98
#else
 
99
# include <embedded_innodb-1.0/innodb.h>
 
100
#endif /* HAVE_HAILDB_H */
97
101
 
98
102
#include "embedded_innodb_engine.h"
99
103
 
102
106
#include "drizzled/field/blob.h"
103
107
#include "drizzled/field/enum.h"
104
108
#include <drizzled/session.h>
 
109
#include <boost/program_options.hpp>
 
110
#include <drizzled/module/option_map.h>
 
111
#include <iostream>
105
112
 
 
113
namespace po= boost::program_options;
106
114
#include <boost/algorithm/string.hpp>
107
115
 
108
116
using namespace std;
2745
2753
 
2746
2754
static int embedded_innodb_init(drizzled::module::Context &context)
2747
2755
{
 
2756
 
 
2757
  const module::option_map &vm= context.getOptions();
 
2758
  if (vm.count("additional-mem-pool-size"))
 
2759
  { 
 
2760
    if (innobase_additional_mem_pool_size > LONG_MAX || innobase_additional_mem_pool_size < 512*1024L)
 
2761
    {
 
2762
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of additional-mem-pool-size"));
 
2763
      exit(-1);
 
2764
    }
 
2765
    innobase_additional_mem_pool_size/= 1024;
 
2766
    innobase_additional_mem_pool_size*= 1024;
 
2767
  }
 
2768
 
 
2769
  if (vm.count("autoextend-increment"))
 
2770
  { 
 
2771
    if (srv_auto_extend_increment > 1000L || srv_auto_extend_increment < 1L)
 
2772
    {
 
2773
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of autoextend-increment"));
 
2774
      exit(-1);
 
2775
    }
 
2776
  }
 
2777
 
 
2778
  if (vm.count("buffer-pool-size"))
 
2779
  { 
 
2780
    if (innobase_buffer_pool_size > INT64_MAX || innobase_buffer_pool_size < 5*1024*1024L)
 
2781
    {
 
2782
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of buffer-pool-size"));
 
2783
      exit(-1);
 
2784
    }
 
2785
    innobase_buffer_pool_size/= 1024*1024L;
 
2786
    innobase_buffer_pool_size*= 1024*1024L;
 
2787
  }
 
2788
 
 
2789
  if (vm.count("io-capacity"))
 
2790
  { 
 
2791
    if (srv_io_capacity > (unsigned long)~0L || srv_io_capacity < 100)
 
2792
    {
 
2793
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of io-capacity"));
 
2794
      exit(-1);
 
2795
    }
 
2796
  }
 
2797
 
 
2798
  if (vm.count("fast-shutdown"))
 
2799
  { 
 
2800
    if (innobase_fast_shutdown > 2)
 
2801
    {
 
2802
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of fast-shutdown"));
 
2803
      exit(-1);
 
2804
    }
 
2805
  }
 
2806
 
 
2807
  if (vm.count("flush-log-at-trx-commit"))
 
2808
  { 
 
2809
    if (srv_flush_log_at_trx_commit > 2)
 
2810
    {
 
2811
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of flush-log-at-trx-commit"));
 
2812
      exit(-1);
 
2813
    }
 
2814
  }
 
2815
 
 
2816
  if (vm.count("force-recovery"))
 
2817
  { 
 
2818
    if (innobase_force_recovery > 6)
 
2819
    {
 
2820
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of force-recovery"));
 
2821
      exit(-1);
 
2822
    }
 
2823
  }
 
2824
 
 
2825
  if (vm.count("log-file-size"))
 
2826
  { 
 
2827
    if (innodb_log_file_size > INT64_MAX || innodb_log_file_size < 1*1024*1024L)
 
2828
    {
 
2829
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-file-size"));
 
2830
      exit(-1);
 
2831
    }
 
2832
    innodb_log_file_size/= 1024*1024L;
 
2833
    innodb_log_file_size*= 1024*1024L;
 
2834
  }
 
2835
 
 
2836
  if (vm.count("log-files-in-group"))
 
2837
  { 
 
2838
    if (innodb_log_files_in_group > 100 || innodb_log_files_in_group < 2)
 
2839
    {
 
2840
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-files-in-group"));
 
2841
      exit(-1);
 
2842
    }
 
2843
  }
 
2844
 
 
2845
  if (vm.count("lock-wait-timeout"))
 
2846
  { 
 
2847
    if (innobase_lock_wait_timeout > 1024*1024*1024 || innobase_lock_wait_timeout < 1)
 
2848
    {
 
2849
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lock-wait-timeout"));
 
2850
      exit(-1);
 
2851
    }
 
2852
  }
 
2853
 
 
2854
  if (vm.count("log-buffer-size"))
 
2855
  { 
 
2856
    if (innobase_log_buffer_size > LONG_MAX || innobase_log_buffer_size < 256*1024L)
 
2857
    {
 
2858
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-buffer-size"));
 
2859
      exit(-1);
 
2860
    }
 
2861
    innobase_log_buffer_size/= 1024;
 
2862
    innobase_log_buffer_size*= 1024;
 
2863
  }
 
2864
 
 
2865
  if (vm.count("lru-old-blocks-pct"))
 
2866
  { 
 
2867
    if (innobase_lru_old_blocks_pct > 95 || innobase_lru_old_blocks_pct < 5)
 
2868
    {
 
2869
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-old-blocks-pct"));
 
2870
      exit(-1);
 
2871
    }
 
2872
  }
 
2873
 
 
2874
  if (vm.count("lru-block-access-recency"))
 
2875
  { 
 
2876
    if (innobase_lru_block_access_recency > ULONG_MAX)
 
2877
    {
 
2878
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-block-access-recency"));
 
2879
      exit(-1);
 
2880
    }
 
2881
  }
 
2882
 
 
2883
  if (vm.count("max-dirty-pages-pct"))
 
2884
  { 
 
2885
    if (srv_max_buf_pool_modified_pct > 99)
 
2886
    {
 
2887
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-dirty-pages-pct"));
 
2888
      exit(-1);
 
2889
    }
 
2890
  }
 
2891
 
 
2892
  if (vm.count("max-purge-lag"))
 
2893
  { 
 
2894
    if (srv_max_purge_lag > (unsigned long)~0L)
 
2895
    {
 
2896
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-purge-lag"));
 
2897
      exit(-1);
 
2898
    }
 
2899
  }
 
2900
 
 
2901
  if (vm.count("open-files"))
 
2902
  { 
 
2903
    if (innobase_open_files > LONG_MAX || innobase_open_files < 10L)
 
2904
    {
 
2905
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of open-files"));
 
2906
      exit(-1);
 
2907
    }
 
2908
  }
 
2909
 
 
2910
  if (vm.count("read-io-threads"))
 
2911
  { 
 
2912
    if (innobase_read_io_threads > 64 || innobase_read_io_threads < 1)
 
2913
    {
 
2914
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of read-io-threads"));
 
2915
      exit(-1);
 
2916
    }
 
2917
  }
 
2918
 
 
2919
  if (vm.count("sync-spin-loops"))
 
2920
  { 
 
2921
    if (srv_n_spin_wait_rounds > (unsigned long)~0L)
 
2922
    {
 
2923
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of sync_spin_loops"));
 
2924
      exit(-1);
 
2925
    }
 
2926
  }
 
2927
 
 
2928
  if (vm.count("data-home-dir"))
 
2929
  {
 
2930
    innobase_data_home_dir= strdup(vm["data-home-dir"].as<string>().c_str());
 
2931
  }
 
2932
 
 
2933
  else
 
2934
  {
 
2935
    innobase_data_home_dir= NULL;
 
2936
  }
 
2937
 
 
2938
  if (vm.count("file-format"))
 
2939
  {
 
2940
    innobase_file_format_name= strdup(vm["file-format"].as<string>().c_str());
 
2941
  }
 
2942
 
 
2943
  else
 
2944
  {
 
2945
    innobase_file_format_name= strdup("Barracuda");
 
2946
  }
 
2947
 
 
2948
  if (vm.count("log-group-home-dir"))
 
2949
  {
 
2950
    innobase_log_group_home_dir= strdup(vm["log-group-home-dir"].as<string>().c_str());
 
2951
  }
 
2952
 
 
2953
  else
 
2954
  {
 
2955
    innobase_log_group_home_dir= NULL;
 
2956
  }
 
2957
 
 
2958
  if (vm.count("flush-method"))
 
2959
  {
 
2960
    innobase_unix_file_flush_method= strdup(vm["flush-method"].as<string>().c_str());
 
2961
  }
 
2962
 
 
2963
  else
 
2964
  {
 
2965
    innobase_unix_file_flush_method= NULL;
 
2966
  }
 
2967
 
 
2968
  if (vm.count("data-file-path"))
 
2969
  {
 
2970
    innodb_data_file_path= strdup(vm["data-file-path"].as<string>().c_str());
 
2971
  }
 
2972
 
 
2973
  else
 
2974
  {
 
2975
    innodb_data_file_path= NULL;
 
2976
  }
 
2977
 
 
2978
  if (vm.count("data-home-dir"))
 
2979
  {
 
2980
    innobase_data_home_dir= strdup(vm["data-home-dir"].as<string>().c_str());
 
2981
  }
 
2982
 
 
2983
  else
 
2984
  {
 
2985
    innobase_data_home_dir= NULL;
 
2986
  }
 
2987
 
2748
2988
  ib_err_t err;
2749
2989
 
2750
2990
  err= ib_init();
2941
3181
  {
2942
3182
    fprintf(stderr,"Error %d shutting down Embedded InnoDB!\n", err);
2943
3183
  }
 
3184
 
 
3185
  /* These get strdup'd from vm variables */
 
3186
  free(innodb_data_file_path);
 
3187
  free(innobase_data_home_dir);
 
3188
  free(innobase_file_format_name);
 
3189
  free(innobase_log_group_home_dir);
 
3190
  free(innobase_unix_file_flush_method);
 
3191
 
2944
3192
}
2945
3193
 
2946
3194
static char innodb_file_format_name_storage[100];
3145
3393
static DRIZZLE_SYSVAR_ULONG(lock_wait_timeout, innobase_lock_wait_timeout,
3146
3394
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3147
3395
  "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
3148
 
  NULL, NULL, 50, 1, 1024 * 1024 * 1024, 0);
 
3396
  NULL, NULL, 5, 1, 1024 * 1024 * 1024, 0);
3149
3397
 
3150
3398
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
3151
3399
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3217
3465
  "Use OS memory allocator instead of InnoDB's internal memory allocator",
3218
3466
  NULL, NULL, true);
3219
3467
 
 
3468
static void init_options(drizzled::module::option_context &context)
 
3469
{
 
3470
  context("adaptive-hash-index", 
 
3471
          po::value<bool>(&innobase_adaptive_hash_index)->default_value(true),
 
3472
          N_("Enable InnoDB adaptive hash index (enabled by default)."));
 
3473
  context("adaptive-flushing",
 
3474
          po::value<bool>(&srv_adaptive_flushing)->default_value(true),
 
3475
          N_("Attempt flushing dirty pages to avoid IO bursts at checkpoints."));
 
3476
  context("additional-mem-pool-size",
 
3477
          po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
 
3478
          N_("Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures."));
 
3479
  context("autoextend-increment",
 
3480
          po::value<unsigned int>(&srv_auto_extend_increment)->default_value(8L),
 
3481
          N_("Data file autoextend increment in megabytes"));
 
3482
  context("buffer-pool-size",
 
3483
          po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
 
3484
          N_("The size of the memory buffer InnoDB uses to cache data and indexes of its tables."));
 
3485
  context("data-home-dir",
 
3486
          po::value<string>(),
 
3487
          N_("The common part for InnoDB table spaces."));
 
3488
  context("checksums",
 
3489
          po::value<bool>(&innobase_use_checksums)->default_value(true),
 
3490
          N_("Enable InnoDB checksums validation (enabled by default). Disable with --skip-innodb-checksums."));
 
3491
  context("doublewrite",
 
3492
          po::value<bool>(&innobase_use_doublewrite)->default_value(true),
 
3493
          N_("Enable InnoDB doublewrite buffer (enabled by default). Disable with --skip-innodb-doublewrite."));
 
3494
  context("io-capacity",
 
3495
          po::value<unsigned long>(&srv_io_capacity)->default_value(200),
 
3496
          N_("Number of IOPs the server can do. Tunes the background IO rate"));
 
3497
  context("fast-shutdown",
 
3498
          po::value<unsigned long>(&innobase_fast_shutdown)->default_value(1),
 
3499
          N_("Speeds up the shutdown process of the InnoDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like)."));
 
3500
  context("file-per-table", 
 
3501
          po::value<bool>(&srv_file_per_table)->default_value(false),
 
3502
          N_("Stores each InnoDB table to an .ibd file in the database dir."));
 
3503
  context("file-format",
 
3504
          po::value<string>(),
 
3505
          N_("File format to use for new tables in .ibd files."));
 
3506
  context("flush-log-at-trx-commit",
 
3507
          po::value<unsigned long>(&srv_flush_log_at_trx_commit)->default_value(1),
 
3508
          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)."));
 
3509
  context("flush-method",
 
3510
          po::value<string>(),
 
3511
          N_("With which method to flush data."));
 
3512
  context("force-recovery",
 
3513
          po::value<long>(&innobase_force_recovery)->default_value(0),
 
3514
          N_("Helps to save your data in case the disk image of the database becomes corrupt."));        
 
3515
  context("data-file-path",
 
3516
          po::value<string>(),
 
3517
          N_("Path to individual files and their sizes."));
 
3518
  context("log-group-home-dir",
 
3519
          po::value<string>(),
 
3520
          N_("Path to individual files and their sizes."));
 
3521
  context("log-group-home-dir",
 
3522
          po::value<string>(),
 
3523
          N_("Path to InnoDB log files."));
 
3524
  context("log-file-size",
 
3525
          po::value<int64_t>(&innodb_log_file_size)->default_value(20*1024*1024L),
 
3526
          N_("Size of each log file in a log group."));
 
3527
  context("innodb-log-files-in-group",
 
3528
          po::value<int64_t>(&innodb_log_files_in_group)->default_value(2),
 
3529
          N_("Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here."));
 
3530
  context("lock-wait-timeout",
 
3531
          po::value<unsigned long>(&innobase_lock_wait_timeout)->default_value(5),
 
3532
          N_("Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
 
3533
  context("log-buffer-size",
 
3534
        po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
 
3535
        N_("The size of the buffer which InnoDB uses to write log to the log files on disk."));
 
3536
  context("lru-old-blocks-pct",
 
3537
          po::value<unsigned long>(&innobase_lru_old_blocks_pct)->default_value(37),
 
3538
          N_("Sets the point in the LRU list from where all pages are classified as old (Advanced users)"));
 
3539
  context("lru-block-access-recency",
 
3540
          po::value<unsigned long>(&innobase_lru_block_access_recency)->default_value(0),
 
3541
          N_("Milliseconds between accesses to a block at which it is made young. 0=disabled (Advanced users)"));
 
3542
  context("max-dirty-pages-pct",
 
3543
          po::value<unsigned long>(&srv_max_buf_pool_modified_pct)->default_value(75),
 
3544
          N_("Percentage of dirty pages allowed in bufferpool."));
 
3545
  context("max-purge-lag",
 
3546
          po::value<unsigned long>(&srv_max_purge_lag)->default_value(0),
 
3547
          N_("Desired maximum length of the purge queue (0 = no limit)"));
 
3548
  context("rollback-on-timeout",
 
3549
          po::value<bool>(&innobase_rollback_on_timeout)->default_value(false),
 
3550
          N_("Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)"));
 
3551
  context("open-files",
 
3552
          po::value<long>(&innobase_open_files)->default_value(300),
 
3553
          N_("How many files at the maximum InnoDB keeps open at the same time."));
 
3554
  context("read-io-threads",
 
3555
          po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
 
3556
          N_("Number of background read I/O threads in InnoDB."));
 
3557
  context("write-io-threads",
 
3558
          po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
 
3559
          N_("Number of background write I/O threads in InnoDB."));
 
3560
  context("print-verbose-log",
 
3561
          po::value<bool>(&innobase_print_verbose_log)->default_value(true),
 
3562
          N_("Disable if you want to reduce the number of messages written to the log (default: enabled)."));
 
3563
  context("status-file",
 
3564
          po::value<bool>(&innobase_create_status_file)->default_value(false),
 
3565
          N_("Enable SHOW INNODB STATUS output in the log"));
 
3566
  context("sync-spin-loops",
 
3567
          po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
 
3568
          N_("Count of spin-loop rounds in InnoDB mutexes (30 by default)"));
 
3569
  context("use-sys-malloc",
 
3570
          po::value<bool>(&srv_use_sys_malloc)->default_value(true),
 
3571
          N_("Use OS memory allocator instead of InnoDB's internal memory allocator"));
 
3572
}
 
3573
 
3220
3574
static drizzle_sys_var* innobase_system_variables[]= {
3221
3575
  DRIZZLE_SYSVAR(adaptive_hash_index),
3222
3576
  DRIZZLE_SYSVAR(adaptive_flushing),
3264
3618
  PLUGIN_LICENSE_GPL,
3265
3619
  embedded_innodb_init,     /* Plugin Init */
3266
3620
  innobase_system_variables, /* system variables */
3267
 
  NULL                /* config options   */
 
3621
  init_options                /* config options   */
3268
3622
}
3269
3623
DRIZZLE_DECLARE_PLUGIN_END;