Commit abb87914 authored by unknown's avatar unknown

Group commit for maria engine.

mysql-test/suite/maria/r/group_commit.result:
  Test of gruoup commit.
mysql-test/suite/maria/r/maria3.result:
  The new variables added.
mysql-test/suite/maria/t/group_commit.test:
  Test of group commit.
randgen:
  Randon query generator tests.
randgen/conf:
  Random query generator tests.
randgen/conf/maria_group_commit.yy:
  Random query generator test for group commit.
storage/maria/ha_maria.cc:
  New variables and support procedures for group commit added.
storage/maria/ma_init.c:
  Correct shutdown of group commit service thread and group commit.
storage/maria/ma_loghandler.c:
  Group commit added.
  Initialization of variables for embeded server edded.
storage/maria/ma_loghandler.h:
  Group commit types and routines.
parent b6d030ed
drop table if exists t1;
create table t1 (a int);
SET GLOBAL maria_group_commit="NONE";
SET GLOBAL maria_group_commit_interval= 0;
SET GLOBAL maria_group_commit="NONE";
SET GLOBAL maria_group_commit_interval= 100;
SET GLOBAL maria_group_commit="HARD";
SET GLOBAL maria_group_commit_interval= 0;
SET GLOBAL maria_group_commit="HARD";
SET GLOBAL maria_group_commit_interval= 100;
SET GLOBAL maria_group_commit="SOFT";
SET GLOBAL maria_group_commit_interval= 0;
SET GLOBAL maria_group_commit="SOFT";
SET GLOBAL maria_group_commit_interval= 100;
SET GLOBAL maria_group_commit="NONE";
SET GLOBAL maria_group_commit_interval= 0;
drop table t1;
...@@ -306,6 +306,8 @@ Variable_name Value ...@@ -306,6 +306,8 @@ Variable_name Value
maria_block_size 8192 maria_block_size 8192
maria_checkpoint_interval 30 maria_checkpoint_interval 30
maria_force_start_after_recovery_failures 0 maria_force_start_after_recovery_failures 0
maria_group_commit none
maria_group_commit_interval 0
maria_log_file_size 4294959104 maria_log_file_size 4294959104
maria_log_purge_type immediate maria_log_purge_type immediate
maria_max_sort_file_size 9223372036853727232 maria_max_sort_file_size 9223372036853727232
...@@ -328,6 +330,7 @@ Maria_pagecache_read_requests # ...@@ -328,6 +330,7 @@ Maria_pagecache_read_requests #
Maria_pagecache_reads # Maria_pagecache_reads #
Maria_pagecache_write_requests # Maria_pagecache_write_requests #
Maria_pagecache_writes # Maria_pagecache_writes #
Maria_transaction_log_syncs #
create table t1 (b char(0)); create table t1 (b char(0));
insert into t1 values(NULL),(""); insert into t1 values(NULL),("");
select length(b) from t1; select length(b) from t1;
......
# Test different ways of syncing (mostly syntax)
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (a int);
SET GLOBAL maria_group_commit="NONE";
SET GLOBAL maria_group_commit_interval= 0;
--disable_query_log
let $num = 5000;
while ($num)
{
insert into t1 values (1);
dec $num;
}
--enable_query_log
SET GLOBAL maria_group_commit="NONE";
SET GLOBAL maria_group_commit_interval= 100;
--disable_query_log
let $num = 5000;
while ($num)
{
insert into t1 values (1);
dec $num;
}
--enable_query_log
SET GLOBAL maria_group_commit="HARD";
SET GLOBAL maria_group_commit_interval= 0;
--disable_query_log
let $num = 5000;
while ($num)
{
insert into t1 values (1);
dec $num;
}
--enable_query_log
SET GLOBAL maria_group_commit="HARD";
SET GLOBAL maria_group_commit_interval= 100;
--disable_query_log
let $num = 5000;
while ($num)
{
insert into t1 values (1);
dec $num;
}
--enable_query_log
SET GLOBAL maria_group_commit="SOFT";
SET GLOBAL maria_group_commit_interval= 0;
--disable_query_log
let $num = 5000;
while ($num)
{
insert into t1 values (1);
dec $num;
}
--enable_query_log
SET GLOBAL maria_group_commit="SOFT";
SET GLOBAL maria_group_commit_interval= 100;
--disable_query_log
let $num = 5000;
while ($num)
{
insert into t1 values (1);
dec $num;
}
--enable_query_log
SET GLOBAL maria_group_commit="NONE";
SET GLOBAL maria_group_commit_interval= 0;
drop table t1;
# test of group commit switching
query:
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
select | insert | update| delete |
change_group_commit | change_interval;
select:
SELECT select_item FROM join where order_by limit;
select_item:
* | X . _field ;
join:
_table AS X |
_table AS X LEFT JOIN _table AS Y ON ( X . _field = Y . _field ) ;
where:
|
WHERE X . _field < value |
WHERE X . _field > value |
WHERE X . _field = value ;
where_delete:
|
WHERE _field < value |
WHERE _field > value |
WHERE _field = value ;
order_by:
| ORDER BY X . _field ;
limit:
| LIMIT _digit ;
insert:
INSERT INTO _table ( _field , _field ) VALUES ( value , value ) ;
update:
UPDATE _table AS X SET _field = value where order_by limit ;
delete:
DELETE FROM _table where_delete LIMIT _digit ;
value:
' _letter ' | _digit | _date | _datetime | _time | _english ;
change_group_commit:
SET GLOBAL MARIA_GROUP_COMMIT=none_soft_hard;
none_soft_hard:
NONE | SOFT | HARD;
change_interval:
set_interval | set_interval | set_interval | set_interval |
drop_interval;
set_interval:
SET GLOBAL MARIA_GROUP_COMMIT_INTERVAL=_tinyint_unsigned;
drop_interval:
SET GLOBAL MARIA_GROUP_COMMIT_INTERVAL=0;
...@@ -102,22 +102,40 @@ TYPELIB maria_translog_purge_type_typelib= ...@@ -102,22 +102,40 @@ TYPELIB maria_translog_purge_type_typelib=
array_elements(maria_translog_purge_type_names) - 1, "", array_elements(maria_translog_purge_type_names) - 1, "",
maria_translog_purge_type_names, NULL maria_translog_purge_type_names, NULL
}; };
/* transactional log directory sync */
const char *maria_sync_log_dir_names[]= const char *maria_sync_log_dir_names[]=
{ {
"NEVER", "NEWFILE", "ALWAYS", NullS "NEVER", "NEWFILE", "ALWAYS", NullS
}; };
TYPELIB maria_sync_log_dir_typelib= TYPELIB maria_sync_log_dir_typelib=
{ {
array_elements(maria_sync_log_dir_names) - 1, "", array_elements(maria_sync_log_dir_names) - 1, "",
maria_sync_log_dir_names, NULL maria_sync_log_dir_names, NULL
}; };
/* transactional log group commit */
const char *maria_group_commit_names[]=
{
"none", "hard", "soft", NullS
};
TYPELIB maria_group_commit_typelib=
{
array_elements(maria_group_commit_names) - 1, "",
maria_group_commit_names, NULL
};
/** Interval between background checkpoints in seconds */ /** Interval between background checkpoints in seconds */
static ulong checkpoint_interval; static ulong checkpoint_interval;
static void update_checkpoint_interval(MYSQL_THD thd, static void update_checkpoint_interval(MYSQL_THD thd,
struct st_mysql_sys_var *var, struct st_mysql_sys_var *var,
void *var_ptr, const void *save); void *var_ptr, const void *save);
static void update_maria_group_commit(MYSQL_THD thd,
struct st_mysql_sys_var *var,
void *var_ptr, const void *save);
static void update_maria_group_commit_interval(MYSQL_THD thd,
struct st_mysql_sys_var *var,
void *var_ptr, const void *save);
/** After that many consecutive recovery failures, remove logs */ /** After that many consecutive recovery failures, remove logs */
static ulong force_start_after_recovery_failures; static ulong force_start_after_recovery_failures;
static void update_log_file_size(MYSQL_THD thd, static void update_log_file_size(MYSQL_THD thd,
...@@ -164,6 +182,24 @@ static MYSQL_SYSVAR_ULONG(log_file_size, log_file_size, ...@@ -164,6 +182,24 @@ static MYSQL_SYSVAR_ULONG(log_file_size, log_file_size,
NULL, update_log_file_size, TRANSLOG_FILE_SIZE, NULL, update_log_file_size, TRANSLOG_FILE_SIZE,
TRANSLOG_MIN_FILE_SIZE, 0xffffffffL, TRANSLOG_PAGE_SIZE); TRANSLOG_MIN_FILE_SIZE, 0xffffffffL, TRANSLOG_PAGE_SIZE);
static MYSQL_SYSVAR_ENUM(group_commit, maria_group_commit,
PLUGIN_VAR_RQCMDARG,
"Specifies maria group commit mode. "
"Possible values are \"none\" (no group commit), "
"\"hard\" (with waiting to actual commit), "
"\"soft\" (no wait for commit (DANGEROUS!!!))",
NULL, update_maria_group_commit,
TRANSLOG_GCOMMIT_NONE, &maria_group_commit_typelib);
static MYSQL_SYSVAR_ULONG(group_commit_interval, maria_group_commit_interval,
PLUGIN_VAR_RQCMDARG,
"Interval between commite in microseconds (1/1000000c)."
" 0 stands for no waiting"
" for other threads to come and do a commit in \"hard\" mode and no"
" sync()/commit at all in \"soft\" mode. Option has only an effect"
" if maria_group_commit is used",
NULL, update_maria_group_commit_interval, 0, 0, UINT_MAX, 1);
static MYSQL_SYSVAR_ENUM(log_purge_type, log_purge_type, static MYSQL_SYSVAR_ENUM(log_purge_type, log_purge_type,
PLUGIN_VAR_RQCMDARG, PLUGIN_VAR_RQCMDARG,
"Specifies how maria transactional log will be purged. " "Specifies how maria transactional log will be purged. "
...@@ -3278,6 +3314,8 @@ static struct st_mysql_sys_var* system_variables[]= { ...@@ -3278,6 +3314,8 @@ static struct st_mysql_sys_var* system_variables[]= {
MYSQL_SYSVAR(block_size), MYSQL_SYSVAR(block_size),
MYSQL_SYSVAR(checkpoint_interval), MYSQL_SYSVAR(checkpoint_interval),
MYSQL_SYSVAR(force_start_after_recovery_failures), MYSQL_SYSVAR(force_start_after_recovery_failures),
MYSQL_SYSVAR(group_commit),
MYSQL_SYSVAR(group_commit_interval),
MYSQL_SYSVAR(page_checksum), MYSQL_SYSVAR(page_checksum),
MYSQL_SYSVAR(log_dir_path), MYSQL_SYSVAR(log_dir_path),
MYSQL_SYSVAR(log_file_size), MYSQL_SYSVAR(log_file_size),
...@@ -3308,6 +3346,92 @@ static void update_checkpoint_interval(MYSQL_THD thd, ...@@ -3308,6 +3346,92 @@ static void update_checkpoint_interval(MYSQL_THD thd,
ma_checkpoint_init(*(ulong *)var_ptr= (ulong)(*(long *)save)); ma_checkpoint_init(*(ulong *)var_ptr= (ulong)(*(long *)save));
} }
/**
@brief Updates group commit mode
*/
static void update_maria_group_commit(MYSQL_THD thd,
struct st_mysql_sys_var *var,
void *var_ptr, const void *save)
{
ulong value= (ulong)*((long *)var_ptr);
DBUG_ENTER("update_maria_group_commit");
DBUG_PRINT("enter", ("old value: %lu new value %lu rate %lu",
value, (ulong)(*(long *)save),
maria_group_commit_interval));
/* old value */
switch (value) {
case TRANSLOG_GCOMMIT_NONE:
break;
case TRANSLOG_GCOMMIT_HARD:
translog_hard_group_commit(FALSE);
break;
case TRANSLOG_GCOMMIT_SOFT:
translog_soft_sync(FALSE);
if (maria_group_commit_interval)
translog_soft_sync_end();
break;
default:
DBUG_ASSERT(0); /* impossible */
}
value= *(ulong *)var_ptr= (ulong)(*(long *)save);
translog_sync();
/* new value */
switch (value) {
case TRANSLOG_GCOMMIT_NONE:
break;
case TRANSLOG_GCOMMIT_HARD:
translog_hard_group_commit(TRUE);
break;
case TRANSLOG_GCOMMIT_SOFT:
translog_soft_sync(TRUE);
/* variable change made under global lock so we can just read it */
if (maria_group_commit_interval)
translog_soft_sync_start();
break;
default:
DBUG_ASSERT(0); /* impossible */
}
DBUG_VOID_RETURN;
}
/**
@brief Updates group commit interval
*/
static void update_maria_group_commit_interval(MYSQL_THD thd,
struct st_mysql_sys_var *var,
void *var_ptr, const void *save)
{
ulong new_value= (ulong)*((long *)save);
ulong *value_ptr= (ulong*) var_ptr;
DBUG_ENTER("update_maria_group_commit_interval");
DBUG_PRINT("enter", ("old value: %lu new value %lu group commit %lu",
*value_ptr, new_value, maria_group_commit));
/* variable change made under global lock so we can just read it */
switch (maria_group_commit) {
case TRANSLOG_GCOMMIT_NONE:
*value_ptr= new_value;
translog_set_group_commit_interval(new_value);
break;
case TRANSLOG_GCOMMIT_HARD:
*value_ptr= new_value;
translog_set_group_commit_interval(new_value);
break;
case TRANSLOG_GCOMMIT_SOFT:
if (*value_ptr)
translog_soft_sync_end();
translog_set_group_commit_interval(new_value);
if ((*value_ptr= new_value))
translog_soft_sync_start();
break;
default:
DBUG_ASSERT(0); /* impossible */
}
DBUG_VOID_RETURN;
}
/** /**
@brief Updates the transaction log file limit. @brief Updates the transaction log file limit.
*/ */
...@@ -3330,6 +3454,7 @@ static SHOW_VAR status_variables[]= { ...@@ -3330,6 +3454,7 @@ static SHOW_VAR status_variables[]= {
{"Maria_pagecache_reads", (char*) &maria_pagecache_var.global_cache_read, SHOW_LONGLONG}, {"Maria_pagecache_reads", (char*) &maria_pagecache_var.global_cache_read, SHOW_LONGLONG},
{"Maria_pagecache_write_requests", (char*) &maria_pagecache_var.global_cache_w_requests, SHOW_LONGLONG}, {"Maria_pagecache_write_requests", (char*) &maria_pagecache_var.global_cache_w_requests, SHOW_LONGLONG},
{"Maria_pagecache_writes", (char*) &maria_pagecache_var.global_cache_write, SHOW_LONGLONG}, {"Maria_pagecache_writes", (char*) &maria_pagecache_var.global_cache_write, SHOW_LONGLONG},
{"Maria_transaction_log_syncs", (char*) &translog_syncs, SHOW_LONGLONG},
{NullS, NullS, SHOW_LONG} {NullS, NullS, SHOW_LONG}
}; };
......
...@@ -82,6 +82,11 @@ void maria_end(void) ...@@ -82,6 +82,11 @@ void maria_end(void)
maria_inited= maria_multi_threaded= FALSE; maria_inited= maria_multi_threaded= FALSE;
ft_free_stopwords(); ft_free_stopwords();
ma_checkpoint_end(); ma_checkpoint_end();
if (translog_status == TRANSLOG_OK)
{
translog_soft_sync_end();
translog_sync();
}
if ((trid= trnman_get_max_trid()) > max_trid_in_control_file) if ((trid= trnman_get_max_trid()) > max_trid_in_control_file)
{ {
/* /*
......
This diff is collapsed.
...@@ -342,6 +342,14 @@ enum enum_translog_status ...@@ -342,6 +342,14 @@ enum enum_translog_status
TRANSLOG_SHUTDOWN /* going to shutdown the loghandler */ TRANSLOG_SHUTDOWN /* going to shutdown the loghandler */
}; };
extern enum enum_translog_status translog_status; extern enum enum_translog_status translog_status;
extern ulonglong translog_syncs; /* Number of sync()s */
void translog_soft_sync(my_bool mode);
void translog_hard_group_commit(my_bool mode);
int translog_soft_sync_start(void);
void translog_soft_sync_end(void);
void translog_sync();
void translog_set_group_commit_interval(uint32 interval);
/* /*
all the rest added because of recovery; should we make all the rest added because of recovery; should we make
...@@ -439,6 +447,14 @@ typedef struct st_log_record_type_descriptor ...@@ -439,6 +447,14 @@ typedef struct st_log_record_type_descriptor
extern LOG_DESC log_record_type_descriptor[LOGREC_NUMBER_OF_TYPES]; extern LOG_DESC log_record_type_descriptor[LOGREC_NUMBER_OF_TYPES];
typedef enum
{
TRANSLOG_GCOMMIT_NONE,
TRANSLOG_GCOMMIT_HARD,
TRANSLOG_GCOMMIT_SOFT
} enum_maria_group_commit;
extern ulong maria_group_commit;
extern ulong maria_group_commit_interval;
typedef enum typedef enum
{ {
TRANSLOG_PURGE_IMMIDIATE, TRANSLOG_PURGE_IMMIDIATE,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment