~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/haildb/haildb_engine.cc

  • Committer: Monty Taylor
  • Date: 2010-10-25 18:26:50 UTC
  • mto: (1879.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 1880.
  • Revision ID: mordred@inaugust.com-20101025182650-7k11plnoi78sy1gl
Split set_var.* into sys_var.* and set_var.*

Show diffs side-by-side

added added

removed removed

Lines of Context:
364
364
                    statement_savepoint_name.length());
365
365
}
366
366
 
367
 
void HailDBEngine::doEndStatement(Session *)
 
367
void HailDBEngine::doEndStatement(Session *session)
368
368
{
 
369
  doCommit(session, false);
369
370
}
370
371
 
371
372
int HailDBEngine::doSetSavepoint(Session* session,
1208
1209
 
1209
1210
  if (table_message.type() == message::Table::TEMPORARY)
1210
1211
  {
1211
 
    session.getMessageCache().storeTableMessage(identifier, table_message);
 
1212
    session.storeTableMessage(identifier, table_message);
1212
1213
    haildb_err= DB_SUCCESS;
1213
1214
  }
1214
1215
  else
1300
1301
 
1301
1302
  if (identifier.getType() == message::Table::TEMPORARY)
1302
1303
  {
1303
 
      session.getMessageCache().removeTableMessage(identifier);
 
1304
      session.removeTableMessage(identifier);
1304
1305
      delete_table_message_from_haildb(haildb_schema_transaction,
1305
1306
                                       haildb_table_name.c_str());
1306
1307
  }
1458
1459
  if (to.getType() == message::Table::TEMPORARY
1459
1460
      && from.getType() == message::Table::TEMPORARY)
1460
1461
  {
1461
 
    session.getMessageCache().renameTableMessage(from, to);
 
1462
    session.renameTableMessage(from, to);
1462
1463
    return 0;
1463
1464
  }
1464
1465
 
1729
1730
  string haildb_table_name;
1730
1731
 
1731
1732
  /* Check temporary tables!? */
1732
 
  if (session.getMessageCache().getTableMessage(identifier, table))
 
1733
  if (session.getTableMessage(identifier, table))
1733
1734
    return EEXIST;
1734
1735
 
1735
1736
  TableIdentifier_to_haildb_name(identifier, &haildb_table_name);
2818
2819
  return err;
2819
2820
}
2820
2821
 
 
2822
static bool  innobase_use_checksums= true;
 
2823
static char*  innobase_data_home_dir      = NULL;
2821
2824
static char*  innobase_log_group_home_dir   = NULL;
2822
2825
static bool innobase_use_doublewrite= true;
 
2826
static unsigned long srv_io_capacity= 200;
2823
2827
static unsigned long innobase_fast_shutdown= 1;
2824
2828
static bool srv_file_per_table= false;
2825
2829
static bool innobase_adaptive_hash_index;
2837
2841
static unsigned long innobase_lru_block_access_recency;
2838
2842
static unsigned long innobase_read_io_threads;
2839
2843
static unsigned long innobase_write_io_threads;
2840
 
typedef constrained_check<unsigned int, 1000, 1> autoextend_constraint;
2841
 
static autoextend_constraint srv_auto_extend_increment;
 
2844
static unsigned int srv_auto_extend_increment;
2842
2845
static unsigned long innobase_lock_wait_timeout;
2843
2846
static unsigned long srv_n_spin_wait_rounds;
2844
 
typedef constrained_check<size_t, SIZE_MAX, 5242880, 1048576> buffer_pool_constraint;
2845
 
static buffer_pool_constraint innobase_buffer_pool_size;
2846
 
typedef constrained_check<size_t, SIZE_MAX, 512, 1024> additional_mem_pool_constraint;
2847
 
static additional_mem_pool_constraint innobase_additional_mem_pool_size;
2848
 
static bool  innobase_use_checksums= true;
2849
 
typedef constrained_check<unsigned int, UINT_MAX, 100> io_capacity_constraint;
2850
 
static io_capacity_constraint srv_io_capacity;
2851
 
 
 
2847
static int64_t innobase_buffer_pool_size;
2852
2848
static long innobase_open_files;
 
2849
static long innobase_additional_mem_pool_size;
2853
2850
static long innobase_force_recovery;
2854
2851
static long innobase_log_buffer_size;
2855
2852
static char  default_haildb_data_file_path[]= "ibdata1:10M:autoextend";
2878
2875
  innobase_print_verbose_log= (vm.count("disable-print-verbose-log")) ? false : true;
2879
2876
  srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
2880
2877
 
 
2878
  if (vm.count("additional-mem-pool-size"))
 
2879
  {
 
2880
    if (innobase_additional_mem_pool_size > LONG_MAX || innobase_additional_mem_pool_size < 512*1024L)
 
2881
    {
 
2882
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of additional-mem-pool-size"));
 
2883
      exit(-1);
 
2884
    }
 
2885
    innobase_additional_mem_pool_size/= 1024;
 
2886
    innobase_additional_mem_pool_size*= 1024;
 
2887
  }
 
2888
 
 
2889
  if (vm.count("autoextend-increment"))
 
2890
  {
 
2891
    if (srv_auto_extend_increment > 1000L || srv_auto_extend_increment < 1L)
 
2892
    {
 
2893
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of autoextend-increment"));
 
2894
      exit(-1);
 
2895
    }
 
2896
  }
 
2897
 
 
2898
  if (vm.count("buffer-pool-size"))
 
2899
  {
 
2900
    if (innobase_buffer_pool_size > INT64_MAX || innobase_buffer_pool_size < 5*1024*1024L)
 
2901
    {
 
2902
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of buffer-pool-size"));
 
2903
      exit(-1);
 
2904
    }
 
2905
    innobase_buffer_pool_size/= 1024*1024L;
 
2906
    innobase_buffer_pool_size*= 1024*1024L;
 
2907
  }
 
2908
 
 
2909
  if (vm.count("io-capacity"))
 
2910
  {
 
2911
    if (srv_io_capacity > (unsigned long)~0L || srv_io_capacity < 100)
 
2912
    {
 
2913
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of io-capacity"));
 
2914
      exit(-1);
 
2915
    }
 
2916
  }
 
2917
 
2881
2918
  if (vm.count("fast-shutdown"))
2882
2919
  {
2883
2920
    if (innobase_fast_shutdown > 2)
2884
2921
    {
2885
2922
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of fast-shutdown"));
2886
 
      return 1;
 
2923
      exit(-1);
2887
2924
    }
2888
2925
  }
2889
2926
 
2892
2929
    if (srv_flush_log_at_trx_commit > 2)
2893
2930
    {
2894
2931
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of flush-log-at-trx-commit"));
2895
 
      return 1;
 
2932
      exit(-1);
2896
2933
    }
2897
2934
  }
2898
2935
 
2901
2938
    if (innobase_force_recovery > 6)
2902
2939
    {
2903
2940
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of force-recovery"));
2904
 
      return 1;
 
2941
      exit(-1);
2905
2942
    }
2906
2943
  }
2907
2944
 
2910
2947
    if (haildb_log_file_size > INT64_MAX || haildb_log_file_size < 1*1024*1024L)
2911
2948
    {
2912
2949
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-file-size"));
2913
 
      return 1;
 
2950
      exit(-1);
2914
2951
    }
2915
2952
    haildb_log_file_size/= 1024*1024L;
2916
2953
    haildb_log_file_size*= 1024*1024L;
2921
2958
    if (haildb_log_files_in_group > 100 || haildb_log_files_in_group < 2)
2922
2959
    {
2923
2960
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-files-in-group"));
2924
 
      return 1;
 
2961
      exit(-1);
2925
2962
    }
2926
2963
  }
2927
2964
 
2930
2967
    if (innobase_lock_wait_timeout > 1024*1024*1024 || innobase_lock_wait_timeout < 1)
2931
2968
    {
2932
2969
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lock-wait-timeout"));
2933
 
      return 1;
 
2970
      exit(-1);
2934
2971
    }
2935
2972
  }
2936
2973
 
2939
2976
    if (innobase_log_buffer_size > LONG_MAX || innobase_log_buffer_size < 256*1024L)
2940
2977
    {
2941
2978
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-buffer-size"));
2942
 
      return 1;
 
2979
      exit(-1);
2943
2980
    }
2944
2981
    innobase_log_buffer_size/= 1024;
2945
2982
    innobase_log_buffer_size*= 1024;
2950
2987
    if (innobase_lru_old_blocks_pct > 95 || innobase_lru_old_blocks_pct < 5)
2951
2988
    {
2952
2989
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-old-blocks-pct"));
2953
 
      return 1;
 
2990
      exit(-1);
2954
2991
    }
2955
2992
  }
2956
2993
 
2959
2996
    if (innobase_lru_block_access_recency > ULONG_MAX)
2960
2997
    {
2961
2998
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-block-access-recency"));
2962
 
      return 1;
 
2999
      exit(-1);
2963
3000
    }
2964
3001
  }
2965
3002
 
2968
3005
    if (srv_max_buf_pool_modified_pct > 99)
2969
3006
    {
2970
3007
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-dirty-pages-pct"));
2971
 
      return 1;
 
3008
      exit(-1);
2972
3009
    }
2973
3010
  }
2974
3011
 
2977
3014
    if (srv_max_purge_lag > (unsigned long)~0L)
2978
3015
    {
2979
3016
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-purge-lag"));
2980
 
      return 1;
 
3017
      exit(-1);
2981
3018
    }
2982
3019
  }
2983
3020
 
2986
3023
    if (innobase_open_files > LONG_MAX || innobase_open_files < 10L)
2987
3024
    {
2988
3025
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of open-files"));
2989
 
      return 1;
 
3026
      exit(-1);
2990
3027
    }
2991
3028
  }
2992
3029
 
2995
3032
    if (innobase_read_io_threads > 64 || innobase_read_io_threads < 1)
2996
3033
    {
2997
3034
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of read-io-threads"));
2998
 
      return 1;
 
3035
      exit(-1);
2999
3036
    }
3000
3037
  }
3001
3038
 
3004
3041
    if (srv_n_spin_wait_rounds > (unsigned long)~0L)
3005
3042
    {
3006
3043
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of sync_spin_loops"));
3007
 
      return 1;
 
3044
      exit(-1);
3008
3045
    }
3009
3046
  }
3010
3047
 
 
3048
  if (vm.count("data-home-dir"))
 
3049
  {
 
3050
    innobase_data_home_dir= const_cast<char *>(vm["data-home-dir"].as<string>().c_str());
 
3051
  }
 
3052
 
3011
3053
  if (vm.count("file-format"))
3012
3054
  {
3013
3055
    innobase_file_format_name= const_cast<char *>(vm["file-format"].as<string>().c_str());
3034
3076
  if (err != DB_SUCCESS)
3035
3077
    goto haildb_error;
3036
3078
 
3037
 
 
3038
 
  if (vm.count("data-home-dir"))
 
3079
  if (innobase_data_home_dir)
3039
3080
  {
3040
 
    err= ib_cfg_set_text("data_home_dir", vm["data-home-dir"].as<string>().c_str());
 
3081
    err= ib_cfg_set_text("data_home_dir", innobase_data_home_dir);
3041
3082
    if (err != DB_SUCCESS)
3042
3083
      goto haildb_error;
3043
3084
  }
3092
3133
  if (err != DB_SUCCESS)
3093
3134
    goto haildb_error;
3094
3135
 
3095
 
  err= ib_cfg_set_int("additional_mem_pool_size", static_cast<size_t>(innobase_additional_mem_pool_size));
3096
 
  if (err != DB_SUCCESS)
3097
 
    goto haildb_error;
3098
 
 
3099
 
  err= ib_cfg_set_int("autoextend_increment", static_cast<unsigned int>(srv_auto_extend_increment));
3100
 
  if (err != DB_SUCCESS)
3101
 
    goto haildb_error;
3102
 
 
3103
 
  err= ib_cfg_set_int("buffer_pool_size", static_cast<size_t>(innobase_buffer_pool_size));
3104
 
  if (err != DB_SUCCESS)
3105
 
    goto haildb_error;
3106
 
 
3107
 
  err= ib_cfg_set_int("io_capacity", static_cast<unsigned int>(srv_io_capacity));
 
3136
  err= ib_cfg_set_int("additional_mem_pool_size", innobase_additional_mem_pool_size);
 
3137
  if (err != DB_SUCCESS)
 
3138
    goto haildb_error;
 
3139
 
 
3140
  err= ib_cfg_set_int("autoextend_increment", srv_auto_extend_increment);
 
3141
  if (err != DB_SUCCESS)
 
3142
    goto haildb_error;
 
3143
 
 
3144
  err= ib_cfg_set_int("buffer_pool_size", innobase_buffer_pool_size);
 
3145
  if (err != DB_SUCCESS)
 
3146
    goto haildb_error;
 
3147
 
 
3148
  err= ib_cfg_set_int("io_capacity", srv_io_capacity);
3108
3149
  if (err != DB_SUCCESS)
3109
3150
    goto haildb_error;
3110
3151
 
3195
3236
 
3196
3237
  haildb_engine= new HailDBEngine("InnoDB");
3197
3238
  context.add(haildb_engine);
3198
 
  context.registerVariable(new sys_var_bool_ptr_readonly("adaptive_hash_index",
3199
 
                                                         &innobase_adaptive_hash_index));
3200
 
  context.registerVariable(new sys_var_bool_ptr_readonly("adaptive_flushing",
3201
 
                                                         &srv_adaptive_flushing));
3202
 
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
3203
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("autoextend_increment", srv_auto_extend_increment));
3204
 
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("buffer_pool_size", innobase_buffer_pool_size));
3205
 
  context.registerVariable(new sys_var_bool_ptr_readonly("checksums",
3206
 
                                                         &innobase_use_checksums));
3207
 
  context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite",
3208
 
                                                         &innobase_use_doublewrite));
3209
 
  context.registerVariable(new sys_var_const_string_val("data_home_dir",
3210
 
                                                vm.count("data-home-dir") ?  vm["data-home-dir"].as<string>() : ""));
3211
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("io_capacity", srv_io_capacity));
3212
3239
 
3213
3240
  haildb_datadict_dump_func_initialize(context);
3214
3241
  config_table_function_initialize(context);
3339
3366
    innobase_create_status_file= status_file_enabled;
3340
3367
}
3341
3368
 
 
3369
static DRIZZLE_SYSVAR_BOOL(adaptive_hash_index, innobase_adaptive_hash_index,
 
3370
  PLUGIN_VAR_NOCMDARG,
 
3371
  "Enable HailDB adaptive hash index (enabled by default).  ",
 
3372
  NULL, NULL, true);
 
3373
 
 
3374
static DRIZZLE_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
 
3375
  PLUGIN_VAR_NOCMDARG,
 
3376
  "Attempt flushing dirty pages to avoid IO bursts at checkpoints.",
 
3377
  NULL, NULL, true);
 
3378
 
 
3379
static DRIZZLE_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
 
3380
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3381
  "Size of a memory pool HailDB uses to store data dictionary information and other internal data structures.",
 
3382
  NULL, NULL, 8*1024*1024L, 512*1024L, LONG_MAX, 1024);
 
3383
 
 
3384
static DRIZZLE_SYSVAR_UINT(autoextend_increment, srv_auto_extend_increment,
 
3385
  PLUGIN_VAR_RQCMDARG,
 
3386
  "Data file autoextend increment in megabytes",
 
3387
  NULL, NULL, 8L, 1L, 1000L, 0);
 
3388
 
 
3389
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
 
3390
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3391
  "The size of the memory buffer HailDB uses to cache data and indexes of its tables.",
 
3392
  NULL, NULL, 128*1024*1024L, 5*1024*1024L, INT64_MAX, 1024*1024L);
 
3393
 
 
3394
static DRIZZLE_SYSVAR_BOOL(checksums, innobase_use_checksums,
 
3395
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
3396
  "Enable HailDB checksums validation (enabled by default). "
 
3397
  "Disable with --skip-haildb-checksums.",
 
3398
  NULL, NULL, true);
 
3399
 
 
3400
static DRIZZLE_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
 
3401
  PLUGIN_VAR_READONLY,
 
3402
  "The common part for HailDB table spaces.",
 
3403
  NULL, NULL, NULL);
 
3404
 
 
3405
static DRIZZLE_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
 
3406
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
3407
  "Enable HailDB doublewrite buffer (enabled by default). "
 
3408
  "Disable with --skip-haildb-doublewrite.",
 
3409
  NULL, NULL, true);
 
3410
 
 
3411
static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
 
3412
  PLUGIN_VAR_RQCMDARG,
 
3413
  "Number of IOPs the server can do. Tunes the background IO rate",
 
3414
  NULL, NULL, 200, 100, ~0L, 0);
 
3415
 
3342
3416
static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
3343
3417
  PLUGIN_VAR_OPCMDARG,
3344
3418
  "Speeds up the shutdown process of the HailDB storage engine. Possible "
3475
3549
  context("disable-adaptive-flushing",
3476
3550
          N_("Do not attempt to flush dirty pages to avoid IO bursts at checkpoints."));
3477
3551
  context("additional-mem-pool-size",
3478
 
          po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
 
3552
          po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
3479
3553
          N_("Size of a memory pool HailDB uses to store data dictionary information and other internal data structures."));
3480
3554
  context("autoextend-increment",
3481
 
          po::value<autoextend_constraint>(&srv_auto_extend_increment)->default_value(8),
 
3555
          po::value<unsigned int>(&srv_auto_extend_increment)->default_value(8L),
3482
3556
          N_("Data file autoextend increment in megabytes"));
3483
3557
  context("buffer-pool-size",
3484
 
          po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
 
3558
          po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
3485
3559
          N_("The size of the memory buffer HailDB uses to cache data and indexes of its tables."));
3486
3560
  context("data-home-dir",
3487
3561
          po::value<string>(),
3491
3565
  context("disable-doublewrite",
3492
3566
          N_("Disable HailDB doublewrite buffer (enabled by default)."));
3493
3567
  context("io-capacity",
3494
 
          po::value<io_capacity_constraint>(&srv_io_capacity)->default_value(200),
 
3568
          po::value<unsigned long>(&srv_io_capacity)->default_value(200),
3495
3569
          N_("Number of IOPs the server can do. Tunes the background IO rate"));
3496
3570
  context("fast-shutdown",
3497
3571
          po::value<unsigned long>(&innobase_fast_shutdown)->default_value(1),
3569
3643
}
3570
3644
 
3571
3645
static drizzle_sys_var* innobase_system_variables[]= {
 
3646
  DRIZZLE_SYSVAR(adaptive_hash_index),
 
3647
  DRIZZLE_SYSVAR(adaptive_flushing),
 
3648
  DRIZZLE_SYSVAR(additional_mem_pool_size),
 
3649
  DRIZZLE_SYSVAR(autoextend_increment),
 
3650
  DRIZZLE_SYSVAR(buffer_pool_size),
 
3651
  DRIZZLE_SYSVAR(checksums),
 
3652
  DRIZZLE_SYSVAR(data_home_dir),
 
3653
  DRIZZLE_SYSVAR(doublewrite),
 
3654
  DRIZZLE_SYSVAR(io_capacity),
3572
3655
  DRIZZLE_SYSVAR(fast_shutdown),
3573
3656
  DRIZZLE_SYSVAR(file_per_table),
3574
3657
  DRIZZLE_SYSVAR(file_format),