diff options
author | Monty <monty@mariadb.org> | 2014-10-07 11:37:36 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2014-10-07 11:37:36 +0300 |
commit | cc8aed3eb7a671d353c453a255b53e8d91d7fa73 (patch) | |
tree | 27989f6009e4fd08c1c9dde9df1d77c56a4f1fa3 /sql/wsrep_mysqld.cc | |
parent | 1a7d17311c8325a072e5c912a2eb3fffb95aa97d (diff) | |
download | mariadb-git-cc8aed3eb7a671d353c453a255b53e8d91d7fa73.tar.gz |
MDEV 4427: query timeouts
Added MAX_STATEMENT_TIME user variable to automaticly kill queries after a given time limit has expired.
- Added timer functions based on pthread_cond_timedwait
- Added kill_handlerton() to signal storage engines about kill/timeout
- Added support for GRANT ... MAX_STATEMENT_TIME=#
- Copy max_statement_time to current user, if stored in mysql.user
- Added status variable max_statement_time_exceeded
- Added KILL_TIMEOUT
- Removed digest hash from performance schema tests as they change all the time.
- Updated test results that changed because of the new user variables or new fields in mysql.user
This functionallity is inspired by work done by Davi Arnaut at twitter.
Test case is copied from Davi's work.
Documentation can be found at
https://kb.askmonty.org/en/how-to-limittimeout-queries/
mysql-test/r/mysqld--help.result:
Updated for new help message
mysql-test/suite/perfschema/r/all_instances.result:
Added new mutex
mysql-test/suite/sys_vars/r/max_statement_time_basic.result:
Added testing of max_statement_time
mysql-test/suite/sys_vars/t/max_statement_time_basic.test:
Added testing of max_statement_time
mysql-test/t/max_statement_time.test:
Added testing of max_statement_time
mysys/CMakeLists.txt:
Added thr_timer
mysys/my_init.c:
mysys/mysys_priv.h:
Added new mutex and condition variables
Added new mutex and condition variables
mysys/thr_timer.c:
Added timer functions based on pthread_cond_timedwait()
This can be compiled with HAVE_TIMER_CREATE to benchmark agains timer_create()/timer_settime()
sql/lex.h:
Added MAX_STATEMENT_TIME
sql/log_event.cc:
Safety fix (timeout should be threated as an interrupted query)
sql/mysqld.cc:
Added support for timers
Added status variable max_statement_time_exceeded
sql/share/errmsg-utf8.txt:
Added ER_QUERY_TIMEOUT
sql/signal_handler.cc:
Added support for KILL_TIMEOUT
sql/sql_acl.cc:
Added support for GRANT ... MAX_STATEMENT_TIME=#
Copy max_statement_time to current user
sql/sql_class.cc:
Added timer functionality to THD.
Added thd_kill_timeout()
sql/sql_class.h:
Added timer functionality to THD.
Added KILL_TIMEOUT
Added max_statement_time variable in similar manner as long_query_time was done.
sql/sql_connect.cc:
Added handling of max_statement_time_exceeded
sql/sql_parse.cc:
Added starting and stopping timers for queries.
sql/sql_show.cc:
Added max_statement_time_exceeded for user/connects status in MariaDB 10.0
sql/sql_yacc.yy:
Added support for GRANT ... MAX_STATEMENT_TIME=# syntax, to be enabled in 10.0
sql/structs.h:
Added max_statement_time user resource
sql/sys_vars.cc:
Added max_statement_time variables
mysql-test/suite/roles/create_and_drop_role_invalid_user_table.test
Removed test as we require all fields in mysql.user table.
scripts/mysql_system_tables.sql
scripts/mysql_system_tables_data.sql
scripts/mysql_system_tables_fix.sql
Updated mysql.user with new max_statement_time field
Diffstat (limited to 'sql/wsrep_mysqld.cc')
-rw-r--r-- | sql/wsrep_mysqld.cc | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 2897bb3fb69..938ec243f61 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -82,6 +82,7 @@ my_bool wsrep_restart_slave_activated = 0; // node has dropped, and slave // restart will be needed my_bool wsrep_slave_UK_checks = 0; // slave thread does UK checks my_bool wsrep_slave_FK_checks = 0; // slave thread does FK checks +bool wsrep_new_cluster = false; // Bootstrap the cluster ? /* * End configuration options */ @@ -886,37 +887,6 @@ void wsrep_stop_replication(THD *thd) return; } -/* This one is set to true when --wsrep-new-cluster is found in the command - * line arguments */ -static my_bool wsrep_new_cluster= FALSE; -#define WSREP_NEW_CLUSTER "--wsrep-new-cluster" -/* Finds and hides --wsrep-new-cluster from the arguments list - * by moving it to the end of the list and decrementing argument count */ -void wsrep_filter_new_cluster (int* argc, char* argv[]) -{ - int i; - for (i= *argc - 1; i > 0; i--) - { - /* make a copy of the argument to convert possible underscores to hyphens. - * the copy need not to be longer than WSREP_NEW_CLUSTER option */ - char arg[sizeof(WSREP_NEW_CLUSTER) + 1]= { 0, }; - strncpy(arg, argv[i], sizeof(arg) - 1); - char* underscore(arg); - while (NULL != (underscore= strchr(underscore, '_'))) *underscore= '-'; - - if (!strcmp(arg, WSREP_NEW_CLUSTER)) - { - wsrep_new_cluster= TRUE; - *argc -= 1; - /* preserve the order of remaining arguments AND - * preserve the original argument pointers - just in case */ - char* wnc= argv[i]; - memmove(&argv[i], &argv[i + 1], (*argc - i)*sizeof(argv[i])); - argv[*argc]= wnc; /* this will be invisible to the rest of the program */ - } - } -} - bool wsrep_start_replication() { wsrep_status_t rcode; @@ -939,11 +909,16 @@ bool wsrep_start_replication() return true; } - bool const bootstrap(TRUE == wsrep_new_cluster); - wsrep_new_cluster= FALSE; + bool const bootstrap= wsrep_new_cluster; WSREP_INFO("Start replication"); + if (wsrep_new_cluster) + { + WSREP_INFO("'wsrep-new-cluster' option used, bootstrapping the cluster"); + wsrep_new_cluster= false; + } + if ((rcode = wsrep->connect(wsrep, wsrep_cluster_name, wsrep_cluster_address, |