2014-02-26 15:28:07 +01:00
|
|
|
/* Copyright (c) 2006, 2013, Oracle and/or its affiliates.
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2006-12-27 02:23:51 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2019-05-11 20:29:06 +02:00
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
|
2017-06-18 05:42:16 +02:00
|
|
|
#include "mariadb.h"
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_priv.h"
|
|
|
|
#include "unireg.h"
|
|
|
|
#include "event_scheduler.h"
|
2006-07-12 10:37:30 +02:00
|
|
|
#include "events.h"
|
|
|
|
#include "event_data_objects.h"
|
|
|
|
#include "event_queue.h"
|
2007-01-29 18:46:29 +01:00
|
|
|
#include "event_db_repository.h"
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_connect.h" // init_new_connection_handler_thread
|
2020-02-28 18:59:01 +01:00
|
|
|
#include "sql_class.h"
|
2006-07-12 10:37:30 +02:00
|
|
|
|
2007-08-15 17:08:44 +02:00
|
|
|
/**
|
|
|
|
@addtogroup Event_Scheduler
|
|
|
|
@{
|
|
|
|
*/
|
|
|
|
|
2006-07-12 10:37:30 +02:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#if __GNUC__ >= 2
|
|
|
|
#define SCHED_FUNC __FUNCTION__
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#define SCHED_FUNC "<unknown>"
|
|
|
|
#endif
|
|
|
|
|
2006-07-17 16:52:45 +02:00
|
|
|
#define LOCK_DATA() lock_data(SCHED_FUNC, __LINE__)
|
|
|
|
#define UNLOCK_DATA() unlock_data(SCHED_FUNC, __LINE__)
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
#define COND_STATE_WAIT(mythd, abstime, stage) \
|
|
|
|
cond_wait(mythd, abstime, stage, SCHED_FUNC, __FILE__, __LINE__)
|
2006-07-12 10:37:30 +02:00
|
|
|
|
|
|
|
extern pthread_attr_t connection_attrib;
|
2012-09-09 00:22:06 +02:00
|
|
|
extern ulong event_executed;
|
2007-01-29 18:46:29 +01:00
|
|
|
|
|
|
|
Event_db_repository *Event_worker_thread::db_repository;
|
|
|
|
|
|
|
|
|
2006-07-12 10:37:30 +02:00
|
|
|
static
|
2018-01-08 14:33:23 +01:00
|
|
|
const LEX_CSTRING scheduler_states_names[] =
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
2018-01-08 14:33:23 +01:00
|
|
|
{ STRING_WITH_LEN("INITIALIZED") },
|
|
|
|
{ STRING_WITH_LEN("RUNNING") },
|
|
|
|
{ STRING_WITH_LEN("STOPPING") }
|
2006-07-12 10:37:30 +02:00
|
|
|
};
|
|
|
|
|
2006-07-13 16:24:55 +02:00
|
|
|
struct scheduler_param {
|
|
|
|
THD *thd;
|
|
|
|
Event_scheduler *scheduler;
|
|
|
|
};
|
|
|
|
|
2006-07-12 10:37:30 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Prints the stack of infos, warnings, errors from thd to
|
|
|
|
the console so it can be fetched by the logs-into-tables and
|
|
|
|
checked later.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
evex_print_warnings
|
|
|
|
thd Thread used during the execution of the event
|
|
|
|
et The event itself
|
|
|
|
*/
|
|
|
|
|
2007-01-29 18:46:29 +01:00
|
|
|
void
|
|
|
|
Event_worker_thread::print_warnings(THD *thd, Event_job_data *et)
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
2013-06-15 17:32:08 +02:00
|
|
|
const Sql_condition *err;
|
2006-07-12 10:37:30 +02:00
|
|
|
DBUG_ENTER("evex_print_warnings");
|
2013-06-15 17:32:08 +02:00
|
|
|
if (thd->get_stmt_da()->is_warning_info_empty())
|
2006-07-12 10:37:30 +02:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
|
|
|
|
char msg_buf[10 * STRING_BUFFER_USUAL_SIZE];
|
|
|
|
char prefix_buf[5 * STRING_BUFFER_USUAL_SIZE];
|
|
|
|
String prefix(prefix_buf, sizeof(prefix_buf), system_charset_info);
|
|
|
|
prefix.length(0);
|
2017-06-19 05:34:38 +02:00
|
|
|
prefix.append(STRING_WITH_LEN("Event Scheduler: ["));
|
2006-07-12 10:37:30 +02:00
|
|
|
|
A set of changes aiming to make the Event Scheduler more user-friendly
when there are no up-to-date system tables to support it:
- initialize the scheduler before reporting "Ready for connections".
This ensures that warnings, if any, are printed before "Ready for
connections", and this message is not mangled.
- do not abort the scheduler if there are no system tables
- check the tables once at start up, remember the status and disable
the scheduler if the tables are not up to date.
If one attempts to use the scheduler with bad tables,
issue an error message.
- clean up the behaviour of the module under LOCK TABLES and pre-locking
mode
- make sure implicit commit of Events DDL works as expected.
- add more tests
Collateral clean ups in the events code.
This patch fixes Bug#23631 Events: SHOW VARIABLES doesn't work
when mysql.event is damaged
mysql-test/r/events.result:
Update results.
mysql-test/r/events_bugs.result:
Update results.
mysql-test/r/events_restart_phase1.result:
Update results.
mysql-test/r/events_restart_phase2.result:
Update results.
mysql-test/r/events_restart_phase3.result:
Update results.
mysql-test/r/events_scheduling.result:
Update results.
mysql-test/r/events_time_zone.result:
Update results.
mysql-test/t/events.test:
Add new tests for tampering with mysql.event and some more
tests for sub-statements, LOCK TABLES mode and pre-locking.
mysql-test/t/events_bugs.test:
Move the non-concurrent part of test for Bug 16420 to this file.
mysql-test/t/events_restart_phase1.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase2.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase3.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_scheduling.test:
Add more coverage for event_scheduler global variable.
mysql-test/t/events_time_zone.test:
Move the non-concurrent part of the tests for Bug 16420 to
events_bugs.test
sql/event_data_objects.cc:
Move update_timing_fields functionality to Event_db_repository.
Make loading of events from a table record more robust to tampering
with the table - now we do not check mysql.event on every table open.
sql/event_data_objects.h:
Cleanup.
sql/event_db_repository.cc:
Now Event_db_repository is responsible for table I/O only.
All the logic of events DDL is handled outside, in Events class please
refer to the added test coverage to see how this change affected
the behavior of Event Scheduler.
Dependency on sp_head.h and sp.h removed.
Make this module robust to tweaks with mysql.event table.
Move check_system_tables from events.cc to this file
sql/event_db_repository.h:
Cleanup declarations (remove unused ones, change return type to bool
from int).
sql/event_queue.cc:
Update to adapt to the new start up scheme of the Event Scheduler.
sql/event_queue.h:
Cleanup declarations.
sql/event_scheduler.cc:
Make all the error messages uniform:
[SEVERITY] Event Scheduler: [user][schema.event] message
Using append_identifier for error logging was an overkill - we may
need it only if the system character set may have NUL (null character)
as part of a valid identifier, this is currently never the case,
whereas additional quoting did not look nice in the log.
sql/event_scheduler.h:
Cleanup the headers.
sql/events.cc:
Use a different start up procedure of Event Scheduler:
- at start up, try to check the system tables first.
If they are not up-to-date, disable the scheduler.
- try to load all the active events. In case of a load error, abort
start up.
- do not parse an event on start up. Parsing only gives some information
about event validity, but far not all.
Consolidate the business logic of Events DDL in this module.
Now opt_event_scheduler may change after start up and thus is protected
by LOCK_event_metadata mutex.
sql/events.h:
Use all-static-data-members approach to implement Singleton pattern.
sql/mysqld.cc:
New invocation scheme of Events. Move some logic to events.cc.
Initialize the scheduler before reporting "Ready for connections".
sql/set_var.cc:
Clean up sys_var_thd_sql_mode::symbolic_mode_representation
to work with a LEX_STRING.
Move more logic related to @@events_scheduler global variable to Events
module.
sql/set_var.h:
Update declarations.
sql/share/errmsg.txt:
If someone tampered with mysql.event table after the server has
started we no longer give him/her a complete report what was actually
broken. Do not send the user to look at the error log in such case,
as there is nothing there (check_table_intact is not executed).
sql/sp_head.cc:
Update to a new declaration of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_db.cc:
New invocation scheme of Events module.
sql/sql_parse.cc:
Move more logic to Events module. Make sure that we are consistent
in the way access rights are checked for Events DDL: always
after committing the current transaction and checking the system tables.
sql/sql_show.cc:
Update to the new declarations of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_test.cc:
New invocation scheme of events.
sql/table.cc:
mysql.event is a system table.
Update check_table_intact to be concurrent, more verbose, and less smart.
sql/table.h:
Add a helper method.
mysql-test/r/events_trans.result:
New BitKeeper file ``mysql-test/r/events_trans.result''
mysql-test/t/events_trans.test:
New BitKeeper file ``mysql-test/t/events_trans.test'':
test cases for Event Scheduler that require a transactional
storage engine.
2007-04-05 13:24:34 +02:00
|
|
|
prefix.append(et->definer.str, et->definer.length, system_charset_info);
|
2006-07-12 10:37:30 +02:00
|
|
|
prefix.append("][", 2);
|
A set of changes aiming to make the Event Scheduler more user-friendly
when there are no up-to-date system tables to support it:
- initialize the scheduler before reporting "Ready for connections".
This ensures that warnings, if any, are printed before "Ready for
connections", and this message is not mangled.
- do not abort the scheduler if there are no system tables
- check the tables once at start up, remember the status and disable
the scheduler if the tables are not up to date.
If one attempts to use the scheduler with bad tables,
issue an error message.
- clean up the behaviour of the module under LOCK TABLES and pre-locking
mode
- make sure implicit commit of Events DDL works as expected.
- add more tests
Collateral clean ups in the events code.
This patch fixes Bug#23631 Events: SHOW VARIABLES doesn't work
when mysql.event is damaged
mysql-test/r/events.result:
Update results.
mysql-test/r/events_bugs.result:
Update results.
mysql-test/r/events_restart_phase1.result:
Update results.
mysql-test/r/events_restart_phase2.result:
Update results.
mysql-test/r/events_restart_phase3.result:
Update results.
mysql-test/r/events_scheduling.result:
Update results.
mysql-test/r/events_time_zone.result:
Update results.
mysql-test/t/events.test:
Add new tests for tampering with mysql.event and some more
tests for sub-statements, LOCK TABLES mode and pre-locking.
mysql-test/t/events_bugs.test:
Move the non-concurrent part of test for Bug 16420 to this file.
mysql-test/t/events_restart_phase1.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase2.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase3.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_scheduling.test:
Add more coverage for event_scheduler global variable.
mysql-test/t/events_time_zone.test:
Move the non-concurrent part of the tests for Bug 16420 to
events_bugs.test
sql/event_data_objects.cc:
Move update_timing_fields functionality to Event_db_repository.
Make loading of events from a table record more robust to tampering
with the table - now we do not check mysql.event on every table open.
sql/event_data_objects.h:
Cleanup.
sql/event_db_repository.cc:
Now Event_db_repository is responsible for table I/O only.
All the logic of events DDL is handled outside, in Events class please
refer to the added test coverage to see how this change affected
the behavior of Event Scheduler.
Dependency on sp_head.h and sp.h removed.
Make this module robust to tweaks with mysql.event table.
Move check_system_tables from events.cc to this file
sql/event_db_repository.h:
Cleanup declarations (remove unused ones, change return type to bool
from int).
sql/event_queue.cc:
Update to adapt to the new start up scheme of the Event Scheduler.
sql/event_queue.h:
Cleanup declarations.
sql/event_scheduler.cc:
Make all the error messages uniform:
[SEVERITY] Event Scheduler: [user][schema.event] message
Using append_identifier for error logging was an overkill - we may
need it only if the system character set may have NUL (null character)
as part of a valid identifier, this is currently never the case,
whereas additional quoting did not look nice in the log.
sql/event_scheduler.h:
Cleanup the headers.
sql/events.cc:
Use a different start up procedure of Event Scheduler:
- at start up, try to check the system tables first.
If they are not up-to-date, disable the scheduler.
- try to load all the active events. In case of a load error, abort
start up.
- do not parse an event on start up. Parsing only gives some information
about event validity, but far not all.
Consolidate the business logic of Events DDL in this module.
Now opt_event_scheduler may change after start up and thus is protected
by LOCK_event_metadata mutex.
sql/events.h:
Use all-static-data-members approach to implement Singleton pattern.
sql/mysqld.cc:
New invocation scheme of Events. Move some logic to events.cc.
Initialize the scheduler before reporting "Ready for connections".
sql/set_var.cc:
Clean up sys_var_thd_sql_mode::symbolic_mode_representation
to work with a LEX_STRING.
Move more logic related to @@events_scheduler global variable to Events
module.
sql/set_var.h:
Update declarations.
sql/share/errmsg.txt:
If someone tampered with mysql.event table after the server has
started we no longer give him/her a complete report what was actually
broken. Do not send the user to look at the error log in such case,
as there is nothing there (check_table_intact is not executed).
sql/sp_head.cc:
Update to a new declaration of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_db.cc:
New invocation scheme of Events module.
sql/sql_parse.cc:
Move more logic to Events module. Make sure that we are consistent
in the way access rights are checked for Events DDL: always
after committing the current transaction and checking the system tables.
sql/sql_show.cc:
Update to the new declarations of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_test.cc:
New invocation scheme of events.
sql/table.cc:
mysql.event is a system table.
Update check_table_intact to be concurrent, more verbose, and less smart.
sql/table.h:
Add a helper method.
mysql-test/r/events_trans.result:
New BitKeeper file ``mysql-test/r/events_trans.result''
mysql-test/t/events_trans.test:
New BitKeeper file ``mysql-test/t/events_trans.test'':
test cases for Event Scheduler that require a transactional
storage engine.
2007-04-05 13:24:34 +02:00
|
|
|
prefix.append(et->dbname.str, et->dbname.length, system_charset_info);
|
2006-07-12 10:37:30 +02:00
|
|
|
prefix.append('.');
|
A set of changes aiming to make the Event Scheduler more user-friendly
when there are no up-to-date system tables to support it:
- initialize the scheduler before reporting "Ready for connections".
This ensures that warnings, if any, are printed before "Ready for
connections", and this message is not mangled.
- do not abort the scheduler if there are no system tables
- check the tables once at start up, remember the status and disable
the scheduler if the tables are not up to date.
If one attempts to use the scheduler with bad tables,
issue an error message.
- clean up the behaviour of the module under LOCK TABLES and pre-locking
mode
- make sure implicit commit of Events DDL works as expected.
- add more tests
Collateral clean ups in the events code.
This patch fixes Bug#23631 Events: SHOW VARIABLES doesn't work
when mysql.event is damaged
mysql-test/r/events.result:
Update results.
mysql-test/r/events_bugs.result:
Update results.
mysql-test/r/events_restart_phase1.result:
Update results.
mysql-test/r/events_restart_phase2.result:
Update results.
mysql-test/r/events_restart_phase3.result:
Update results.
mysql-test/r/events_scheduling.result:
Update results.
mysql-test/r/events_time_zone.result:
Update results.
mysql-test/t/events.test:
Add new tests for tampering with mysql.event and some more
tests for sub-statements, LOCK TABLES mode and pre-locking.
mysql-test/t/events_bugs.test:
Move the non-concurrent part of test for Bug 16420 to this file.
mysql-test/t/events_restart_phase1.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase2.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase3.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_scheduling.test:
Add more coverage for event_scheduler global variable.
mysql-test/t/events_time_zone.test:
Move the non-concurrent part of the tests for Bug 16420 to
events_bugs.test
sql/event_data_objects.cc:
Move update_timing_fields functionality to Event_db_repository.
Make loading of events from a table record more robust to tampering
with the table - now we do not check mysql.event on every table open.
sql/event_data_objects.h:
Cleanup.
sql/event_db_repository.cc:
Now Event_db_repository is responsible for table I/O only.
All the logic of events DDL is handled outside, in Events class please
refer to the added test coverage to see how this change affected
the behavior of Event Scheduler.
Dependency on sp_head.h and sp.h removed.
Make this module robust to tweaks with mysql.event table.
Move check_system_tables from events.cc to this file
sql/event_db_repository.h:
Cleanup declarations (remove unused ones, change return type to bool
from int).
sql/event_queue.cc:
Update to adapt to the new start up scheme of the Event Scheduler.
sql/event_queue.h:
Cleanup declarations.
sql/event_scheduler.cc:
Make all the error messages uniform:
[SEVERITY] Event Scheduler: [user][schema.event] message
Using append_identifier for error logging was an overkill - we may
need it only if the system character set may have NUL (null character)
as part of a valid identifier, this is currently never the case,
whereas additional quoting did not look nice in the log.
sql/event_scheduler.h:
Cleanup the headers.
sql/events.cc:
Use a different start up procedure of Event Scheduler:
- at start up, try to check the system tables first.
If they are not up-to-date, disable the scheduler.
- try to load all the active events. In case of a load error, abort
start up.
- do not parse an event on start up. Parsing only gives some information
about event validity, but far not all.
Consolidate the business logic of Events DDL in this module.
Now opt_event_scheduler may change after start up and thus is protected
by LOCK_event_metadata mutex.
sql/events.h:
Use all-static-data-members approach to implement Singleton pattern.
sql/mysqld.cc:
New invocation scheme of Events. Move some logic to events.cc.
Initialize the scheduler before reporting "Ready for connections".
sql/set_var.cc:
Clean up sys_var_thd_sql_mode::symbolic_mode_representation
to work with a LEX_STRING.
Move more logic related to @@events_scheduler global variable to Events
module.
sql/set_var.h:
Update declarations.
sql/share/errmsg.txt:
If someone tampered with mysql.event table after the server has
started we no longer give him/her a complete report what was actually
broken. Do not send the user to look at the error log in such case,
as there is nothing there (check_table_intact is not executed).
sql/sp_head.cc:
Update to a new declaration of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_db.cc:
New invocation scheme of Events module.
sql/sql_parse.cc:
Move more logic to Events module. Make sure that we are consistent
in the way access rights are checked for Events DDL: always
after committing the current transaction and checking the system tables.
sql/sql_show.cc:
Update to the new declarations of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_test.cc:
New invocation scheme of events.
sql/table.cc:
mysql.event is a system table.
Update check_table_intact to be concurrent, more verbose, and less smart.
sql/table.h:
Add a helper method.
mysql-test/r/events_trans.result:
New BitKeeper file ``mysql-test/r/events_trans.result''
mysql-test/t/events_trans.test:
New BitKeeper file ``mysql-test/t/events_trans.test'':
test cases for Event Scheduler that require a transactional
storage engine.
2007-04-05 13:24:34 +02:00
|
|
|
prefix.append(et->name.str, et->name.length, system_charset_info);
|
2006-07-12 10:37:30 +02:00
|
|
|
prefix.append("] ", 2);
|
|
|
|
|
2013-06-15 17:32:08 +02:00
|
|
|
Diagnostics_area::Sql_condition_iterator it=
|
|
|
|
thd->get_stmt_da()->sql_conditions();
|
2006-07-12 10:37:30 +02:00
|
|
|
while ((err= it++))
|
|
|
|
{
|
|
|
|
String err_msg(msg_buf, sizeof(msg_buf), system_charset_info);
|
|
|
|
/* set it to 0 or we start adding at the end. That's the trick ;) */
|
|
|
|
err_msg.length(0);
|
|
|
|
err_msg.append(prefix);
|
2009-09-10 11:18:29 +02:00
|
|
|
err_msg.append(err->get_message_text(),
|
|
|
|
err->get_message_octet_length(), system_charset_info);
|
|
|
|
DBUG_ASSERT(err->get_level() < 3);
|
|
|
|
(sql_print_message_handlers[err->get_level()])("%*s", err_msg.length(),
|
2011-10-19 21:45:18 +02:00
|
|
|
err_msg.c_ptr_safe());
|
2006-07-12 10:37:30 +02:00
|
|
|
}
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-13 10:59:58 +02:00
|
|
|
/*
|
|
|
|
Performs post initialization of structures in a new thread.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
post_init_event_thread()
|
|
|
|
thd Thread
|
2007-03-01 21:47:28 +01:00
|
|
|
|
|
|
|
NOTES
|
|
|
|
Before this is called, one should not do any DBUG_XXX() calls.
|
|
|
|
|
2006-07-13 10:59:58 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
bool
|
|
|
|
post_init_event_thread(THD *thd)
|
|
|
|
{
|
2007-03-01 21:47:28 +01:00
|
|
|
(void) init_new_connection_handler_thread();
|
2020-04-30 19:06:26 +02:00
|
|
|
if (init_thr_lock())
|
2006-07-13 10:59:58 +02:00
|
|
|
{
|
|
|
|
thd->cleanup();
|
|
|
|
return TRUE;
|
|
|
|
}
|
2020-04-30 19:06:26 +02:00
|
|
|
thd->store_globals();
|
2006-07-13 10:59:58 +02:00
|
|
|
return FALSE;
|
2006-07-12 10:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Cleans up the THD and the threaded environment of the thread.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
deinit_event_thread()
|
|
|
|
thd Thread
|
|
|
|
*/
|
|
|
|
|
2006-07-13 10:59:58 +02:00
|
|
|
void
|
2006-07-12 10:37:30 +02:00
|
|
|
deinit_event_thread(THD *thd)
|
|
|
|
{
|
|
|
|
thd->proc_info= "Clearing";
|
2006-07-17 16:52:45 +02:00
|
|
|
DBUG_PRINT("exit", ("Event thread finishing"));
|
2019-01-19 23:32:35 +01:00
|
|
|
server_threads.erase(thd);
|
2017-02-28 12:23:44 +01:00
|
|
|
delete thd;
|
2006-07-12 10:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-13 16:24:55 +02:00
|
|
|
/*
|
2010-01-07 06:42:07 +01:00
|
|
|
Performs pre- mysql_thread_create() initialisation of THD. Do this
|
2006-07-13 16:24:55 +02:00
|
|
|
in the thread that will pass THD to the child thread. In the
|
|
|
|
child thread call post_init_event_thread().
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
pre_init_event_thread()
|
|
|
|
thd The THD of the thread. Has to be allocated by the caller.
|
|
|
|
|
|
|
|
NOTES
|
|
|
|
1. The host of the thead is my_localhost
|
|
|
|
2. thd->net is initted with NULL - no communication.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
pre_init_event_thread(THD* thd)
|
|
|
|
{
|
MDEV-4011 Added per thread memory counting and usage
Base code and idea from a patch from by plinux at Taobao.
The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC.
Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc().
There are plenty of new asserts to ensure that for a debug server the counting is correct.
Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS.
- The later is there mainly to show how query is progressing.
The following changes in interfaces was needed to get this to work:
- init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root()
- my_init_dynamic_array() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- Added flag for hash_init() so that one can mark hash table to be thread specific.
- Added flags to init_tree() so that one can mark tree to be thread specific.
- Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
- Added flag to Warning_info::Warning_info() if the structure should be fully initialized.
- String elements can now be marked as thread specific.
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Changed type of myf from int to ulong, as this is always a set of bit flags.
Other things:
- Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
- We now also show EXAMINED_ROWS in SHOW PROCESSLIST
- Added new variable 'memory_used'
- Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
- Removed calls to the obsoleted function init_dynamic_array()
- Use set_current_thd() instead of my_pthread_setspecific_ptr(THR_THD,...)
client/completion_hash.cc:
Updated call to init_alloc_root()
client/mysql.cc:
Updated call to init_alloc_root()
client/mysqlbinlog.cc:
init_dynamic_array() -> my_init_dynamic_array()
Updated call to init_alloc_root()
client/mysqlcheck.c:
Updated call to my_init_dynamic_array()
client/mysqldump.c:
Updated call to init_alloc_root()
client/mysqltest.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Fixed compiler warnings
extra/comp_err.c:
Updated call to my_init_dynamic_array()
extra/resolve_stack_dump.c:
Updated call to my_init_dynamic_array()
include/hash.h:
Added HASH_THREAD_SPECIFIC
include/heap.h:
Added flag is internal temporary table.
include/my_dir.h:
Safety fix: Ensure that MY_DONT_SORT and MY_WANT_STAT don't interfer with other mysys flags
include/my_global.h:
Changed type of myf from int to ulong, as this is always a set of bit flags.
include/my_sys.h:
Added MY_THREAD_SPECIFIC and MY_THREAD_MOVE
Added malloc_flags to DYNAMIC_ARRAY
Added extra mysys flag argument to my_init_dynamic_array()
Removed deprecated functions init_dynamic_array() and my_init_dynamic_array.._ci
Updated paramaters for init_alloc_root()
include/my_tree.h:
Added my_flags to allow one to use MY_THREAD_SPECIFIC with hash tables.
Removed with_delete. One should now instead use MY_TREE_WITH_DELETE_FLAG
Updated parameters to init_tree()
include/myisamchk.h:
Added malloc_flags to allow one to use MY_THREAD_SPECIFIC for checks.
include/mysql.h:
Added MYSQL_THREAD_SPECIFIC_MALLOC
Used 'unused1' to mark memory as thread specific.
include/mysql.h.pp:
Updated file
include/mysql_com.h:
Used 'unused1' to mark memory as thread specific.
Updated parameters for my_net_init()
libmysql/libmysql.c:
Updated call to init_alloc_root() to mark memory thread specific.
libmysqld/emb_qcache.cc:
Updated call to init_alloc_root()
libmysqld/lib_sql.cc:
Updated call to init_alloc_root()
mysql-test/r/create.result:
Updated results
mysql-test/r/user_var.result:
Updated results
mysql-test/suite/funcs_1/datadict/processlist_priv.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/is_columns_is.result:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result:
Updated results
mysql-test/suite/funcs_1/r/processlist_val_no_prot.result:
Updated results
mysql-test/t/show_explain.test:
Fixed usage of debug variable so that one can run test with --debug
mysql-test/t/user_var.test:
Added test of memory_usage variable.
mysys/array.c:
Added extra my_flags option to init_dynamic_array() and init_dynamic_array2() so that one can mark memory with MY_THREAD_SPECIFIC
All allocated memory is marked with the given my_flags.
Removed obsolete function init_dynamic_array()
mysys/default.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
mysys/hash.c:
Updated call to my_init_dynamic_array_ci().
Allocated memory is marked with MY_THREAD_SPECIFIC if HASH_THREAD_SPECIFIC is used.
mysys/ma_dyncol.c:
init_dynamic_array() -> my_init_dynamic_array()
Added #if to get rid of compiler warnings
mysys/mf_tempdir.c:
Updated call to my_init_dynamic_array()
mysys/my_alloc.c:
Added extra parameter to init_alloc_root() so that one can mark memory with MY_THREAD_SPECIFIC
Extend MEM_ROOT with a flag if memory is thread specific.
This is stored in block_size, to keep the size of the MEM_ROOT object identical as before.
Allocated memory is marked with MY_THREAD_SPECIFIC if used with init_alloc_root()
mysys/my_chmod.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_chsize.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_copy.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_create.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_delete.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_error.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fopen.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fstream.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_getwd.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_lib.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Updated DBUG_PRINT because of change of myf type
mysys/my_lock.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_malloc.c:
Store at start of each allocated memory block the size of the block and if the block is thread specific.
Call malloc_size_cb_func, if set, with the memory allocated/freed.
Updated DBUG_PRINT because of change of myf type
mysys/my_open.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_pread.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_read.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_redel.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_rename.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_seek.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_sync.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_thr_init.c:
Ensure that one can call my_thread_dbug_id() even if thread is not properly initialized.
mysys/my_write.c:
Updated DBUG_PRINT because of change of myf type
mysys/mysys_priv.h:
Updated parameters to sf_malloc and sf_realloc()
mysys/safemalloc.c:
Added checking that for memory marked with MY_THREAD_SPECIFIC that it's the same thread that is allocation and freeing the memory.
Added sf_malloc_dbug_id() to allow MariaDB to specify which THD is handling the memory.
Added my_flags arguments to sf_malloc() and sf_realloc() to be able to mark memory with MY_THREAD_SPECIFIC.
Added sf_report_leaked_memory() to get list of memory not freed by a thread.
mysys/tree.c:
Added flags to init_tree() so that one can mark tree to be thread specific.
Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
Updated call to init_alloc_root()
All allocated memory is marked with the given malloc flags
mysys/waiting_threads.c:
Updated call to my_init_dynamic_array()
sql-common/client.c:
Updated call to init_alloc_root() and my_net_init() to mark memory thread specific.
Updated call to my_init_dynamic_array().
Added MYSQL_THREAD_SPECIFIC_MALLOC so that client can mark memory as MY_THREAD_SPECIFIC.
sql-common/client_plugin.c:
Updated call to init_alloc_root()
sql/debug_sync.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/event_scheduler.cc:
Removed calls to net_end() as this is now done in ~THD()
Call set_current_thd() to ensure that memory is assigned to right thread.
sql/events.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/filesort.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/filesort_utils.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/ha_ndbcluster.cc:
Updated call to init_alloc_root()
Updated call to my_net_init()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_ndbcluster_binlog.cc:
Updated call to my_net_init()
Updated call to init_sql_alloc()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_partition.cc:
Updated call to init_alloc_root()
sql/handler.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
Added missing call to my_dir_end()
sql/item_func.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_subselect.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_sum.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/log.cc:
More DBUG
Updated call to init_alloc_root()
sql/mdl.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/mysqld.cc:
Added total_memory_used
Updated call to init_alloc_root()
Move mysql_cond_broadcast() before my_thread_end()
Added mariadb_dbug_id() to count memory per THD instead of per thread.
Added my_malloc_size_cb_func() callback function for my_malloc() to count memory.
Move initialization of mysqld_server_started and mysqld_server_initialized earlier.
Updated call to my_init_dynamic_array().
Updated call to my_net_init().
Call my_pthread_setspecific_ptr(THR_THD,...) to ensure that memory is assigned to right thread.
Added status variable 'memory_used'.
Updated call to init_alloc_root()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/mysqld.h:
Added set_current_thd()
sql/net_serv.cc:
Added new parameter to my_net_init() so that one can mark memory with MY_THREAD_SPECIFIC.
Store in net->thread_specific_malloc if memory is thread specific.
Mark memory to be thread specific if requested.
sql/opt_range.cc:
Updated call to my_init_dynamic_array()
Updated call to init_sql_alloc()
Added MY_THREAD_SPECIFIC to allocated memory.
sql/opt_subselect.cc:
Updated call to init_sql_alloc() to mark memory thread specific.
sql/protocol.cc:
Fixed compiler warning
sql/records.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/rpl_filter.cc:
Updated call to my_init_dynamic_array()
sql/rpl_handler.cc:
Updated call to my_init_dynamic_array2()
sql/rpl_handler.h:
Updated call to init_sql_alloc()
sql/rpl_mi.cc:
Updated call to my_init_dynamic_array()
sql/rpl_tblmap.cc:
Updated call to init_alloc_root()
sql/rpl_utility.cc:
Updated call to my_init_dynamic_array()
sql/slave.cc:
Initialize things properly before calling functions that allocate memory.
Removed calls to net_end() as this is now done in ~THD()
sql/sp_head.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
Added parameter to warning_info() that it should be fully initialized.
sql/sp_pcontext.cc:
Updated call to my_init_dynamic_array()
sql/sql_acl.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_admin.cc:
Added parameter to warning_info() that it should be fully initialized.
sql/sql_analyse.h:
Updated call to init_tree() to mark memory thread specific.
sql/sql_array.h:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_audit.cc:
Updated call to my_init_dynamic_array()
sql/sql_base.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_cache.cc:
Updated comment
sql/sql_class.cc:
Added parameter to warning_info() that not initialize it until THD is fully created.
Updated call to init_sql_alloc()
Mark THD::user_vars has to be thread specific.
Updated call to my_init_dynamic_array()
Ensure that memory allocated by THD is assigned to the THD.
More DBUG
Always acll net_end() in ~THD()
Assert that all memory signed to this THD is really deleted at ~THD.
Fixed set_status_var_init() to not reset memory_used.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_class.h:
Added MY_THREAD_SPECIFIC to allocated memory.
Added malloc_size to THD to record allocated memory per THD.
sql/sql_delete.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_error.cc:
Added 'initialize' parameter to Warning_info() to say if should allocate memory for it's structures.
This is used by THD::THD() to not allocate memory until THD is ready.
Added Warning_info::free_memory()
sql/sql_error.h:
Updated Warning_info() class.
sql/sql_handler.cc:
Updated call to init_alloc_root() to mark memory thread specific.
sql/sql_insert.cc:
More DBUG
sql/sql_join_cache.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_lex.cc:
Updated call to my_init_dynamic_array()
sql/sql_lex.h:
Updated call to my_init_dynamic_array()
sql/sql_load.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_parse.cc:
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
Ensure that examined_row_count() is reset before query.
Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Don't restore thd->status_var.memory_used when restoring thd->status_var
sql/sql_plugin.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Don't allocate THD on the stack, as this causes problems with valgrind when doing thd memory counting.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_prepare.cc:
Added parameter to warning_info() that it should be fully initialized.
Updated call to init_sql_alloc() to mark memory thread specific.
sql/sql_reload.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_select.cc:
Updated call to my_init_dynamic_array() and init_sql_alloc() to mark memory thread specific.
Added MY_THREAD_SPECIFIC to allocated memory.
More DBUG
sql/sql_servers.cc:
Updated call to init_sql_alloc() to mark memory some memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_show.cc:
Updated call to my_init_dynamic_array()
Mark my_dir() memory thread specific.
Use my_pthread_setspecific_ptr(THR_THD,...) to mark that allocated memory should be allocated to calling thread.
More DBUG.
Added malloc_size and examined_row_count to SHOW PROCESSLIST.
Added MY_THREAD_SPECIFIC to allocated memory.
Updated call to init_sql_alloc()
Added parameter to warning_info() that it should be fully initialized.
sql/sql_statistics.cc:
Fixed compiler warning
sql/sql_string.cc:
String elements can now be marked as thread specific.
sql/sql_string.h:
String elements can now be marked as thread specific.
sql/sql_table.cc:
Updated call to init_sql_alloc() and my_malloc() to mark memory thread specific
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Fixed compiler warning
sql/sql_test.cc:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_trigger.cc:
Updated call to init_sql_alloc()
sql/sql_udf.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_update.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/table.cc:
Updated call to init_sql_alloc().
Mark memory used by temporary tables, that are not for slave threads, as MY_THREAD_SPECIFIC
Updated call to init_sql_alloc()
sql/thr_malloc.cc:
Added my_flags argument to init_sql_alloc() to be able to mark memory as MY_THREAD_SPECIFIC.
sql/thr_malloc.h:
Updated prototype for init_sql_alloc()
sql/tztime.cc:
Updated call to init_sql_alloc()
Updated call to init_alloc_root() to mark memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/uniques.cc:
Updated calls to init_tree(), my_init_dynamic_array() and my_malloc() to mark memory thread specific.
sql/unireg.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/csv/ha_tina.cc:
Updated call to init_alloc_root()
storage/federated/ha_federated.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Ensure that memory allocated by fedarated is registered for the system, not for the thread.
storage/federatedx/federatedx_io_mysql.cc:
Updated call to my_init_dynamic_array()
storage/federatedx/ha_federatedx.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
storage/heap/ha_heap.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/heap/heapdef.h:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_block.c:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_create.c:
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Use MY_TREE_WITH_DELETE instead of removed option 'with_delete'.
storage/heap/hp_open.c:
Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
storage/heap/hp_write.c:
Added new parameter to hp_get_new_block()
storage/maria/ma_bitmap.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_blockrec.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_check.c:
Updated call to init_alloc_root()
storage/maria/ma_ft_boolean_search.c:
Updated calls to init_tree() and init_alloc_root()
storage/maria/ma_ft_nlq_search.c:
Updated call to init_tree()
storage/maria/ma_ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/maria/ma_loghandler.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_open.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_sort.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_write.c:
Updated calls to my_init_dynamic_array() and init_tree()
storage/maria/maria_pack.c:
Updated call to init_tree()
storage/maria/unittest/sequence_storage.c:
Updated call to my_init_dynamic_array()
storage/myisam/ft_boolean_search.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_nlq_search.c:
Updated call to init_tree()
storage/myisam/ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_stopwords.c:
Updated call to init_tree()
storage/myisam/mi_check.c:
Updated call to init_alloc_root()
storage/myisam/mi_write.c:
Updated call to my_init_dynamic_array()
Updated call to init_tree()
storage/myisam/myisamlog.c:
Updated call to init_tree()
storage/myisam/myisampack.c:
Updated call to init_tree()
storage/myisam/sort.c:
Updated call to my_init_dynamic_array()
storage/myisammrg/ha_myisammrg.cc:
Updated call to init_sql_alloc()
storage/perfschema/pfs_check.cc:
Rest current_thd
storage/perfschema/pfs_instr.cc:
Removed DBUG_ENTER/DBUG_VOID_RETURN as at this point my_thread_var is not allocated anymore, which can cause problems.
support-files/compiler_warnings.supp:
Disable compiler warning from offsetof macro.
2013-01-23 16:16:14 +01:00
|
|
|
THD *orig_thd= current_thd;
|
2006-07-13 16:24:55 +02:00
|
|
|
DBUG_ENTER("pre_init_event_thread");
|
MDEV-4011 Added per thread memory counting and usage
Base code and idea from a patch from by plinux at Taobao.
The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC.
Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc().
There are plenty of new asserts to ensure that for a debug server the counting is correct.
Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS.
- The later is there mainly to show how query is progressing.
The following changes in interfaces was needed to get this to work:
- init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root()
- my_init_dynamic_array() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- Added flag for hash_init() so that one can mark hash table to be thread specific.
- Added flags to init_tree() so that one can mark tree to be thread specific.
- Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
- Added flag to Warning_info::Warning_info() if the structure should be fully initialized.
- String elements can now be marked as thread specific.
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Changed type of myf from int to ulong, as this is always a set of bit flags.
Other things:
- Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
- We now also show EXAMINED_ROWS in SHOW PROCESSLIST
- Added new variable 'memory_used'
- Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
- Removed calls to the obsoleted function init_dynamic_array()
- Use set_current_thd() instead of my_pthread_setspecific_ptr(THR_THD,...)
client/completion_hash.cc:
Updated call to init_alloc_root()
client/mysql.cc:
Updated call to init_alloc_root()
client/mysqlbinlog.cc:
init_dynamic_array() -> my_init_dynamic_array()
Updated call to init_alloc_root()
client/mysqlcheck.c:
Updated call to my_init_dynamic_array()
client/mysqldump.c:
Updated call to init_alloc_root()
client/mysqltest.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Fixed compiler warnings
extra/comp_err.c:
Updated call to my_init_dynamic_array()
extra/resolve_stack_dump.c:
Updated call to my_init_dynamic_array()
include/hash.h:
Added HASH_THREAD_SPECIFIC
include/heap.h:
Added flag is internal temporary table.
include/my_dir.h:
Safety fix: Ensure that MY_DONT_SORT and MY_WANT_STAT don't interfer with other mysys flags
include/my_global.h:
Changed type of myf from int to ulong, as this is always a set of bit flags.
include/my_sys.h:
Added MY_THREAD_SPECIFIC and MY_THREAD_MOVE
Added malloc_flags to DYNAMIC_ARRAY
Added extra mysys flag argument to my_init_dynamic_array()
Removed deprecated functions init_dynamic_array() and my_init_dynamic_array.._ci
Updated paramaters for init_alloc_root()
include/my_tree.h:
Added my_flags to allow one to use MY_THREAD_SPECIFIC with hash tables.
Removed with_delete. One should now instead use MY_TREE_WITH_DELETE_FLAG
Updated parameters to init_tree()
include/myisamchk.h:
Added malloc_flags to allow one to use MY_THREAD_SPECIFIC for checks.
include/mysql.h:
Added MYSQL_THREAD_SPECIFIC_MALLOC
Used 'unused1' to mark memory as thread specific.
include/mysql.h.pp:
Updated file
include/mysql_com.h:
Used 'unused1' to mark memory as thread specific.
Updated parameters for my_net_init()
libmysql/libmysql.c:
Updated call to init_alloc_root() to mark memory thread specific.
libmysqld/emb_qcache.cc:
Updated call to init_alloc_root()
libmysqld/lib_sql.cc:
Updated call to init_alloc_root()
mysql-test/r/create.result:
Updated results
mysql-test/r/user_var.result:
Updated results
mysql-test/suite/funcs_1/datadict/processlist_priv.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/is_columns_is.result:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result:
Updated results
mysql-test/suite/funcs_1/r/processlist_val_no_prot.result:
Updated results
mysql-test/t/show_explain.test:
Fixed usage of debug variable so that one can run test with --debug
mysql-test/t/user_var.test:
Added test of memory_usage variable.
mysys/array.c:
Added extra my_flags option to init_dynamic_array() and init_dynamic_array2() so that one can mark memory with MY_THREAD_SPECIFIC
All allocated memory is marked with the given my_flags.
Removed obsolete function init_dynamic_array()
mysys/default.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
mysys/hash.c:
Updated call to my_init_dynamic_array_ci().
Allocated memory is marked with MY_THREAD_SPECIFIC if HASH_THREAD_SPECIFIC is used.
mysys/ma_dyncol.c:
init_dynamic_array() -> my_init_dynamic_array()
Added #if to get rid of compiler warnings
mysys/mf_tempdir.c:
Updated call to my_init_dynamic_array()
mysys/my_alloc.c:
Added extra parameter to init_alloc_root() so that one can mark memory with MY_THREAD_SPECIFIC
Extend MEM_ROOT with a flag if memory is thread specific.
This is stored in block_size, to keep the size of the MEM_ROOT object identical as before.
Allocated memory is marked with MY_THREAD_SPECIFIC if used with init_alloc_root()
mysys/my_chmod.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_chsize.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_copy.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_create.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_delete.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_error.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fopen.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fstream.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_getwd.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_lib.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Updated DBUG_PRINT because of change of myf type
mysys/my_lock.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_malloc.c:
Store at start of each allocated memory block the size of the block and if the block is thread specific.
Call malloc_size_cb_func, if set, with the memory allocated/freed.
Updated DBUG_PRINT because of change of myf type
mysys/my_open.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_pread.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_read.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_redel.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_rename.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_seek.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_sync.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_thr_init.c:
Ensure that one can call my_thread_dbug_id() even if thread is not properly initialized.
mysys/my_write.c:
Updated DBUG_PRINT because of change of myf type
mysys/mysys_priv.h:
Updated parameters to sf_malloc and sf_realloc()
mysys/safemalloc.c:
Added checking that for memory marked with MY_THREAD_SPECIFIC that it's the same thread that is allocation and freeing the memory.
Added sf_malloc_dbug_id() to allow MariaDB to specify which THD is handling the memory.
Added my_flags arguments to sf_malloc() and sf_realloc() to be able to mark memory with MY_THREAD_SPECIFIC.
Added sf_report_leaked_memory() to get list of memory not freed by a thread.
mysys/tree.c:
Added flags to init_tree() so that one can mark tree to be thread specific.
Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
Updated call to init_alloc_root()
All allocated memory is marked with the given malloc flags
mysys/waiting_threads.c:
Updated call to my_init_dynamic_array()
sql-common/client.c:
Updated call to init_alloc_root() and my_net_init() to mark memory thread specific.
Updated call to my_init_dynamic_array().
Added MYSQL_THREAD_SPECIFIC_MALLOC so that client can mark memory as MY_THREAD_SPECIFIC.
sql-common/client_plugin.c:
Updated call to init_alloc_root()
sql/debug_sync.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/event_scheduler.cc:
Removed calls to net_end() as this is now done in ~THD()
Call set_current_thd() to ensure that memory is assigned to right thread.
sql/events.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/filesort.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/filesort_utils.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/ha_ndbcluster.cc:
Updated call to init_alloc_root()
Updated call to my_net_init()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_ndbcluster_binlog.cc:
Updated call to my_net_init()
Updated call to init_sql_alloc()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_partition.cc:
Updated call to init_alloc_root()
sql/handler.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
Added missing call to my_dir_end()
sql/item_func.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_subselect.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_sum.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/log.cc:
More DBUG
Updated call to init_alloc_root()
sql/mdl.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/mysqld.cc:
Added total_memory_used
Updated call to init_alloc_root()
Move mysql_cond_broadcast() before my_thread_end()
Added mariadb_dbug_id() to count memory per THD instead of per thread.
Added my_malloc_size_cb_func() callback function for my_malloc() to count memory.
Move initialization of mysqld_server_started and mysqld_server_initialized earlier.
Updated call to my_init_dynamic_array().
Updated call to my_net_init().
Call my_pthread_setspecific_ptr(THR_THD,...) to ensure that memory is assigned to right thread.
Added status variable 'memory_used'.
Updated call to init_alloc_root()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/mysqld.h:
Added set_current_thd()
sql/net_serv.cc:
Added new parameter to my_net_init() so that one can mark memory with MY_THREAD_SPECIFIC.
Store in net->thread_specific_malloc if memory is thread specific.
Mark memory to be thread specific if requested.
sql/opt_range.cc:
Updated call to my_init_dynamic_array()
Updated call to init_sql_alloc()
Added MY_THREAD_SPECIFIC to allocated memory.
sql/opt_subselect.cc:
Updated call to init_sql_alloc() to mark memory thread specific.
sql/protocol.cc:
Fixed compiler warning
sql/records.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/rpl_filter.cc:
Updated call to my_init_dynamic_array()
sql/rpl_handler.cc:
Updated call to my_init_dynamic_array2()
sql/rpl_handler.h:
Updated call to init_sql_alloc()
sql/rpl_mi.cc:
Updated call to my_init_dynamic_array()
sql/rpl_tblmap.cc:
Updated call to init_alloc_root()
sql/rpl_utility.cc:
Updated call to my_init_dynamic_array()
sql/slave.cc:
Initialize things properly before calling functions that allocate memory.
Removed calls to net_end() as this is now done in ~THD()
sql/sp_head.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
Added parameter to warning_info() that it should be fully initialized.
sql/sp_pcontext.cc:
Updated call to my_init_dynamic_array()
sql/sql_acl.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_admin.cc:
Added parameter to warning_info() that it should be fully initialized.
sql/sql_analyse.h:
Updated call to init_tree() to mark memory thread specific.
sql/sql_array.h:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_audit.cc:
Updated call to my_init_dynamic_array()
sql/sql_base.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_cache.cc:
Updated comment
sql/sql_class.cc:
Added parameter to warning_info() that not initialize it until THD is fully created.
Updated call to init_sql_alloc()
Mark THD::user_vars has to be thread specific.
Updated call to my_init_dynamic_array()
Ensure that memory allocated by THD is assigned to the THD.
More DBUG
Always acll net_end() in ~THD()
Assert that all memory signed to this THD is really deleted at ~THD.
Fixed set_status_var_init() to not reset memory_used.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_class.h:
Added MY_THREAD_SPECIFIC to allocated memory.
Added malloc_size to THD to record allocated memory per THD.
sql/sql_delete.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_error.cc:
Added 'initialize' parameter to Warning_info() to say if should allocate memory for it's structures.
This is used by THD::THD() to not allocate memory until THD is ready.
Added Warning_info::free_memory()
sql/sql_error.h:
Updated Warning_info() class.
sql/sql_handler.cc:
Updated call to init_alloc_root() to mark memory thread specific.
sql/sql_insert.cc:
More DBUG
sql/sql_join_cache.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_lex.cc:
Updated call to my_init_dynamic_array()
sql/sql_lex.h:
Updated call to my_init_dynamic_array()
sql/sql_load.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_parse.cc:
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
Ensure that examined_row_count() is reset before query.
Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Don't restore thd->status_var.memory_used when restoring thd->status_var
sql/sql_plugin.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Don't allocate THD on the stack, as this causes problems with valgrind when doing thd memory counting.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_prepare.cc:
Added parameter to warning_info() that it should be fully initialized.
Updated call to init_sql_alloc() to mark memory thread specific.
sql/sql_reload.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_select.cc:
Updated call to my_init_dynamic_array() and init_sql_alloc() to mark memory thread specific.
Added MY_THREAD_SPECIFIC to allocated memory.
More DBUG
sql/sql_servers.cc:
Updated call to init_sql_alloc() to mark memory some memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_show.cc:
Updated call to my_init_dynamic_array()
Mark my_dir() memory thread specific.
Use my_pthread_setspecific_ptr(THR_THD,...) to mark that allocated memory should be allocated to calling thread.
More DBUG.
Added malloc_size and examined_row_count to SHOW PROCESSLIST.
Added MY_THREAD_SPECIFIC to allocated memory.
Updated call to init_sql_alloc()
Added parameter to warning_info() that it should be fully initialized.
sql/sql_statistics.cc:
Fixed compiler warning
sql/sql_string.cc:
String elements can now be marked as thread specific.
sql/sql_string.h:
String elements can now be marked as thread specific.
sql/sql_table.cc:
Updated call to init_sql_alloc() and my_malloc() to mark memory thread specific
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Fixed compiler warning
sql/sql_test.cc:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_trigger.cc:
Updated call to init_sql_alloc()
sql/sql_udf.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_update.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/table.cc:
Updated call to init_sql_alloc().
Mark memory used by temporary tables, that are not for slave threads, as MY_THREAD_SPECIFIC
Updated call to init_sql_alloc()
sql/thr_malloc.cc:
Added my_flags argument to init_sql_alloc() to be able to mark memory as MY_THREAD_SPECIFIC.
sql/thr_malloc.h:
Updated prototype for init_sql_alloc()
sql/tztime.cc:
Updated call to init_sql_alloc()
Updated call to init_alloc_root() to mark memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/uniques.cc:
Updated calls to init_tree(), my_init_dynamic_array() and my_malloc() to mark memory thread specific.
sql/unireg.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/csv/ha_tina.cc:
Updated call to init_alloc_root()
storage/federated/ha_federated.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Ensure that memory allocated by fedarated is registered for the system, not for the thread.
storage/federatedx/federatedx_io_mysql.cc:
Updated call to my_init_dynamic_array()
storage/federatedx/ha_federatedx.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
storage/heap/ha_heap.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/heap/heapdef.h:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_block.c:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_create.c:
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Use MY_TREE_WITH_DELETE instead of removed option 'with_delete'.
storage/heap/hp_open.c:
Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
storage/heap/hp_write.c:
Added new parameter to hp_get_new_block()
storage/maria/ma_bitmap.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_blockrec.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_check.c:
Updated call to init_alloc_root()
storage/maria/ma_ft_boolean_search.c:
Updated calls to init_tree() and init_alloc_root()
storage/maria/ma_ft_nlq_search.c:
Updated call to init_tree()
storage/maria/ma_ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/maria/ma_loghandler.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_open.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_sort.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_write.c:
Updated calls to my_init_dynamic_array() and init_tree()
storage/maria/maria_pack.c:
Updated call to init_tree()
storage/maria/unittest/sequence_storage.c:
Updated call to my_init_dynamic_array()
storage/myisam/ft_boolean_search.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_nlq_search.c:
Updated call to init_tree()
storage/myisam/ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_stopwords.c:
Updated call to init_tree()
storage/myisam/mi_check.c:
Updated call to init_alloc_root()
storage/myisam/mi_write.c:
Updated call to my_init_dynamic_array()
Updated call to init_tree()
storage/myisam/myisamlog.c:
Updated call to init_tree()
storage/myisam/myisampack.c:
Updated call to init_tree()
storage/myisam/sort.c:
Updated call to my_init_dynamic_array()
storage/myisammrg/ha_myisammrg.cc:
Updated call to init_sql_alloc()
storage/perfschema/pfs_check.cc:
Rest current_thd
storage/perfschema/pfs_instr.cc:
Removed DBUG_ENTER/DBUG_VOID_RETURN as at this point my_thread_var is not allocated anymore, which can cause problems.
support-files/compiler_warnings.supp:
Disable compiler warning from offsetof macro.
2013-01-23 16:16:14 +01:00
|
|
|
|
|
|
|
set_current_thd(thd);
|
2006-07-13 16:24:55 +02:00
|
|
|
thd->client_capabilities= 0;
|
2020-02-09 18:53:11 +01:00
|
|
|
thd->security_ctx->master_access= NO_ACL;
|
|
|
|
thd->security_ctx->db_access= NO_ACL;
|
2006-07-13 16:24:55 +02:00
|
|
|
thd->security_ctx->host_or_ip= (char*)my_localhost;
|
2015-08-31 11:57:46 +02:00
|
|
|
my_net_init(&thd->net, NULL, thd, MYF(MY_THREAD_SPECIFIC));
|
2006-07-13 16:24:55 +02:00
|
|
|
thd->security_ctx->set_user((char*)"event_scheduler");
|
|
|
|
thd->net.read_timeout= slave_net_timeout;
|
2009-12-22 10:35:56 +01:00
|
|
|
thd->variables.option_bits|= OPTION_AUTO_IS_NULL;
|
2006-07-13 16:24:55 +02:00
|
|
|
thd->client_capabilities|= CLIENT_MULTI_RESULTS;
|
2019-01-19 23:32:35 +01:00
|
|
|
server_threads.insert(thd);
|
2006-07-13 16:24:55 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Guarantees that we will see the thread in SHOW PROCESSLIST though its
|
|
|
|
vio is NULL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
thd->proc_info= "Initialized";
|
|
|
|
thd->set_time();
|
|
|
|
|
2010-02-24 18:04:00 +01:00
|
|
|
/* Do not use user-supplied timeout value for system threads. */
|
|
|
|
thd->variables.lock_wait_timeout= LONG_TIMEOUT;
|
|
|
|
|
MDEV-4011 Added per thread memory counting and usage
Base code and idea from a patch from by plinux at Taobao.
The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC.
Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc().
There are plenty of new asserts to ensure that for a debug server the counting is correct.
Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS.
- The later is there mainly to show how query is progressing.
The following changes in interfaces was needed to get this to work:
- init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root()
- my_init_dynamic_array() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- Added flag for hash_init() so that one can mark hash table to be thread specific.
- Added flags to init_tree() so that one can mark tree to be thread specific.
- Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
- Added flag to Warning_info::Warning_info() if the structure should be fully initialized.
- String elements can now be marked as thread specific.
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Changed type of myf from int to ulong, as this is always a set of bit flags.
Other things:
- Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
- We now also show EXAMINED_ROWS in SHOW PROCESSLIST
- Added new variable 'memory_used'
- Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
- Removed calls to the obsoleted function init_dynamic_array()
- Use set_current_thd() instead of my_pthread_setspecific_ptr(THR_THD,...)
client/completion_hash.cc:
Updated call to init_alloc_root()
client/mysql.cc:
Updated call to init_alloc_root()
client/mysqlbinlog.cc:
init_dynamic_array() -> my_init_dynamic_array()
Updated call to init_alloc_root()
client/mysqlcheck.c:
Updated call to my_init_dynamic_array()
client/mysqldump.c:
Updated call to init_alloc_root()
client/mysqltest.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Fixed compiler warnings
extra/comp_err.c:
Updated call to my_init_dynamic_array()
extra/resolve_stack_dump.c:
Updated call to my_init_dynamic_array()
include/hash.h:
Added HASH_THREAD_SPECIFIC
include/heap.h:
Added flag is internal temporary table.
include/my_dir.h:
Safety fix: Ensure that MY_DONT_SORT and MY_WANT_STAT don't interfer with other mysys flags
include/my_global.h:
Changed type of myf from int to ulong, as this is always a set of bit flags.
include/my_sys.h:
Added MY_THREAD_SPECIFIC and MY_THREAD_MOVE
Added malloc_flags to DYNAMIC_ARRAY
Added extra mysys flag argument to my_init_dynamic_array()
Removed deprecated functions init_dynamic_array() and my_init_dynamic_array.._ci
Updated paramaters for init_alloc_root()
include/my_tree.h:
Added my_flags to allow one to use MY_THREAD_SPECIFIC with hash tables.
Removed with_delete. One should now instead use MY_TREE_WITH_DELETE_FLAG
Updated parameters to init_tree()
include/myisamchk.h:
Added malloc_flags to allow one to use MY_THREAD_SPECIFIC for checks.
include/mysql.h:
Added MYSQL_THREAD_SPECIFIC_MALLOC
Used 'unused1' to mark memory as thread specific.
include/mysql.h.pp:
Updated file
include/mysql_com.h:
Used 'unused1' to mark memory as thread specific.
Updated parameters for my_net_init()
libmysql/libmysql.c:
Updated call to init_alloc_root() to mark memory thread specific.
libmysqld/emb_qcache.cc:
Updated call to init_alloc_root()
libmysqld/lib_sql.cc:
Updated call to init_alloc_root()
mysql-test/r/create.result:
Updated results
mysql-test/r/user_var.result:
Updated results
mysql-test/suite/funcs_1/datadict/processlist_priv.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/is_columns_is.result:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result:
Updated results
mysql-test/suite/funcs_1/r/processlist_val_no_prot.result:
Updated results
mysql-test/t/show_explain.test:
Fixed usage of debug variable so that one can run test with --debug
mysql-test/t/user_var.test:
Added test of memory_usage variable.
mysys/array.c:
Added extra my_flags option to init_dynamic_array() and init_dynamic_array2() so that one can mark memory with MY_THREAD_SPECIFIC
All allocated memory is marked with the given my_flags.
Removed obsolete function init_dynamic_array()
mysys/default.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
mysys/hash.c:
Updated call to my_init_dynamic_array_ci().
Allocated memory is marked with MY_THREAD_SPECIFIC if HASH_THREAD_SPECIFIC is used.
mysys/ma_dyncol.c:
init_dynamic_array() -> my_init_dynamic_array()
Added #if to get rid of compiler warnings
mysys/mf_tempdir.c:
Updated call to my_init_dynamic_array()
mysys/my_alloc.c:
Added extra parameter to init_alloc_root() so that one can mark memory with MY_THREAD_SPECIFIC
Extend MEM_ROOT with a flag if memory is thread specific.
This is stored in block_size, to keep the size of the MEM_ROOT object identical as before.
Allocated memory is marked with MY_THREAD_SPECIFIC if used with init_alloc_root()
mysys/my_chmod.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_chsize.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_copy.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_create.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_delete.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_error.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fopen.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fstream.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_getwd.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_lib.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Updated DBUG_PRINT because of change of myf type
mysys/my_lock.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_malloc.c:
Store at start of each allocated memory block the size of the block and if the block is thread specific.
Call malloc_size_cb_func, if set, with the memory allocated/freed.
Updated DBUG_PRINT because of change of myf type
mysys/my_open.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_pread.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_read.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_redel.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_rename.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_seek.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_sync.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_thr_init.c:
Ensure that one can call my_thread_dbug_id() even if thread is not properly initialized.
mysys/my_write.c:
Updated DBUG_PRINT because of change of myf type
mysys/mysys_priv.h:
Updated parameters to sf_malloc and sf_realloc()
mysys/safemalloc.c:
Added checking that for memory marked with MY_THREAD_SPECIFIC that it's the same thread that is allocation and freeing the memory.
Added sf_malloc_dbug_id() to allow MariaDB to specify which THD is handling the memory.
Added my_flags arguments to sf_malloc() and sf_realloc() to be able to mark memory with MY_THREAD_SPECIFIC.
Added sf_report_leaked_memory() to get list of memory not freed by a thread.
mysys/tree.c:
Added flags to init_tree() so that one can mark tree to be thread specific.
Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
Updated call to init_alloc_root()
All allocated memory is marked with the given malloc flags
mysys/waiting_threads.c:
Updated call to my_init_dynamic_array()
sql-common/client.c:
Updated call to init_alloc_root() and my_net_init() to mark memory thread specific.
Updated call to my_init_dynamic_array().
Added MYSQL_THREAD_SPECIFIC_MALLOC so that client can mark memory as MY_THREAD_SPECIFIC.
sql-common/client_plugin.c:
Updated call to init_alloc_root()
sql/debug_sync.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/event_scheduler.cc:
Removed calls to net_end() as this is now done in ~THD()
Call set_current_thd() to ensure that memory is assigned to right thread.
sql/events.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/filesort.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/filesort_utils.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/ha_ndbcluster.cc:
Updated call to init_alloc_root()
Updated call to my_net_init()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_ndbcluster_binlog.cc:
Updated call to my_net_init()
Updated call to init_sql_alloc()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_partition.cc:
Updated call to init_alloc_root()
sql/handler.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
Added missing call to my_dir_end()
sql/item_func.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_subselect.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_sum.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/log.cc:
More DBUG
Updated call to init_alloc_root()
sql/mdl.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/mysqld.cc:
Added total_memory_used
Updated call to init_alloc_root()
Move mysql_cond_broadcast() before my_thread_end()
Added mariadb_dbug_id() to count memory per THD instead of per thread.
Added my_malloc_size_cb_func() callback function for my_malloc() to count memory.
Move initialization of mysqld_server_started and mysqld_server_initialized earlier.
Updated call to my_init_dynamic_array().
Updated call to my_net_init().
Call my_pthread_setspecific_ptr(THR_THD,...) to ensure that memory is assigned to right thread.
Added status variable 'memory_used'.
Updated call to init_alloc_root()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/mysqld.h:
Added set_current_thd()
sql/net_serv.cc:
Added new parameter to my_net_init() so that one can mark memory with MY_THREAD_SPECIFIC.
Store in net->thread_specific_malloc if memory is thread specific.
Mark memory to be thread specific if requested.
sql/opt_range.cc:
Updated call to my_init_dynamic_array()
Updated call to init_sql_alloc()
Added MY_THREAD_SPECIFIC to allocated memory.
sql/opt_subselect.cc:
Updated call to init_sql_alloc() to mark memory thread specific.
sql/protocol.cc:
Fixed compiler warning
sql/records.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/rpl_filter.cc:
Updated call to my_init_dynamic_array()
sql/rpl_handler.cc:
Updated call to my_init_dynamic_array2()
sql/rpl_handler.h:
Updated call to init_sql_alloc()
sql/rpl_mi.cc:
Updated call to my_init_dynamic_array()
sql/rpl_tblmap.cc:
Updated call to init_alloc_root()
sql/rpl_utility.cc:
Updated call to my_init_dynamic_array()
sql/slave.cc:
Initialize things properly before calling functions that allocate memory.
Removed calls to net_end() as this is now done in ~THD()
sql/sp_head.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
Added parameter to warning_info() that it should be fully initialized.
sql/sp_pcontext.cc:
Updated call to my_init_dynamic_array()
sql/sql_acl.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_admin.cc:
Added parameter to warning_info() that it should be fully initialized.
sql/sql_analyse.h:
Updated call to init_tree() to mark memory thread specific.
sql/sql_array.h:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_audit.cc:
Updated call to my_init_dynamic_array()
sql/sql_base.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_cache.cc:
Updated comment
sql/sql_class.cc:
Added parameter to warning_info() that not initialize it until THD is fully created.
Updated call to init_sql_alloc()
Mark THD::user_vars has to be thread specific.
Updated call to my_init_dynamic_array()
Ensure that memory allocated by THD is assigned to the THD.
More DBUG
Always acll net_end() in ~THD()
Assert that all memory signed to this THD is really deleted at ~THD.
Fixed set_status_var_init() to not reset memory_used.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_class.h:
Added MY_THREAD_SPECIFIC to allocated memory.
Added malloc_size to THD to record allocated memory per THD.
sql/sql_delete.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_error.cc:
Added 'initialize' parameter to Warning_info() to say if should allocate memory for it's structures.
This is used by THD::THD() to not allocate memory until THD is ready.
Added Warning_info::free_memory()
sql/sql_error.h:
Updated Warning_info() class.
sql/sql_handler.cc:
Updated call to init_alloc_root() to mark memory thread specific.
sql/sql_insert.cc:
More DBUG
sql/sql_join_cache.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_lex.cc:
Updated call to my_init_dynamic_array()
sql/sql_lex.h:
Updated call to my_init_dynamic_array()
sql/sql_load.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_parse.cc:
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
Ensure that examined_row_count() is reset before query.
Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Don't restore thd->status_var.memory_used when restoring thd->status_var
sql/sql_plugin.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Don't allocate THD on the stack, as this causes problems with valgrind when doing thd memory counting.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_prepare.cc:
Added parameter to warning_info() that it should be fully initialized.
Updated call to init_sql_alloc() to mark memory thread specific.
sql/sql_reload.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_select.cc:
Updated call to my_init_dynamic_array() and init_sql_alloc() to mark memory thread specific.
Added MY_THREAD_SPECIFIC to allocated memory.
More DBUG
sql/sql_servers.cc:
Updated call to init_sql_alloc() to mark memory some memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_show.cc:
Updated call to my_init_dynamic_array()
Mark my_dir() memory thread specific.
Use my_pthread_setspecific_ptr(THR_THD,...) to mark that allocated memory should be allocated to calling thread.
More DBUG.
Added malloc_size and examined_row_count to SHOW PROCESSLIST.
Added MY_THREAD_SPECIFIC to allocated memory.
Updated call to init_sql_alloc()
Added parameter to warning_info() that it should be fully initialized.
sql/sql_statistics.cc:
Fixed compiler warning
sql/sql_string.cc:
String elements can now be marked as thread specific.
sql/sql_string.h:
String elements can now be marked as thread specific.
sql/sql_table.cc:
Updated call to init_sql_alloc() and my_malloc() to mark memory thread specific
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Fixed compiler warning
sql/sql_test.cc:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_trigger.cc:
Updated call to init_sql_alloc()
sql/sql_udf.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_update.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/table.cc:
Updated call to init_sql_alloc().
Mark memory used by temporary tables, that are not for slave threads, as MY_THREAD_SPECIFIC
Updated call to init_sql_alloc()
sql/thr_malloc.cc:
Added my_flags argument to init_sql_alloc() to be able to mark memory as MY_THREAD_SPECIFIC.
sql/thr_malloc.h:
Updated prototype for init_sql_alloc()
sql/tztime.cc:
Updated call to init_sql_alloc()
Updated call to init_alloc_root() to mark memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/uniques.cc:
Updated calls to init_tree(), my_init_dynamic_array() and my_malloc() to mark memory thread specific.
sql/unireg.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/csv/ha_tina.cc:
Updated call to init_alloc_root()
storage/federated/ha_federated.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Ensure that memory allocated by fedarated is registered for the system, not for the thread.
storage/federatedx/federatedx_io_mysql.cc:
Updated call to my_init_dynamic_array()
storage/federatedx/ha_federatedx.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
storage/heap/ha_heap.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/heap/heapdef.h:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_block.c:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_create.c:
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Use MY_TREE_WITH_DELETE instead of removed option 'with_delete'.
storage/heap/hp_open.c:
Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
storage/heap/hp_write.c:
Added new parameter to hp_get_new_block()
storage/maria/ma_bitmap.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_blockrec.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_check.c:
Updated call to init_alloc_root()
storage/maria/ma_ft_boolean_search.c:
Updated calls to init_tree() and init_alloc_root()
storage/maria/ma_ft_nlq_search.c:
Updated call to init_tree()
storage/maria/ma_ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/maria/ma_loghandler.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_open.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_sort.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_write.c:
Updated calls to my_init_dynamic_array() and init_tree()
storage/maria/maria_pack.c:
Updated call to init_tree()
storage/maria/unittest/sequence_storage.c:
Updated call to my_init_dynamic_array()
storage/myisam/ft_boolean_search.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_nlq_search.c:
Updated call to init_tree()
storage/myisam/ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_stopwords.c:
Updated call to init_tree()
storage/myisam/mi_check.c:
Updated call to init_alloc_root()
storage/myisam/mi_write.c:
Updated call to my_init_dynamic_array()
Updated call to init_tree()
storage/myisam/myisamlog.c:
Updated call to init_tree()
storage/myisam/myisampack.c:
Updated call to init_tree()
storage/myisam/sort.c:
Updated call to my_init_dynamic_array()
storage/myisammrg/ha_myisammrg.cc:
Updated call to init_sql_alloc()
storage/perfschema/pfs_check.cc:
Rest current_thd
storage/perfschema/pfs_instr.cc:
Removed DBUG_ENTER/DBUG_VOID_RETURN as at this point my_thread_var is not allocated anymore, which can cause problems.
support-files/compiler_warnings.supp:
Disable compiler warning from offsetof macro.
2013-01-23 16:16:14 +01:00
|
|
|
set_current_thd(orig_thd);
|
2006-07-13 16:24:55 +02:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-12 10:37:30 +02:00
|
|
|
/*
|
|
|
|
Function that executes the scheduler,
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
event_scheduler_thread()
|
|
|
|
arg Pointer to `struct scheduler_param`
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
0 OK
|
|
|
|
*/
|
|
|
|
|
|
|
|
pthread_handler_t
|
|
|
|
event_scheduler_thread(void *arg)
|
|
|
|
{
|
|
|
|
/* needs to be first for thread_stack */
|
2007-03-01 21:47:28 +01:00
|
|
|
THD *thd= (THD *) ((struct scheduler_param *) arg)->thd;
|
2006-07-13 10:59:58 +02:00
|
|
|
Event_scheduler *scheduler= ((struct scheduler_param *) arg)->scheduler;
|
2007-03-01 21:47:28 +01:00
|
|
|
bool res;
|
2006-07-12 10:37:30 +02:00
|
|
|
|
2006-07-13 10:59:58 +02:00
|
|
|
thd->thread_stack= (char *)&thd; // remember where our stack is
|
2010-01-07 06:42:07 +01:00
|
|
|
|
|
|
|
mysql_thread_set_psi_id(thd->thread_id);
|
|
|
|
|
2007-03-01 21:47:28 +01:00
|
|
|
res= post_init_event_thread(thd);
|
2006-07-12 10:37:30 +02:00
|
|
|
|
2006-07-13 10:59:58 +02:00
|
|
|
DBUG_ENTER("event_scheduler_thread");
|
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
client/mysqldump.c:
Pass my_free directly as its signature is compatible with the
callback type -- which wasn't the case for free_table_ent.
2010-07-08 23:20:08 +02:00
|
|
|
my_free(arg);
|
2007-03-01 21:47:28 +01:00
|
|
|
if (!res)
|
2006-07-13 10:59:58 +02:00
|
|
|
scheduler->run(thd);
|
2006-07-12 10:37:30 +02:00
|
|
|
|
2017-02-28 12:23:44 +01:00
|
|
|
deinit_event_thread(thd);
|
2010-02-02 13:17:21 +01:00
|
|
|
DBUG_LEAVE; // Against gcc warnings
|
2007-04-06 17:44:14 +02:00
|
|
|
my_thread_end();
|
2010-02-02 13:17:21 +01:00
|
|
|
return 0;
|
2006-07-12 10:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
A set of changes aiming to make the Event Scheduler more user-friendly
when there are no up-to-date system tables to support it:
- initialize the scheduler before reporting "Ready for connections".
This ensures that warnings, if any, are printed before "Ready for
connections", and this message is not mangled.
- do not abort the scheduler if there are no system tables
- check the tables once at start up, remember the status and disable
the scheduler if the tables are not up to date.
If one attempts to use the scheduler with bad tables,
issue an error message.
- clean up the behaviour of the module under LOCK TABLES and pre-locking
mode
- make sure implicit commit of Events DDL works as expected.
- add more tests
Collateral clean ups in the events code.
This patch fixes Bug#23631 Events: SHOW VARIABLES doesn't work
when mysql.event is damaged
mysql-test/r/events.result:
Update results.
mysql-test/r/events_bugs.result:
Update results.
mysql-test/r/events_restart_phase1.result:
Update results.
mysql-test/r/events_restart_phase2.result:
Update results.
mysql-test/r/events_restart_phase3.result:
Update results.
mysql-test/r/events_scheduling.result:
Update results.
mysql-test/r/events_time_zone.result:
Update results.
mysql-test/t/events.test:
Add new tests for tampering with mysql.event and some more
tests for sub-statements, LOCK TABLES mode and pre-locking.
mysql-test/t/events_bugs.test:
Move the non-concurrent part of test for Bug 16420 to this file.
mysql-test/t/events_restart_phase1.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase2.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase3.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_scheduling.test:
Add more coverage for event_scheduler global variable.
mysql-test/t/events_time_zone.test:
Move the non-concurrent part of the tests for Bug 16420 to
events_bugs.test
sql/event_data_objects.cc:
Move update_timing_fields functionality to Event_db_repository.
Make loading of events from a table record more robust to tampering
with the table - now we do not check mysql.event on every table open.
sql/event_data_objects.h:
Cleanup.
sql/event_db_repository.cc:
Now Event_db_repository is responsible for table I/O only.
All the logic of events DDL is handled outside, in Events class please
refer to the added test coverage to see how this change affected
the behavior of Event Scheduler.
Dependency on sp_head.h and sp.h removed.
Make this module robust to tweaks with mysql.event table.
Move check_system_tables from events.cc to this file
sql/event_db_repository.h:
Cleanup declarations (remove unused ones, change return type to bool
from int).
sql/event_queue.cc:
Update to adapt to the new start up scheme of the Event Scheduler.
sql/event_queue.h:
Cleanup declarations.
sql/event_scheduler.cc:
Make all the error messages uniform:
[SEVERITY] Event Scheduler: [user][schema.event] message
Using append_identifier for error logging was an overkill - we may
need it only if the system character set may have NUL (null character)
as part of a valid identifier, this is currently never the case,
whereas additional quoting did not look nice in the log.
sql/event_scheduler.h:
Cleanup the headers.
sql/events.cc:
Use a different start up procedure of Event Scheduler:
- at start up, try to check the system tables first.
If they are not up-to-date, disable the scheduler.
- try to load all the active events. In case of a load error, abort
start up.
- do not parse an event on start up. Parsing only gives some information
about event validity, but far not all.
Consolidate the business logic of Events DDL in this module.
Now opt_event_scheduler may change after start up and thus is protected
by LOCK_event_metadata mutex.
sql/events.h:
Use all-static-data-members approach to implement Singleton pattern.
sql/mysqld.cc:
New invocation scheme of Events. Move some logic to events.cc.
Initialize the scheduler before reporting "Ready for connections".
sql/set_var.cc:
Clean up sys_var_thd_sql_mode::symbolic_mode_representation
to work with a LEX_STRING.
Move more logic related to @@events_scheduler global variable to Events
module.
sql/set_var.h:
Update declarations.
sql/share/errmsg.txt:
If someone tampered with mysql.event table after the server has
started we no longer give him/her a complete report what was actually
broken. Do not send the user to look at the error log in such case,
as there is nothing there (check_table_intact is not executed).
sql/sp_head.cc:
Update to a new declaration of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_db.cc:
New invocation scheme of Events module.
sql/sql_parse.cc:
Move more logic to Events module. Make sure that we are consistent
in the way access rights are checked for Events DDL: always
after committing the current transaction and checking the system tables.
sql/sql_show.cc:
Update to the new declarations of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_test.cc:
New invocation scheme of events.
sql/table.cc:
mysql.event is a system table.
Update check_table_intact to be concurrent, more verbose, and less smart.
sql/table.h:
Add a helper method.
mysql-test/r/events_trans.result:
New BitKeeper file ``mysql-test/r/events_trans.result''
mysql-test/t/events_trans.test:
New BitKeeper file ``mysql-test/t/events_trans.test'':
test cases for Event Scheduler that require a transactional
storage engine.
2007-04-05 13:24:34 +02:00
|
|
|
/**
|
2007-03-23 16:14:03 +01:00
|
|
|
Function that executes an event in a child thread. Setups the
|
2006-07-12 10:37:30 +02:00
|
|
|
environment for the event execution and cleans after that.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
event_worker_thread()
|
|
|
|
arg The Event_job_data object to be processed
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
0 OK
|
|
|
|
*/
|
|
|
|
|
|
|
|
pthread_handler_t
|
|
|
|
event_worker_thread(void *arg)
|
|
|
|
{
|
2007-03-23 16:14:03 +01:00
|
|
|
THD *thd;
|
2007-01-29 18:46:29 +01:00
|
|
|
Event_queue_element_for_exec *event= (Event_queue_element_for_exec *)arg;
|
2006-07-12 10:37:30 +02:00
|
|
|
|
|
|
|
thd= event->thd;
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_thread_set_psi_id(thd->thread_id);
|
|
|
|
|
2007-01-29 18:46:29 +01:00
|
|
|
Event_worker_thread worker_thread;
|
2007-03-01 21:47:28 +01:00
|
|
|
worker_thread.run(thd, event);
|
2007-01-29 18:46:29 +01:00
|
|
|
|
2007-04-06 17:44:14 +02:00
|
|
|
my_thread_end();
|
2007-01-29 18:46:29 +01:00
|
|
|
return 0; // Can't return anything here
|
|
|
|
}
|
|
|
|
|
|
|
|
|
A set of changes aiming to make the Event Scheduler more user-friendly
when there are no up-to-date system tables to support it:
- initialize the scheduler before reporting "Ready for connections".
This ensures that warnings, if any, are printed before "Ready for
connections", and this message is not mangled.
- do not abort the scheduler if there are no system tables
- check the tables once at start up, remember the status and disable
the scheduler if the tables are not up to date.
If one attempts to use the scheduler with bad tables,
issue an error message.
- clean up the behaviour of the module under LOCK TABLES and pre-locking
mode
- make sure implicit commit of Events DDL works as expected.
- add more tests
Collateral clean ups in the events code.
This patch fixes Bug#23631 Events: SHOW VARIABLES doesn't work
when mysql.event is damaged
mysql-test/r/events.result:
Update results.
mysql-test/r/events_bugs.result:
Update results.
mysql-test/r/events_restart_phase1.result:
Update results.
mysql-test/r/events_restart_phase2.result:
Update results.
mysql-test/r/events_restart_phase3.result:
Update results.
mysql-test/r/events_scheduling.result:
Update results.
mysql-test/r/events_time_zone.result:
Update results.
mysql-test/t/events.test:
Add new tests for tampering with mysql.event and some more
tests for sub-statements, LOCK TABLES mode and pre-locking.
mysql-test/t/events_bugs.test:
Move the non-concurrent part of test for Bug 16420 to this file.
mysql-test/t/events_restart_phase1.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase2.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase3.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_scheduling.test:
Add more coverage for event_scheduler global variable.
mysql-test/t/events_time_zone.test:
Move the non-concurrent part of the tests for Bug 16420 to
events_bugs.test
sql/event_data_objects.cc:
Move update_timing_fields functionality to Event_db_repository.
Make loading of events from a table record more robust to tampering
with the table - now we do not check mysql.event on every table open.
sql/event_data_objects.h:
Cleanup.
sql/event_db_repository.cc:
Now Event_db_repository is responsible for table I/O only.
All the logic of events DDL is handled outside, in Events class please
refer to the added test coverage to see how this change affected
the behavior of Event Scheduler.
Dependency on sp_head.h and sp.h removed.
Make this module robust to tweaks with mysql.event table.
Move check_system_tables from events.cc to this file
sql/event_db_repository.h:
Cleanup declarations (remove unused ones, change return type to bool
from int).
sql/event_queue.cc:
Update to adapt to the new start up scheme of the Event Scheduler.
sql/event_queue.h:
Cleanup declarations.
sql/event_scheduler.cc:
Make all the error messages uniform:
[SEVERITY] Event Scheduler: [user][schema.event] message
Using append_identifier for error logging was an overkill - we may
need it only if the system character set may have NUL (null character)
as part of a valid identifier, this is currently never the case,
whereas additional quoting did not look nice in the log.
sql/event_scheduler.h:
Cleanup the headers.
sql/events.cc:
Use a different start up procedure of Event Scheduler:
- at start up, try to check the system tables first.
If they are not up-to-date, disable the scheduler.
- try to load all the active events. In case of a load error, abort
start up.
- do not parse an event on start up. Parsing only gives some information
about event validity, but far not all.
Consolidate the business logic of Events DDL in this module.
Now opt_event_scheduler may change after start up and thus is protected
by LOCK_event_metadata mutex.
sql/events.h:
Use all-static-data-members approach to implement Singleton pattern.
sql/mysqld.cc:
New invocation scheme of Events. Move some logic to events.cc.
Initialize the scheduler before reporting "Ready for connections".
sql/set_var.cc:
Clean up sys_var_thd_sql_mode::symbolic_mode_representation
to work with a LEX_STRING.
Move more logic related to @@events_scheduler global variable to Events
module.
sql/set_var.h:
Update declarations.
sql/share/errmsg.txt:
If someone tampered with mysql.event table after the server has
started we no longer give him/her a complete report what was actually
broken. Do not send the user to look at the error log in such case,
as there is nothing there (check_table_intact is not executed).
sql/sp_head.cc:
Update to a new declaration of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_db.cc:
New invocation scheme of Events module.
sql/sql_parse.cc:
Move more logic to Events module. Make sure that we are consistent
in the way access rights are checked for Events DDL: always
after committing the current transaction and checking the system tables.
sql/sql_show.cc:
Update to the new declarations of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_test.cc:
New invocation scheme of events.
sql/table.cc:
mysql.event is a system table.
Update check_table_intact to be concurrent, more verbose, and less smart.
sql/table.h:
Add a helper method.
mysql-test/r/events_trans.result:
New BitKeeper file ``mysql-test/r/events_trans.result''
mysql-test/t/events_trans.test:
New BitKeeper file ``mysql-test/t/events_trans.test'':
test cases for Event Scheduler that require a transactional
storage engine.
2007-04-05 13:24:34 +02:00
|
|
|
/**
|
2007-03-23 16:14:03 +01:00
|
|
|
Function that executes an event in a child thread. Setups the
|
2007-01-29 18:46:29 +01:00
|
|
|
environment for the event execution and cleans after that.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_worker_thread::run()
|
|
|
|
thd Thread context
|
|
|
|
event The Event_queue_element_for_exec object to be processed
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event)
|
|
|
|
{
|
2007-03-01 21:47:28 +01:00
|
|
|
/* needs to be first for thread_stack */
|
|
|
|
char my_stack;
|
2007-04-13 22:35:56 +02:00
|
|
|
Event_job_data job_data;
|
2007-03-01 21:47:28 +01:00
|
|
|
bool res;
|
|
|
|
|
2015-05-05 15:23:47 +02:00
|
|
|
DBUG_ASSERT(thd->m_digest == NULL);
|
|
|
|
DBUG_ASSERT(thd->m_statement_psi == NULL);
|
|
|
|
|
2020-02-14 17:05:31 +01:00
|
|
|
#ifdef HAVE_PSI_STATEMENT_INTERFACE
|
|
|
|
PSI_statement_locker_state state;
|
|
|
|
thd->m_statement_psi= MYSQL_START_STATEMENT(& state,
|
|
|
|
event->get_psi_info()->m_key,
|
|
|
|
event->dbname.str,
|
|
|
|
event->dbname.length,
|
|
|
|
thd->charset(), NULL);
|
|
|
|
#endif
|
|
|
|
|
2007-03-01 21:47:28 +01:00
|
|
|
thd->thread_stack= &my_stack; // remember where our stack is
|
|
|
|
res= post_init_event_thread(thd);
|
|
|
|
|
2007-01-29 18:46:29 +01:00
|
|
|
DBUG_ENTER("Event_worker_thread::run");
|
2017-09-19 19:45:17 +02:00
|
|
|
DBUG_PRINT("info", ("Time is %u, THD: %p", (uint)my_time(0), thd));
|
2007-03-01 21:47:28 +01:00
|
|
|
|
|
|
|
if (res)
|
2007-01-29 18:46:29 +01:00
|
|
|
goto end;
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
if ((res= db_repository->load_named_event(thd, &event->dbname, &event->name,
|
2007-04-13 22:35:56 +02:00
|
|
|
&job_data)))
|
2007-01-29 18:46:29 +01:00
|
|
|
{
|
2007-04-13 22:35:56 +02:00
|
|
|
DBUG_PRINT("error", ("Got error from load_named_event"));
|
2007-01-29 18:46:29 +01:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
thd->enable_slow_log= TRUE;
|
|
|
|
|
2007-04-13 22:35:56 +02:00
|
|
|
res= job_data.execute(thd, event->dropped);
|
2007-01-29 18:46:29 +01:00
|
|
|
|
2007-04-13 22:35:56 +02:00
|
|
|
print_warnings(thd, &job_data);
|
2007-01-29 18:46:29 +01:00
|
|
|
|
2007-04-13 22:35:56 +02:00
|
|
|
if (res)
|
|
|
|
sql_print_information("Event Scheduler: "
|
|
|
|
"[%s].[%s.%s] event execution failed.",
|
|
|
|
job_data.definer.str,
|
|
|
|
job_data.dbname.str, job_data.name.str);
|
2007-01-29 18:46:29 +01:00
|
|
|
end:
|
2020-02-14 17:05:31 +01:00
|
|
|
#ifdef HAVE_PSI_STATEMENT_INTERFACE
|
|
|
|
MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da());
|
|
|
|
thd->m_statement_psi= NULL;
|
|
|
|
#endif
|
2015-05-05 15:23:47 +02:00
|
|
|
DBUG_ASSERT(thd->m_digest == NULL);
|
2007-03-02 00:39:00 +01:00
|
|
|
DBUG_PRINT("info", ("Done with Event %s.%s", event->dbname.str,
|
2006-07-12 10:37:30 +02:00
|
|
|
event->name.str));
|
|
|
|
|
2007-01-29 18:46:29 +01:00
|
|
|
delete event;
|
2007-03-01 21:47:28 +01:00
|
|
|
deinit_event_thread(thd);
|
2007-06-10 11:16:02 +02:00
|
|
|
|
|
|
|
DBUG_VOID_RETURN;
|
2006-07-12 10:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
A set of changes aiming to make the Event Scheduler more user-friendly
when there are no up-to-date system tables to support it:
- initialize the scheduler before reporting "Ready for connections".
This ensures that warnings, if any, are printed before "Ready for
connections", and this message is not mangled.
- do not abort the scheduler if there are no system tables
- check the tables once at start up, remember the status and disable
the scheduler if the tables are not up to date.
If one attempts to use the scheduler with bad tables,
issue an error message.
- clean up the behaviour of the module under LOCK TABLES and pre-locking
mode
- make sure implicit commit of Events DDL works as expected.
- add more tests
Collateral clean ups in the events code.
This patch fixes Bug#23631 Events: SHOW VARIABLES doesn't work
when mysql.event is damaged
mysql-test/r/events.result:
Update results.
mysql-test/r/events_bugs.result:
Update results.
mysql-test/r/events_restart_phase1.result:
Update results.
mysql-test/r/events_restart_phase2.result:
Update results.
mysql-test/r/events_restart_phase3.result:
Update results.
mysql-test/r/events_scheduling.result:
Update results.
mysql-test/r/events_time_zone.result:
Update results.
mysql-test/t/events.test:
Add new tests for tampering with mysql.event and some more
tests for sub-statements, LOCK TABLES mode and pre-locking.
mysql-test/t/events_bugs.test:
Move the non-concurrent part of test for Bug 16420 to this file.
mysql-test/t/events_restart_phase1.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase2.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase3.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_scheduling.test:
Add more coverage for event_scheduler global variable.
mysql-test/t/events_time_zone.test:
Move the non-concurrent part of the tests for Bug 16420 to
events_bugs.test
sql/event_data_objects.cc:
Move update_timing_fields functionality to Event_db_repository.
Make loading of events from a table record more robust to tampering
with the table - now we do not check mysql.event on every table open.
sql/event_data_objects.h:
Cleanup.
sql/event_db_repository.cc:
Now Event_db_repository is responsible for table I/O only.
All the logic of events DDL is handled outside, in Events class please
refer to the added test coverage to see how this change affected
the behavior of Event Scheduler.
Dependency on sp_head.h and sp.h removed.
Make this module robust to tweaks with mysql.event table.
Move check_system_tables from events.cc to this file
sql/event_db_repository.h:
Cleanup declarations (remove unused ones, change return type to bool
from int).
sql/event_queue.cc:
Update to adapt to the new start up scheme of the Event Scheduler.
sql/event_queue.h:
Cleanup declarations.
sql/event_scheduler.cc:
Make all the error messages uniform:
[SEVERITY] Event Scheduler: [user][schema.event] message
Using append_identifier for error logging was an overkill - we may
need it only if the system character set may have NUL (null character)
as part of a valid identifier, this is currently never the case,
whereas additional quoting did not look nice in the log.
sql/event_scheduler.h:
Cleanup the headers.
sql/events.cc:
Use a different start up procedure of Event Scheduler:
- at start up, try to check the system tables first.
If they are not up-to-date, disable the scheduler.
- try to load all the active events. In case of a load error, abort
start up.
- do not parse an event on start up. Parsing only gives some information
about event validity, but far not all.
Consolidate the business logic of Events DDL in this module.
Now opt_event_scheduler may change after start up and thus is protected
by LOCK_event_metadata mutex.
sql/events.h:
Use all-static-data-members approach to implement Singleton pattern.
sql/mysqld.cc:
New invocation scheme of Events. Move some logic to events.cc.
Initialize the scheduler before reporting "Ready for connections".
sql/set_var.cc:
Clean up sys_var_thd_sql_mode::symbolic_mode_representation
to work with a LEX_STRING.
Move more logic related to @@events_scheduler global variable to Events
module.
sql/set_var.h:
Update declarations.
sql/share/errmsg.txt:
If someone tampered with mysql.event table after the server has
started we no longer give him/her a complete report what was actually
broken. Do not send the user to look at the error log in such case,
as there is nothing there (check_table_intact is not executed).
sql/sp_head.cc:
Update to a new declaration of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_db.cc:
New invocation scheme of Events module.
sql/sql_parse.cc:
Move more logic to Events module. Make sure that we are consistent
in the way access rights are checked for Events DDL: always
after committing the current transaction and checking the system tables.
sql/sql_show.cc:
Update to the new declarations of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_test.cc:
New invocation scheme of events.
sql/table.cc:
mysql.event is a system table.
Update check_table_intact to be concurrent, more verbose, and less smart.
sql/table.h:
Add a helper method.
mysql-test/r/events_trans.result:
New BitKeeper file ``mysql-test/r/events_trans.result''
mysql-test/t/events_trans.test:
New BitKeeper file ``mysql-test/t/events_trans.test'':
test cases for Event Scheduler that require a transactional
storage engine.
2007-04-05 13:24:34 +02:00
|
|
|
Event_scheduler::Event_scheduler(Event_queue *queue_arg)
|
2007-05-21 10:51:11 +02:00
|
|
|
:state(INITIALIZED),
|
A set of changes aiming to make the Event Scheduler more user-friendly
when there are no up-to-date system tables to support it:
- initialize the scheduler before reporting "Ready for connections".
This ensures that warnings, if any, are printed before "Ready for
connections", and this message is not mangled.
- do not abort the scheduler if there are no system tables
- check the tables once at start up, remember the status and disable
the scheduler if the tables are not up to date.
If one attempts to use the scheduler with bad tables,
issue an error message.
- clean up the behaviour of the module under LOCK TABLES and pre-locking
mode
- make sure implicit commit of Events DDL works as expected.
- add more tests
Collateral clean ups in the events code.
This patch fixes Bug#23631 Events: SHOW VARIABLES doesn't work
when mysql.event is damaged
mysql-test/r/events.result:
Update results.
mysql-test/r/events_bugs.result:
Update results.
mysql-test/r/events_restart_phase1.result:
Update results.
mysql-test/r/events_restart_phase2.result:
Update results.
mysql-test/r/events_restart_phase3.result:
Update results.
mysql-test/r/events_scheduling.result:
Update results.
mysql-test/r/events_time_zone.result:
Update results.
mysql-test/t/events.test:
Add new tests for tampering with mysql.event and some more
tests for sub-statements, LOCK TABLES mode and pre-locking.
mysql-test/t/events_bugs.test:
Move the non-concurrent part of test for Bug 16420 to this file.
mysql-test/t/events_restart_phase1.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase2.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase3.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_scheduling.test:
Add more coverage for event_scheduler global variable.
mysql-test/t/events_time_zone.test:
Move the non-concurrent part of the tests for Bug 16420 to
events_bugs.test
sql/event_data_objects.cc:
Move update_timing_fields functionality to Event_db_repository.
Make loading of events from a table record more robust to tampering
with the table - now we do not check mysql.event on every table open.
sql/event_data_objects.h:
Cleanup.
sql/event_db_repository.cc:
Now Event_db_repository is responsible for table I/O only.
All the logic of events DDL is handled outside, in Events class please
refer to the added test coverage to see how this change affected
the behavior of Event Scheduler.
Dependency on sp_head.h and sp.h removed.
Make this module robust to tweaks with mysql.event table.
Move check_system_tables from events.cc to this file
sql/event_db_repository.h:
Cleanup declarations (remove unused ones, change return type to bool
from int).
sql/event_queue.cc:
Update to adapt to the new start up scheme of the Event Scheduler.
sql/event_queue.h:
Cleanup declarations.
sql/event_scheduler.cc:
Make all the error messages uniform:
[SEVERITY] Event Scheduler: [user][schema.event] message
Using append_identifier for error logging was an overkill - we may
need it only if the system character set may have NUL (null character)
as part of a valid identifier, this is currently never the case,
whereas additional quoting did not look nice in the log.
sql/event_scheduler.h:
Cleanup the headers.
sql/events.cc:
Use a different start up procedure of Event Scheduler:
- at start up, try to check the system tables first.
If they are not up-to-date, disable the scheduler.
- try to load all the active events. In case of a load error, abort
start up.
- do not parse an event on start up. Parsing only gives some information
about event validity, but far not all.
Consolidate the business logic of Events DDL in this module.
Now opt_event_scheduler may change after start up and thus is protected
by LOCK_event_metadata mutex.
sql/events.h:
Use all-static-data-members approach to implement Singleton pattern.
sql/mysqld.cc:
New invocation scheme of Events. Move some logic to events.cc.
Initialize the scheduler before reporting "Ready for connections".
sql/set_var.cc:
Clean up sys_var_thd_sql_mode::symbolic_mode_representation
to work with a LEX_STRING.
Move more logic related to @@events_scheduler global variable to Events
module.
sql/set_var.h:
Update declarations.
sql/share/errmsg.txt:
If someone tampered with mysql.event table after the server has
started we no longer give him/her a complete report what was actually
broken. Do not send the user to look at the error log in such case,
as there is nothing there (check_table_intact is not executed).
sql/sp_head.cc:
Update to a new declaration of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_db.cc:
New invocation scheme of Events module.
sql/sql_parse.cc:
Move more logic to Events module. Make sure that we are consistent
in the way access rights are checked for Events DDL: always
after committing the current transaction and checking the system tables.
sql/sql_show.cc:
Update to the new declarations of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_test.cc:
New invocation scheme of events.
sql/table.cc:
mysql.event is a system table.
Update check_table_intact to be concurrent, more verbose, and less smart.
sql/table.h:
Add a helper method.
mysql-test/r/events_trans.result:
New BitKeeper file ``mysql-test/r/events_trans.result''
mysql-test/t/events_trans.test:
New BitKeeper file ``mysql-test/t/events_trans.test'':
test cases for Event Scheduler that require a transactional
storage engine.
2007-04-05 13:24:34 +02:00
|
|
|
scheduler_thd(NULL),
|
|
|
|
queue(queue_arg),
|
2007-05-21 10:51:11 +02:00
|
|
|
mutex_last_locked_at_line(0),
|
|
|
|
mutex_last_unlocked_at_line(0),
|
|
|
|
mutex_last_locked_in_func("n/a"),
|
|
|
|
mutex_last_unlocked_in_func("n/a"),
|
|
|
|
mutex_scheduler_data_locked(FALSE),
|
|
|
|
waiting_on_cond(FALSE),
|
A set of changes aiming to make the Event Scheduler more user-friendly
when there are no up-to-date system tables to support it:
- initialize the scheduler before reporting "Ready for connections".
This ensures that warnings, if any, are printed before "Ready for
connections", and this message is not mangled.
- do not abort the scheduler if there are no system tables
- check the tables once at start up, remember the status and disable
the scheduler if the tables are not up to date.
If one attempts to use the scheduler with bad tables,
issue an error message.
- clean up the behaviour of the module under LOCK TABLES and pre-locking
mode
- make sure implicit commit of Events DDL works as expected.
- add more tests
Collateral clean ups in the events code.
This patch fixes Bug#23631 Events: SHOW VARIABLES doesn't work
when mysql.event is damaged
mysql-test/r/events.result:
Update results.
mysql-test/r/events_bugs.result:
Update results.
mysql-test/r/events_restart_phase1.result:
Update results.
mysql-test/r/events_restart_phase2.result:
Update results.
mysql-test/r/events_restart_phase3.result:
Update results.
mysql-test/r/events_scheduling.result:
Update results.
mysql-test/r/events_time_zone.result:
Update results.
mysql-test/t/events.test:
Add new tests for tampering with mysql.event and some more
tests for sub-statements, LOCK TABLES mode and pre-locking.
mysql-test/t/events_bugs.test:
Move the non-concurrent part of test for Bug 16420 to this file.
mysql-test/t/events_restart_phase1.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase2.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase3.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_scheduling.test:
Add more coverage for event_scheduler global variable.
mysql-test/t/events_time_zone.test:
Move the non-concurrent part of the tests for Bug 16420 to
events_bugs.test
sql/event_data_objects.cc:
Move update_timing_fields functionality to Event_db_repository.
Make loading of events from a table record more robust to tampering
with the table - now we do not check mysql.event on every table open.
sql/event_data_objects.h:
Cleanup.
sql/event_db_repository.cc:
Now Event_db_repository is responsible for table I/O only.
All the logic of events DDL is handled outside, in Events class please
refer to the added test coverage to see how this change affected
the behavior of Event Scheduler.
Dependency on sp_head.h and sp.h removed.
Make this module robust to tweaks with mysql.event table.
Move check_system_tables from events.cc to this file
sql/event_db_repository.h:
Cleanup declarations (remove unused ones, change return type to bool
from int).
sql/event_queue.cc:
Update to adapt to the new start up scheme of the Event Scheduler.
sql/event_queue.h:
Cleanup declarations.
sql/event_scheduler.cc:
Make all the error messages uniform:
[SEVERITY] Event Scheduler: [user][schema.event] message
Using append_identifier for error logging was an overkill - we may
need it only if the system character set may have NUL (null character)
as part of a valid identifier, this is currently never the case,
whereas additional quoting did not look nice in the log.
sql/event_scheduler.h:
Cleanup the headers.
sql/events.cc:
Use a different start up procedure of Event Scheduler:
- at start up, try to check the system tables first.
If they are not up-to-date, disable the scheduler.
- try to load all the active events. In case of a load error, abort
start up.
- do not parse an event on start up. Parsing only gives some information
about event validity, but far not all.
Consolidate the business logic of Events DDL in this module.
Now opt_event_scheduler may change after start up and thus is protected
by LOCK_event_metadata mutex.
sql/events.h:
Use all-static-data-members approach to implement Singleton pattern.
sql/mysqld.cc:
New invocation scheme of Events. Move some logic to events.cc.
Initialize the scheduler before reporting "Ready for connections".
sql/set_var.cc:
Clean up sys_var_thd_sql_mode::symbolic_mode_representation
to work with a LEX_STRING.
Move more logic related to @@events_scheduler global variable to Events
module.
sql/set_var.h:
Update declarations.
sql/share/errmsg.txt:
If someone tampered with mysql.event table after the server has
started we no longer give him/her a complete report what was actually
broken. Do not send the user to look at the error log in such case,
as there is nothing there (check_table_intact is not executed).
sql/sp_head.cc:
Update to a new declaration of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_db.cc:
New invocation scheme of Events module.
sql/sql_parse.cc:
Move more logic to Events module. Make sure that we are consistent
in the way access rights are checked for Events DDL: always
after committing the current transaction and checking the system tables.
sql/sql_show.cc:
Update to the new declarations of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_test.cc:
New invocation scheme of events.
sql/table.cc:
mysql.event is a system table.
Update check_table_intact to be concurrent, more verbose, and less smart.
sql/table.h:
Add a helper method.
mysql-test/r/events_trans.result:
New BitKeeper file ``mysql-test/r/events_trans.result''
mysql-test/t/events_trans.test:
New BitKeeper file ``mysql-test/t/events_trans.test'':
test cases for Event Scheduler that require a transactional
storage engine.
2007-04-05 13:24:34 +02:00
|
|
|
started_events(0)
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_init(key_event_scheduler_LOCK_scheduler_state,
|
|
|
|
&LOCK_scheduler_state, MY_MUTEX_INIT_FAST);
|
|
|
|
mysql_cond_init(key_event_scheduler_COND_state, &COND_state, NULL);
|
2014-09-25 08:43:11 +02:00
|
|
|
mysql_mutex_record_order(&LOCK_scheduler_state, &LOCK_global_system_variables);
|
2006-07-12 10:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
A set of changes aiming to make the Event Scheduler more user-friendly
when there are no up-to-date system tables to support it:
- initialize the scheduler before reporting "Ready for connections".
This ensures that warnings, if any, are printed before "Ready for
connections", and this message is not mangled.
- do not abort the scheduler if there are no system tables
- check the tables once at start up, remember the status and disable
the scheduler if the tables are not up to date.
If one attempts to use the scheduler with bad tables,
issue an error message.
- clean up the behaviour of the module under LOCK TABLES and pre-locking
mode
- make sure implicit commit of Events DDL works as expected.
- add more tests
Collateral clean ups in the events code.
This patch fixes Bug#23631 Events: SHOW VARIABLES doesn't work
when mysql.event is damaged
mysql-test/r/events.result:
Update results.
mysql-test/r/events_bugs.result:
Update results.
mysql-test/r/events_restart_phase1.result:
Update results.
mysql-test/r/events_restart_phase2.result:
Update results.
mysql-test/r/events_restart_phase3.result:
Update results.
mysql-test/r/events_scheduling.result:
Update results.
mysql-test/r/events_time_zone.result:
Update results.
mysql-test/t/events.test:
Add new tests for tampering with mysql.event and some more
tests for sub-statements, LOCK TABLES mode and pre-locking.
mysql-test/t/events_bugs.test:
Move the non-concurrent part of test for Bug 16420 to this file.
mysql-test/t/events_restart_phase1.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase2.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase3.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_scheduling.test:
Add more coverage for event_scheduler global variable.
mysql-test/t/events_time_zone.test:
Move the non-concurrent part of the tests for Bug 16420 to
events_bugs.test
sql/event_data_objects.cc:
Move update_timing_fields functionality to Event_db_repository.
Make loading of events from a table record more robust to tampering
with the table - now we do not check mysql.event on every table open.
sql/event_data_objects.h:
Cleanup.
sql/event_db_repository.cc:
Now Event_db_repository is responsible for table I/O only.
All the logic of events DDL is handled outside, in Events class please
refer to the added test coverage to see how this change affected
the behavior of Event Scheduler.
Dependency on sp_head.h and sp.h removed.
Make this module robust to tweaks with mysql.event table.
Move check_system_tables from events.cc to this file
sql/event_db_repository.h:
Cleanup declarations (remove unused ones, change return type to bool
from int).
sql/event_queue.cc:
Update to adapt to the new start up scheme of the Event Scheduler.
sql/event_queue.h:
Cleanup declarations.
sql/event_scheduler.cc:
Make all the error messages uniform:
[SEVERITY] Event Scheduler: [user][schema.event] message
Using append_identifier for error logging was an overkill - we may
need it only if the system character set may have NUL (null character)
as part of a valid identifier, this is currently never the case,
whereas additional quoting did not look nice in the log.
sql/event_scheduler.h:
Cleanup the headers.
sql/events.cc:
Use a different start up procedure of Event Scheduler:
- at start up, try to check the system tables first.
If they are not up-to-date, disable the scheduler.
- try to load all the active events. In case of a load error, abort
start up.
- do not parse an event on start up. Parsing only gives some information
about event validity, but far not all.
Consolidate the business logic of Events DDL in this module.
Now opt_event_scheduler may change after start up and thus is protected
by LOCK_event_metadata mutex.
sql/events.h:
Use all-static-data-members approach to implement Singleton pattern.
sql/mysqld.cc:
New invocation scheme of Events. Move some logic to events.cc.
Initialize the scheduler before reporting "Ready for connections".
sql/set_var.cc:
Clean up sys_var_thd_sql_mode::symbolic_mode_representation
to work with a LEX_STRING.
Move more logic related to @@events_scheduler global variable to Events
module.
sql/set_var.h:
Update declarations.
sql/share/errmsg.txt:
If someone tampered with mysql.event table after the server has
started we no longer give him/her a complete report what was actually
broken. Do not send the user to look at the error log in such case,
as there is nothing there (check_table_intact is not executed).
sql/sp_head.cc:
Update to a new declaration of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_db.cc:
New invocation scheme of Events module.
sql/sql_parse.cc:
Move more logic to Events module. Make sure that we are consistent
in the way access rights are checked for Events DDL: always
after committing the current transaction and checking the system tables.
sql/sql_show.cc:
Update to the new declarations of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_test.cc:
New invocation scheme of events.
sql/table.cc:
mysql.event is a system table.
Update check_table_intact to be concurrent, more verbose, and less smart.
sql/table.h:
Add a helper method.
mysql-test/r/events_trans.result:
New BitKeeper file ``mysql-test/r/events_trans.result''
mysql-test/t/events_trans.test:
New BitKeeper file ``mysql-test/t/events_trans.test'':
test cases for Event Scheduler that require a transactional
storage engine.
2007-04-05 13:24:34 +02:00
|
|
|
Event_scheduler::~Event_scheduler()
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
A set of changes aiming to make the Event Scheduler more user-friendly
when there are no up-to-date system tables to support it:
- initialize the scheduler before reporting "Ready for connections".
This ensures that warnings, if any, are printed before "Ready for
connections", and this message is not mangled.
- do not abort the scheduler if there are no system tables
- check the tables once at start up, remember the status and disable
the scheduler if the tables are not up to date.
If one attempts to use the scheduler with bad tables,
issue an error message.
- clean up the behaviour of the module under LOCK TABLES and pre-locking
mode
- make sure implicit commit of Events DDL works as expected.
- add more tests
Collateral clean ups in the events code.
This patch fixes Bug#23631 Events: SHOW VARIABLES doesn't work
when mysql.event is damaged
mysql-test/r/events.result:
Update results.
mysql-test/r/events_bugs.result:
Update results.
mysql-test/r/events_restart_phase1.result:
Update results.
mysql-test/r/events_restart_phase2.result:
Update results.
mysql-test/r/events_restart_phase3.result:
Update results.
mysql-test/r/events_scheduling.result:
Update results.
mysql-test/r/events_time_zone.result:
Update results.
mysql-test/t/events.test:
Add new tests for tampering with mysql.event and some more
tests for sub-statements, LOCK TABLES mode and pre-locking.
mysql-test/t/events_bugs.test:
Move the non-concurrent part of test for Bug 16420 to this file.
mysql-test/t/events_restart_phase1.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase2.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase3.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_scheduling.test:
Add more coverage for event_scheduler global variable.
mysql-test/t/events_time_zone.test:
Move the non-concurrent part of the tests for Bug 16420 to
events_bugs.test
sql/event_data_objects.cc:
Move update_timing_fields functionality to Event_db_repository.
Make loading of events from a table record more robust to tampering
with the table - now we do not check mysql.event on every table open.
sql/event_data_objects.h:
Cleanup.
sql/event_db_repository.cc:
Now Event_db_repository is responsible for table I/O only.
All the logic of events DDL is handled outside, in Events class please
refer to the added test coverage to see how this change affected
the behavior of Event Scheduler.
Dependency on sp_head.h and sp.h removed.
Make this module robust to tweaks with mysql.event table.
Move check_system_tables from events.cc to this file
sql/event_db_repository.h:
Cleanup declarations (remove unused ones, change return type to bool
from int).
sql/event_queue.cc:
Update to adapt to the new start up scheme of the Event Scheduler.
sql/event_queue.h:
Cleanup declarations.
sql/event_scheduler.cc:
Make all the error messages uniform:
[SEVERITY] Event Scheduler: [user][schema.event] message
Using append_identifier for error logging was an overkill - we may
need it only if the system character set may have NUL (null character)
as part of a valid identifier, this is currently never the case,
whereas additional quoting did not look nice in the log.
sql/event_scheduler.h:
Cleanup the headers.
sql/events.cc:
Use a different start up procedure of Event Scheduler:
- at start up, try to check the system tables first.
If they are not up-to-date, disable the scheduler.
- try to load all the active events. In case of a load error, abort
start up.
- do not parse an event on start up. Parsing only gives some information
about event validity, but far not all.
Consolidate the business logic of Events DDL in this module.
Now opt_event_scheduler may change after start up and thus is protected
by LOCK_event_metadata mutex.
sql/events.h:
Use all-static-data-members approach to implement Singleton pattern.
sql/mysqld.cc:
New invocation scheme of Events. Move some logic to events.cc.
Initialize the scheduler before reporting "Ready for connections".
sql/set_var.cc:
Clean up sys_var_thd_sql_mode::symbolic_mode_representation
to work with a LEX_STRING.
Move more logic related to @@events_scheduler global variable to Events
module.
sql/set_var.h:
Update declarations.
sql/share/errmsg.txt:
If someone tampered with mysql.event table after the server has
started we no longer give him/her a complete report what was actually
broken. Do not send the user to look at the error log in such case,
as there is nothing there (check_table_intact is not executed).
sql/sp_head.cc:
Update to a new declaration of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_db.cc:
New invocation scheme of Events module.
sql/sql_parse.cc:
Move more logic to Events module. Make sure that we are consistent
in the way access rights are checked for Events DDL: always
after committing the current transaction and checking the system tables.
sql/sql_show.cc:
Update to the new declarations of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_test.cc:
New invocation scheme of events.
sql/table.cc:
mysql.event is a system table.
Update check_table_intact to be concurrent, more verbose, and less smart.
sql/table.h:
Add a helper method.
mysql-test/r/events_trans.result:
New BitKeeper file ``mysql-test/r/events_trans.result''
mysql-test/t/events_trans.test:
New BitKeeper file ``mysql-test/t/events_trans.test'':
test cases for Event Scheduler that require a transactional
storage engine.
2007-04-05 13:24:34 +02:00
|
|
|
stop(); /* does nothing if not running */
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_destroy(&LOCK_scheduler_state);
|
|
|
|
mysql_cond_destroy(&COND_state);
|
2006-07-12 10:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-24 12:14:41 +02:00
|
|
|
/**
|
2006-07-12 10:37:30 +02:00
|
|
|
Starts the scheduler (again). Creates a new THD and passes it to
|
|
|
|
a forked thread. Does not wait for acknowledgement from the new
|
|
|
|
thread that it has started. Asynchronous starting. Most of the
|
|
|
|
needed initializations are done in the current thread to minimize
|
|
|
|
the chance of failure in the spawned thread.
|
|
|
|
|
2013-07-24 12:14:41 +02:00
|
|
|
@param[out] err_no - errno indicating type of error which caused
|
|
|
|
failure to start scheduler thread.
|
2006-07-12 10:37:30 +02:00
|
|
|
|
2013-07-24 12:14:41 +02:00
|
|
|
@return
|
|
|
|
@retval false Success.
|
|
|
|
@retval true Error.
|
2006-07-12 10:37:30 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
bool
|
2013-07-24 12:14:41 +02:00
|
|
|
Event_scheduler::start(int *err_no)
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
|
|
|
THD *new_thd= NULL;
|
2013-07-24 12:14:41 +02:00
|
|
|
bool ret= false;
|
2006-07-12 10:37:30 +02:00
|
|
|
pthread_t th;
|
2006-07-13 10:59:58 +02:00
|
|
|
struct scheduler_param *scheduler_param_value;
|
2006-07-12 10:37:30 +02:00
|
|
|
DBUG_ENTER("Event_scheduler::start");
|
|
|
|
|
2006-07-13 16:24:55 +02:00
|
|
|
LOCK_DATA();
|
2006-11-27 00:47:38 +01:00
|
|
|
DBUG_PRINT("info", ("state before action %s", scheduler_states_names[state].str));
|
2006-07-12 10:37:30 +02:00
|
|
|
if (state > INITIALIZED)
|
|
|
|
goto end;
|
|
|
|
|
2016-04-07 18:51:40 +02:00
|
|
|
if (!(new_thd= new THD(next_thread_id())))
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
2007-03-23 17:14:08 +01:00
|
|
|
sql_print_error("Event Scheduler: Cannot initialize the scheduler thread");
|
2013-07-24 12:14:41 +02:00
|
|
|
ret= true;
|
2006-07-12 10:37:30 +02:00
|
|
|
goto end;
|
|
|
|
}
|
MDEV-4011 Added per thread memory counting and usage
Base code and idea from a patch from by plinux at Taobao.
The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC.
Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc().
There are plenty of new asserts to ensure that for a debug server the counting is correct.
Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS.
- The later is there mainly to show how query is progressing.
The following changes in interfaces was needed to get this to work:
- init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root()
- my_init_dynamic_array() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- Added flag for hash_init() so that one can mark hash table to be thread specific.
- Added flags to init_tree() so that one can mark tree to be thread specific.
- Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
- Added flag to Warning_info::Warning_info() if the structure should be fully initialized.
- String elements can now be marked as thread specific.
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Changed type of myf from int to ulong, as this is always a set of bit flags.
Other things:
- Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
- We now also show EXAMINED_ROWS in SHOW PROCESSLIST
- Added new variable 'memory_used'
- Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
- Removed calls to the obsoleted function init_dynamic_array()
- Use set_current_thd() instead of my_pthread_setspecific_ptr(THR_THD,...)
client/completion_hash.cc:
Updated call to init_alloc_root()
client/mysql.cc:
Updated call to init_alloc_root()
client/mysqlbinlog.cc:
init_dynamic_array() -> my_init_dynamic_array()
Updated call to init_alloc_root()
client/mysqlcheck.c:
Updated call to my_init_dynamic_array()
client/mysqldump.c:
Updated call to init_alloc_root()
client/mysqltest.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Fixed compiler warnings
extra/comp_err.c:
Updated call to my_init_dynamic_array()
extra/resolve_stack_dump.c:
Updated call to my_init_dynamic_array()
include/hash.h:
Added HASH_THREAD_SPECIFIC
include/heap.h:
Added flag is internal temporary table.
include/my_dir.h:
Safety fix: Ensure that MY_DONT_SORT and MY_WANT_STAT don't interfer with other mysys flags
include/my_global.h:
Changed type of myf from int to ulong, as this is always a set of bit flags.
include/my_sys.h:
Added MY_THREAD_SPECIFIC and MY_THREAD_MOVE
Added malloc_flags to DYNAMIC_ARRAY
Added extra mysys flag argument to my_init_dynamic_array()
Removed deprecated functions init_dynamic_array() and my_init_dynamic_array.._ci
Updated paramaters for init_alloc_root()
include/my_tree.h:
Added my_flags to allow one to use MY_THREAD_SPECIFIC with hash tables.
Removed with_delete. One should now instead use MY_TREE_WITH_DELETE_FLAG
Updated parameters to init_tree()
include/myisamchk.h:
Added malloc_flags to allow one to use MY_THREAD_SPECIFIC for checks.
include/mysql.h:
Added MYSQL_THREAD_SPECIFIC_MALLOC
Used 'unused1' to mark memory as thread specific.
include/mysql.h.pp:
Updated file
include/mysql_com.h:
Used 'unused1' to mark memory as thread specific.
Updated parameters for my_net_init()
libmysql/libmysql.c:
Updated call to init_alloc_root() to mark memory thread specific.
libmysqld/emb_qcache.cc:
Updated call to init_alloc_root()
libmysqld/lib_sql.cc:
Updated call to init_alloc_root()
mysql-test/r/create.result:
Updated results
mysql-test/r/user_var.result:
Updated results
mysql-test/suite/funcs_1/datadict/processlist_priv.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/is_columns_is.result:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result:
Updated results
mysql-test/suite/funcs_1/r/processlist_val_no_prot.result:
Updated results
mysql-test/t/show_explain.test:
Fixed usage of debug variable so that one can run test with --debug
mysql-test/t/user_var.test:
Added test of memory_usage variable.
mysys/array.c:
Added extra my_flags option to init_dynamic_array() and init_dynamic_array2() so that one can mark memory with MY_THREAD_SPECIFIC
All allocated memory is marked with the given my_flags.
Removed obsolete function init_dynamic_array()
mysys/default.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
mysys/hash.c:
Updated call to my_init_dynamic_array_ci().
Allocated memory is marked with MY_THREAD_SPECIFIC if HASH_THREAD_SPECIFIC is used.
mysys/ma_dyncol.c:
init_dynamic_array() -> my_init_dynamic_array()
Added #if to get rid of compiler warnings
mysys/mf_tempdir.c:
Updated call to my_init_dynamic_array()
mysys/my_alloc.c:
Added extra parameter to init_alloc_root() so that one can mark memory with MY_THREAD_SPECIFIC
Extend MEM_ROOT with a flag if memory is thread specific.
This is stored in block_size, to keep the size of the MEM_ROOT object identical as before.
Allocated memory is marked with MY_THREAD_SPECIFIC if used with init_alloc_root()
mysys/my_chmod.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_chsize.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_copy.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_create.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_delete.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_error.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fopen.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fstream.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_getwd.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_lib.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Updated DBUG_PRINT because of change of myf type
mysys/my_lock.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_malloc.c:
Store at start of each allocated memory block the size of the block and if the block is thread specific.
Call malloc_size_cb_func, if set, with the memory allocated/freed.
Updated DBUG_PRINT because of change of myf type
mysys/my_open.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_pread.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_read.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_redel.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_rename.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_seek.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_sync.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_thr_init.c:
Ensure that one can call my_thread_dbug_id() even if thread is not properly initialized.
mysys/my_write.c:
Updated DBUG_PRINT because of change of myf type
mysys/mysys_priv.h:
Updated parameters to sf_malloc and sf_realloc()
mysys/safemalloc.c:
Added checking that for memory marked with MY_THREAD_SPECIFIC that it's the same thread that is allocation and freeing the memory.
Added sf_malloc_dbug_id() to allow MariaDB to specify which THD is handling the memory.
Added my_flags arguments to sf_malloc() and sf_realloc() to be able to mark memory with MY_THREAD_SPECIFIC.
Added sf_report_leaked_memory() to get list of memory not freed by a thread.
mysys/tree.c:
Added flags to init_tree() so that one can mark tree to be thread specific.
Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
Updated call to init_alloc_root()
All allocated memory is marked with the given malloc flags
mysys/waiting_threads.c:
Updated call to my_init_dynamic_array()
sql-common/client.c:
Updated call to init_alloc_root() and my_net_init() to mark memory thread specific.
Updated call to my_init_dynamic_array().
Added MYSQL_THREAD_SPECIFIC_MALLOC so that client can mark memory as MY_THREAD_SPECIFIC.
sql-common/client_plugin.c:
Updated call to init_alloc_root()
sql/debug_sync.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/event_scheduler.cc:
Removed calls to net_end() as this is now done in ~THD()
Call set_current_thd() to ensure that memory is assigned to right thread.
sql/events.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/filesort.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/filesort_utils.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/ha_ndbcluster.cc:
Updated call to init_alloc_root()
Updated call to my_net_init()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_ndbcluster_binlog.cc:
Updated call to my_net_init()
Updated call to init_sql_alloc()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_partition.cc:
Updated call to init_alloc_root()
sql/handler.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
Added missing call to my_dir_end()
sql/item_func.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_subselect.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_sum.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/log.cc:
More DBUG
Updated call to init_alloc_root()
sql/mdl.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/mysqld.cc:
Added total_memory_used
Updated call to init_alloc_root()
Move mysql_cond_broadcast() before my_thread_end()
Added mariadb_dbug_id() to count memory per THD instead of per thread.
Added my_malloc_size_cb_func() callback function for my_malloc() to count memory.
Move initialization of mysqld_server_started and mysqld_server_initialized earlier.
Updated call to my_init_dynamic_array().
Updated call to my_net_init().
Call my_pthread_setspecific_ptr(THR_THD,...) to ensure that memory is assigned to right thread.
Added status variable 'memory_used'.
Updated call to init_alloc_root()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/mysqld.h:
Added set_current_thd()
sql/net_serv.cc:
Added new parameter to my_net_init() so that one can mark memory with MY_THREAD_SPECIFIC.
Store in net->thread_specific_malloc if memory is thread specific.
Mark memory to be thread specific if requested.
sql/opt_range.cc:
Updated call to my_init_dynamic_array()
Updated call to init_sql_alloc()
Added MY_THREAD_SPECIFIC to allocated memory.
sql/opt_subselect.cc:
Updated call to init_sql_alloc() to mark memory thread specific.
sql/protocol.cc:
Fixed compiler warning
sql/records.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/rpl_filter.cc:
Updated call to my_init_dynamic_array()
sql/rpl_handler.cc:
Updated call to my_init_dynamic_array2()
sql/rpl_handler.h:
Updated call to init_sql_alloc()
sql/rpl_mi.cc:
Updated call to my_init_dynamic_array()
sql/rpl_tblmap.cc:
Updated call to init_alloc_root()
sql/rpl_utility.cc:
Updated call to my_init_dynamic_array()
sql/slave.cc:
Initialize things properly before calling functions that allocate memory.
Removed calls to net_end() as this is now done in ~THD()
sql/sp_head.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
Added parameter to warning_info() that it should be fully initialized.
sql/sp_pcontext.cc:
Updated call to my_init_dynamic_array()
sql/sql_acl.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_admin.cc:
Added parameter to warning_info() that it should be fully initialized.
sql/sql_analyse.h:
Updated call to init_tree() to mark memory thread specific.
sql/sql_array.h:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_audit.cc:
Updated call to my_init_dynamic_array()
sql/sql_base.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_cache.cc:
Updated comment
sql/sql_class.cc:
Added parameter to warning_info() that not initialize it until THD is fully created.
Updated call to init_sql_alloc()
Mark THD::user_vars has to be thread specific.
Updated call to my_init_dynamic_array()
Ensure that memory allocated by THD is assigned to the THD.
More DBUG
Always acll net_end() in ~THD()
Assert that all memory signed to this THD is really deleted at ~THD.
Fixed set_status_var_init() to not reset memory_used.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_class.h:
Added MY_THREAD_SPECIFIC to allocated memory.
Added malloc_size to THD to record allocated memory per THD.
sql/sql_delete.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_error.cc:
Added 'initialize' parameter to Warning_info() to say if should allocate memory for it's structures.
This is used by THD::THD() to not allocate memory until THD is ready.
Added Warning_info::free_memory()
sql/sql_error.h:
Updated Warning_info() class.
sql/sql_handler.cc:
Updated call to init_alloc_root() to mark memory thread specific.
sql/sql_insert.cc:
More DBUG
sql/sql_join_cache.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_lex.cc:
Updated call to my_init_dynamic_array()
sql/sql_lex.h:
Updated call to my_init_dynamic_array()
sql/sql_load.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_parse.cc:
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
Ensure that examined_row_count() is reset before query.
Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Don't restore thd->status_var.memory_used when restoring thd->status_var
sql/sql_plugin.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Don't allocate THD on the stack, as this causes problems with valgrind when doing thd memory counting.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_prepare.cc:
Added parameter to warning_info() that it should be fully initialized.
Updated call to init_sql_alloc() to mark memory thread specific.
sql/sql_reload.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_select.cc:
Updated call to my_init_dynamic_array() and init_sql_alloc() to mark memory thread specific.
Added MY_THREAD_SPECIFIC to allocated memory.
More DBUG
sql/sql_servers.cc:
Updated call to init_sql_alloc() to mark memory some memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_show.cc:
Updated call to my_init_dynamic_array()
Mark my_dir() memory thread specific.
Use my_pthread_setspecific_ptr(THR_THD,...) to mark that allocated memory should be allocated to calling thread.
More DBUG.
Added malloc_size and examined_row_count to SHOW PROCESSLIST.
Added MY_THREAD_SPECIFIC to allocated memory.
Updated call to init_sql_alloc()
Added parameter to warning_info() that it should be fully initialized.
sql/sql_statistics.cc:
Fixed compiler warning
sql/sql_string.cc:
String elements can now be marked as thread specific.
sql/sql_string.h:
String elements can now be marked as thread specific.
sql/sql_table.cc:
Updated call to init_sql_alloc() and my_malloc() to mark memory thread specific
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Fixed compiler warning
sql/sql_test.cc:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_trigger.cc:
Updated call to init_sql_alloc()
sql/sql_udf.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_update.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/table.cc:
Updated call to init_sql_alloc().
Mark memory used by temporary tables, that are not for slave threads, as MY_THREAD_SPECIFIC
Updated call to init_sql_alloc()
sql/thr_malloc.cc:
Added my_flags argument to init_sql_alloc() to be able to mark memory as MY_THREAD_SPECIFIC.
sql/thr_malloc.h:
Updated prototype for init_sql_alloc()
sql/tztime.cc:
Updated call to init_sql_alloc()
Updated call to init_alloc_root() to mark memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/uniques.cc:
Updated calls to init_tree(), my_init_dynamic_array() and my_malloc() to mark memory thread specific.
sql/unireg.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/csv/ha_tina.cc:
Updated call to init_alloc_root()
storage/federated/ha_federated.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Ensure that memory allocated by fedarated is registered for the system, not for the thread.
storage/federatedx/federatedx_io_mysql.cc:
Updated call to my_init_dynamic_array()
storage/federatedx/ha_federatedx.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
storage/heap/ha_heap.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/heap/heapdef.h:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_block.c:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_create.c:
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Use MY_TREE_WITH_DELETE instead of removed option 'with_delete'.
storage/heap/hp_open.c:
Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
storage/heap/hp_write.c:
Added new parameter to hp_get_new_block()
storage/maria/ma_bitmap.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_blockrec.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_check.c:
Updated call to init_alloc_root()
storage/maria/ma_ft_boolean_search.c:
Updated calls to init_tree() and init_alloc_root()
storage/maria/ma_ft_nlq_search.c:
Updated call to init_tree()
storage/maria/ma_ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/maria/ma_loghandler.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_open.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_sort.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_write.c:
Updated calls to my_init_dynamic_array() and init_tree()
storage/maria/maria_pack.c:
Updated call to init_tree()
storage/maria/unittest/sequence_storage.c:
Updated call to my_init_dynamic_array()
storage/myisam/ft_boolean_search.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_nlq_search.c:
Updated call to init_tree()
storage/myisam/ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_stopwords.c:
Updated call to init_tree()
storage/myisam/mi_check.c:
Updated call to init_alloc_root()
storage/myisam/mi_write.c:
Updated call to my_init_dynamic_array()
Updated call to init_tree()
storage/myisam/myisamlog.c:
Updated call to init_tree()
storage/myisam/myisampack.c:
Updated call to init_tree()
storage/myisam/sort.c:
Updated call to my_init_dynamic_array()
storage/myisammrg/ha_myisammrg.cc:
Updated call to init_sql_alloc()
storage/perfschema/pfs_check.cc:
Rest current_thd
storage/perfschema/pfs_instr.cc:
Removed DBUG_ENTER/DBUG_VOID_RETURN as at this point my_thread_var is not allocated anymore, which can cause problems.
support-files/compiler_warnings.supp:
Disable compiler warning from offsetof macro.
2013-01-23 16:16:14 +01:00
|
|
|
|
2006-07-13 10:59:58 +02:00
|
|
|
pre_init_event_thread(new_thd);
|
2006-07-12 10:37:30 +02:00
|
|
|
new_thd->system_thread= SYSTEM_THREAD_EVENT_SCHEDULER;
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
new_thd->set_command(COM_DAEMON);
|
2006-07-12 10:37:30 +02:00
|
|
|
|
Patch for BUG#31111: --read-only crashes MySQL (events fail to load).
There actually were several problems here:
- WRITE-lock is required to load events from the mysql.event table,
but in the read-only mode an ordinary user can not acquire it;
- Security_context::master_access attribute was not properly
initialized in Security_context::init(), which led to differences
in behavior with and without debug configure options.
- if the server failed to load events from mysql.event, it forgot to
close the mysql.event table, that led to the coredump, described
in the bug report.
The patch is to fix all these problems:
- Use the super-user to acquire WRITE-lock on the mysql.even table;
- The WRITE-lock is acquired by the event scheduler in two cases:
- on initial loading of events from the database;
- when an event has been executed, so its attributes should
be updated.
Other cases when WRITE-lock is needed for the mysql.event table
happen under the user account. So, nothing should be changed there
for the read-only mode. The user is able to create/update/drop
an event only if he is a super-user.
- Initialize Security_context::master_access;
- Close the mysql.event table in case something went wrong.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/t/events_bugs.test:
A test case for BUG#31111: --read-only crashes MySQL (events fail
to load).
sql/event_data_objects.cc:
When the worker thread is going to drop event after the execution
we should do it under the super-user privileges in order to be able
to lock the mysql.event table for writing in the read-only mode.
This is a system operation, where user SQL can not be executed.
So, there is no risk in compromising security by dropping an event
under the super-user privileges.
sql/event_db_repository.cc:
1. Close tables if something went wrong in simple_open_n_lock_tables();
2. As soon as the system event scheduler thread is running under
the super-user privileges, we should always be able to acquire
WRITE-lock on the mysql.event table. However, let's have an assert
to check this.
sql/event_scheduler.cc:
Run the system event scheduler thread under the super-user privileges.
In particular, this is needed to be able to lock the mysql.event table
for writing when the server is running in the read-only mode.
The event scheduler executes only system operations and does not
execute user SQL (this is what the worker threads for). So, there
is no risk in compromising security by running the event scheduler
under the super-user privileges.
sql/events.cc:
Open the mysql.event table as the super user to be able to acquire
WRITE-lock in the read-only mode.
sql/sql_class.cc:
Initialize Security_context::master_acces.
2007-10-19 17:57:08 +02:00
|
|
|
/*
|
|
|
|
We should run the event scheduler thread under the super-user privileges.
|
|
|
|
In particular, this is needed to be able to lock the mysql.event table
|
|
|
|
for writing when the server is running in the read-only mode.
|
2012-10-01 13:15:29 +02:00
|
|
|
|
|
|
|
Same goes for transaction access mode. Set it to read-write for this thd.
|
Patch for BUG#31111: --read-only crashes MySQL (events fail to load).
There actually were several problems here:
- WRITE-lock is required to load events from the mysql.event table,
but in the read-only mode an ordinary user can not acquire it;
- Security_context::master_access attribute was not properly
initialized in Security_context::init(), which led to differences
in behavior with and without debug configure options.
- if the server failed to load events from mysql.event, it forgot to
close the mysql.event table, that led to the coredump, described
in the bug report.
The patch is to fix all these problems:
- Use the super-user to acquire WRITE-lock on the mysql.even table;
- The WRITE-lock is acquired by the event scheduler in two cases:
- on initial loading of events from the database;
- when an event has been executed, so its attributes should
be updated.
Other cases when WRITE-lock is needed for the mysql.event table
happen under the user account. So, nothing should be changed there
for the read-only mode. The user is able to create/update/drop
an event only if he is a super-user.
- Initialize Security_context::master_access;
- Close the mysql.event table in case something went wrong.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/t/events_bugs.test:
A test case for BUG#31111: --read-only crashes MySQL (events fail
to load).
sql/event_data_objects.cc:
When the worker thread is going to drop event after the execution
we should do it under the super-user privileges in order to be able
to lock the mysql.event table for writing in the read-only mode.
This is a system operation, where user SQL can not be executed.
So, there is no risk in compromising security by dropping an event
under the super-user privileges.
sql/event_db_repository.cc:
1. Close tables if something went wrong in simple_open_n_lock_tables();
2. As soon as the system event scheduler thread is running under
the super-user privileges, we should always be able to acquire
WRITE-lock on the mysql.event table. However, let's have an assert
to check this.
sql/event_scheduler.cc:
Run the system event scheduler thread under the super-user privileges.
In particular, this is needed to be able to lock the mysql.event table
for writing when the server is running in the read-only mode.
The event scheduler executes only system operations and does not
execute user SQL (this is what the worker threads for). So, there
is no risk in compromising security by running the event scheduler
under the super-user privileges.
sql/events.cc:
Open the mysql.event table as the super user to be able to acquire
WRITE-lock in the read-only mode.
sql/sql_class.cc:
Initialize Security_context::master_acces.
2007-10-19 17:57:08 +02:00
|
|
|
*/
|
2020-02-28 18:59:01 +01:00
|
|
|
new_thd->security_ctx->master_access |= PRIV_IGNORE_READ_ONLY;
|
2012-08-07 06:25:15 +02:00
|
|
|
new_thd->variables.tx_read_only= false;
|
|
|
|
new_thd->tx_read_only= false;
|
Patch for BUG#31111: --read-only crashes MySQL (events fail to load).
There actually were several problems here:
- WRITE-lock is required to load events from the mysql.event table,
but in the read-only mode an ordinary user can not acquire it;
- Security_context::master_access attribute was not properly
initialized in Security_context::init(), which led to differences
in behavior with and without debug configure options.
- if the server failed to load events from mysql.event, it forgot to
close the mysql.event table, that led to the coredump, described
in the bug report.
The patch is to fix all these problems:
- Use the super-user to acquire WRITE-lock on the mysql.even table;
- The WRITE-lock is acquired by the event scheduler in two cases:
- on initial loading of events from the database;
- when an event has been executed, so its attributes should
be updated.
Other cases when WRITE-lock is needed for the mysql.event table
happen under the user account. So, nothing should be changed there
for the read-only mode. The user is able to create/update/drop
an event only if he is a super-user.
- Initialize Security_context::master_access;
- Close the mysql.event table in case something went wrong.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/t/events_bugs.test:
A test case for BUG#31111: --read-only crashes MySQL (events fail
to load).
sql/event_data_objects.cc:
When the worker thread is going to drop event after the execution
we should do it under the super-user privileges in order to be able
to lock the mysql.event table for writing in the read-only mode.
This is a system operation, where user SQL can not be executed.
So, there is no risk in compromising security by dropping an event
under the super-user privileges.
sql/event_db_repository.cc:
1. Close tables if something went wrong in simple_open_n_lock_tables();
2. As soon as the system event scheduler thread is running under
the super-user privileges, we should always be able to acquire
WRITE-lock on the mysql.event table. However, let's have an assert
to check this.
sql/event_scheduler.cc:
Run the system event scheduler thread under the super-user privileges.
In particular, this is needed to be able to lock the mysql.event table
for writing when the server is running in the read-only mode.
The event scheduler executes only system operations and does not
execute user SQL (this is what the worker threads for). So, there
is no risk in compromising security by running the event scheduler
under the super-user privileges.
sql/events.cc:
Open the mysql.event table as the super user to be able to acquire
WRITE-lock in the read-only mode.
sql/sql_class.cc:
Initialize Security_context::master_acces.
2007-10-19 17:57:08 +02:00
|
|
|
|
MDEV-4011 Added per thread memory counting and usage
Base code and idea from a patch from by plinux at Taobao.
The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC.
Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc().
There are plenty of new asserts to ensure that for a debug server the counting is correct.
Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS.
- The later is there mainly to show how query is progressing.
The following changes in interfaces was needed to get this to work:
- init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root()
- my_init_dynamic_array() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- Added flag for hash_init() so that one can mark hash table to be thread specific.
- Added flags to init_tree() so that one can mark tree to be thread specific.
- Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
- Added flag to Warning_info::Warning_info() if the structure should be fully initialized.
- String elements can now be marked as thread specific.
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Changed type of myf from int to ulong, as this is always a set of bit flags.
Other things:
- Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
- We now also show EXAMINED_ROWS in SHOW PROCESSLIST
- Added new variable 'memory_used'
- Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
- Removed calls to the obsoleted function init_dynamic_array()
- Use set_current_thd() instead of my_pthread_setspecific_ptr(THR_THD,...)
client/completion_hash.cc:
Updated call to init_alloc_root()
client/mysql.cc:
Updated call to init_alloc_root()
client/mysqlbinlog.cc:
init_dynamic_array() -> my_init_dynamic_array()
Updated call to init_alloc_root()
client/mysqlcheck.c:
Updated call to my_init_dynamic_array()
client/mysqldump.c:
Updated call to init_alloc_root()
client/mysqltest.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Fixed compiler warnings
extra/comp_err.c:
Updated call to my_init_dynamic_array()
extra/resolve_stack_dump.c:
Updated call to my_init_dynamic_array()
include/hash.h:
Added HASH_THREAD_SPECIFIC
include/heap.h:
Added flag is internal temporary table.
include/my_dir.h:
Safety fix: Ensure that MY_DONT_SORT and MY_WANT_STAT don't interfer with other mysys flags
include/my_global.h:
Changed type of myf from int to ulong, as this is always a set of bit flags.
include/my_sys.h:
Added MY_THREAD_SPECIFIC and MY_THREAD_MOVE
Added malloc_flags to DYNAMIC_ARRAY
Added extra mysys flag argument to my_init_dynamic_array()
Removed deprecated functions init_dynamic_array() and my_init_dynamic_array.._ci
Updated paramaters for init_alloc_root()
include/my_tree.h:
Added my_flags to allow one to use MY_THREAD_SPECIFIC with hash tables.
Removed with_delete. One should now instead use MY_TREE_WITH_DELETE_FLAG
Updated parameters to init_tree()
include/myisamchk.h:
Added malloc_flags to allow one to use MY_THREAD_SPECIFIC for checks.
include/mysql.h:
Added MYSQL_THREAD_SPECIFIC_MALLOC
Used 'unused1' to mark memory as thread specific.
include/mysql.h.pp:
Updated file
include/mysql_com.h:
Used 'unused1' to mark memory as thread specific.
Updated parameters for my_net_init()
libmysql/libmysql.c:
Updated call to init_alloc_root() to mark memory thread specific.
libmysqld/emb_qcache.cc:
Updated call to init_alloc_root()
libmysqld/lib_sql.cc:
Updated call to init_alloc_root()
mysql-test/r/create.result:
Updated results
mysql-test/r/user_var.result:
Updated results
mysql-test/suite/funcs_1/datadict/processlist_priv.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/is_columns_is.result:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result:
Updated results
mysql-test/suite/funcs_1/r/processlist_val_no_prot.result:
Updated results
mysql-test/t/show_explain.test:
Fixed usage of debug variable so that one can run test with --debug
mysql-test/t/user_var.test:
Added test of memory_usage variable.
mysys/array.c:
Added extra my_flags option to init_dynamic_array() and init_dynamic_array2() so that one can mark memory with MY_THREAD_SPECIFIC
All allocated memory is marked with the given my_flags.
Removed obsolete function init_dynamic_array()
mysys/default.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
mysys/hash.c:
Updated call to my_init_dynamic_array_ci().
Allocated memory is marked with MY_THREAD_SPECIFIC if HASH_THREAD_SPECIFIC is used.
mysys/ma_dyncol.c:
init_dynamic_array() -> my_init_dynamic_array()
Added #if to get rid of compiler warnings
mysys/mf_tempdir.c:
Updated call to my_init_dynamic_array()
mysys/my_alloc.c:
Added extra parameter to init_alloc_root() so that one can mark memory with MY_THREAD_SPECIFIC
Extend MEM_ROOT with a flag if memory is thread specific.
This is stored in block_size, to keep the size of the MEM_ROOT object identical as before.
Allocated memory is marked with MY_THREAD_SPECIFIC if used with init_alloc_root()
mysys/my_chmod.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_chsize.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_copy.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_create.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_delete.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_error.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fopen.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fstream.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_getwd.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_lib.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Updated DBUG_PRINT because of change of myf type
mysys/my_lock.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_malloc.c:
Store at start of each allocated memory block the size of the block and if the block is thread specific.
Call malloc_size_cb_func, if set, with the memory allocated/freed.
Updated DBUG_PRINT because of change of myf type
mysys/my_open.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_pread.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_read.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_redel.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_rename.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_seek.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_sync.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_thr_init.c:
Ensure that one can call my_thread_dbug_id() even if thread is not properly initialized.
mysys/my_write.c:
Updated DBUG_PRINT because of change of myf type
mysys/mysys_priv.h:
Updated parameters to sf_malloc and sf_realloc()
mysys/safemalloc.c:
Added checking that for memory marked with MY_THREAD_SPECIFIC that it's the same thread that is allocation and freeing the memory.
Added sf_malloc_dbug_id() to allow MariaDB to specify which THD is handling the memory.
Added my_flags arguments to sf_malloc() and sf_realloc() to be able to mark memory with MY_THREAD_SPECIFIC.
Added sf_report_leaked_memory() to get list of memory not freed by a thread.
mysys/tree.c:
Added flags to init_tree() so that one can mark tree to be thread specific.
Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
Updated call to init_alloc_root()
All allocated memory is marked with the given malloc flags
mysys/waiting_threads.c:
Updated call to my_init_dynamic_array()
sql-common/client.c:
Updated call to init_alloc_root() and my_net_init() to mark memory thread specific.
Updated call to my_init_dynamic_array().
Added MYSQL_THREAD_SPECIFIC_MALLOC so that client can mark memory as MY_THREAD_SPECIFIC.
sql-common/client_plugin.c:
Updated call to init_alloc_root()
sql/debug_sync.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/event_scheduler.cc:
Removed calls to net_end() as this is now done in ~THD()
Call set_current_thd() to ensure that memory is assigned to right thread.
sql/events.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/filesort.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/filesort_utils.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/ha_ndbcluster.cc:
Updated call to init_alloc_root()
Updated call to my_net_init()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_ndbcluster_binlog.cc:
Updated call to my_net_init()
Updated call to init_sql_alloc()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_partition.cc:
Updated call to init_alloc_root()
sql/handler.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
Added missing call to my_dir_end()
sql/item_func.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_subselect.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_sum.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/log.cc:
More DBUG
Updated call to init_alloc_root()
sql/mdl.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/mysqld.cc:
Added total_memory_used
Updated call to init_alloc_root()
Move mysql_cond_broadcast() before my_thread_end()
Added mariadb_dbug_id() to count memory per THD instead of per thread.
Added my_malloc_size_cb_func() callback function for my_malloc() to count memory.
Move initialization of mysqld_server_started and mysqld_server_initialized earlier.
Updated call to my_init_dynamic_array().
Updated call to my_net_init().
Call my_pthread_setspecific_ptr(THR_THD,...) to ensure that memory is assigned to right thread.
Added status variable 'memory_used'.
Updated call to init_alloc_root()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/mysqld.h:
Added set_current_thd()
sql/net_serv.cc:
Added new parameter to my_net_init() so that one can mark memory with MY_THREAD_SPECIFIC.
Store in net->thread_specific_malloc if memory is thread specific.
Mark memory to be thread specific if requested.
sql/opt_range.cc:
Updated call to my_init_dynamic_array()
Updated call to init_sql_alloc()
Added MY_THREAD_SPECIFIC to allocated memory.
sql/opt_subselect.cc:
Updated call to init_sql_alloc() to mark memory thread specific.
sql/protocol.cc:
Fixed compiler warning
sql/records.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/rpl_filter.cc:
Updated call to my_init_dynamic_array()
sql/rpl_handler.cc:
Updated call to my_init_dynamic_array2()
sql/rpl_handler.h:
Updated call to init_sql_alloc()
sql/rpl_mi.cc:
Updated call to my_init_dynamic_array()
sql/rpl_tblmap.cc:
Updated call to init_alloc_root()
sql/rpl_utility.cc:
Updated call to my_init_dynamic_array()
sql/slave.cc:
Initialize things properly before calling functions that allocate memory.
Removed calls to net_end() as this is now done in ~THD()
sql/sp_head.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
Added parameter to warning_info() that it should be fully initialized.
sql/sp_pcontext.cc:
Updated call to my_init_dynamic_array()
sql/sql_acl.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_admin.cc:
Added parameter to warning_info() that it should be fully initialized.
sql/sql_analyse.h:
Updated call to init_tree() to mark memory thread specific.
sql/sql_array.h:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_audit.cc:
Updated call to my_init_dynamic_array()
sql/sql_base.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_cache.cc:
Updated comment
sql/sql_class.cc:
Added parameter to warning_info() that not initialize it until THD is fully created.
Updated call to init_sql_alloc()
Mark THD::user_vars has to be thread specific.
Updated call to my_init_dynamic_array()
Ensure that memory allocated by THD is assigned to the THD.
More DBUG
Always acll net_end() in ~THD()
Assert that all memory signed to this THD is really deleted at ~THD.
Fixed set_status_var_init() to not reset memory_used.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_class.h:
Added MY_THREAD_SPECIFIC to allocated memory.
Added malloc_size to THD to record allocated memory per THD.
sql/sql_delete.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_error.cc:
Added 'initialize' parameter to Warning_info() to say if should allocate memory for it's structures.
This is used by THD::THD() to not allocate memory until THD is ready.
Added Warning_info::free_memory()
sql/sql_error.h:
Updated Warning_info() class.
sql/sql_handler.cc:
Updated call to init_alloc_root() to mark memory thread specific.
sql/sql_insert.cc:
More DBUG
sql/sql_join_cache.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_lex.cc:
Updated call to my_init_dynamic_array()
sql/sql_lex.h:
Updated call to my_init_dynamic_array()
sql/sql_load.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_parse.cc:
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
Ensure that examined_row_count() is reset before query.
Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Don't restore thd->status_var.memory_used when restoring thd->status_var
sql/sql_plugin.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Don't allocate THD on the stack, as this causes problems with valgrind when doing thd memory counting.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_prepare.cc:
Added parameter to warning_info() that it should be fully initialized.
Updated call to init_sql_alloc() to mark memory thread specific.
sql/sql_reload.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_select.cc:
Updated call to my_init_dynamic_array() and init_sql_alloc() to mark memory thread specific.
Added MY_THREAD_SPECIFIC to allocated memory.
More DBUG
sql/sql_servers.cc:
Updated call to init_sql_alloc() to mark memory some memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_show.cc:
Updated call to my_init_dynamic_array()
Mark my_dir() memory thread specific.
Use my_pthread_setspecific_ptr(THR_THD,...) to mark that allocated memory should be allocated to calling thread.
More DBUG.
Added malloc_size and examined_row_count to SHOW PROCESSLIST.
Added MY_THREAD_SPECIFIC to allocated memory.
Updated call to init_sql_alloc()
Added parameter to warning_info() that it should be fully initialized.
sql/sql_statistics.cc:
Fixed compiler warning
sql/sql_string.cc:
String elements can now be marked as thread specific.
sql/sql_string.h:
String elements can now be marked as thread specific.
sql/sql_table.cc:
Updated call to init_sql_alloc() and my_malloc() to mark memory thread specific
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Fixed compiler warning
sql/sql_test.cc:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_trigger.cc:
Updated call to init_sql_alloc()
sql/sql_udf.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_update.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/table.cc:
Updated call to init_sql_alloc().
Mark memory used by temporary tables, that are not for slave threads, as MY_THREAD_SPECIFIC
Updated call to init_sql_alloc()
sql/thr_malloc.cc:
Added my_flags argument to init_sql_alloc() to be able to mark memory as MY_THREAD_SPECIFIC.
sql/thr_malloc.h:
Updated prototype for init_sql_alloc()
sql/tztime.cc:
Updated call to init_sql_alloc()
Updated call to init_alloc_root() to mark memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/uniques.cc:
Updated calls to init_tree(), my_init_dynamic_array() and my_malloc() to mark memory thread specific.
sql/unireg.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/csv/ha_tina.cc:
Updated call to init_alloc_root()
storage/federated/ha_federated.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Ensure that memory allocated by fedarated is registered for the system, not for the thread.
storage/federatedx/federatedx_io_mysql.cc:
Updated call to my_init_dynamic_array()
storage/federatedx/ha_federatedx.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
storage/heap/ha_heap.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/heap/heapdef.h:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_block.c:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_create.c:
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Use MY_TREE_WITH_DELETE instead of removed option 'with_delete'.
storage/heap/hp_open.c:
Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
storage/heap/hp_write.c:
Added new parameter to hp_get_new_block()
storage/maria/ma_bitmap.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_blockrec.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_check.c:
Updated call to init_alloc_root()
storage/maria/ma_ft_boolean_search.c:
Updated calls to init_tree() and init_alloc_root()
storage/maria/ma_ft_nlq_search.c:
Updated call to init_tree()
storage/maria/ma_ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/maria/ma_loghandler.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_open.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_sort.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_write.c:
Updated calls to my_init_dynamic_array() and init_tree()
storage/maria/maria_pack.c:
Updated call to init_tree()
storage/maria/unittest/sequence_storage.c:
Updated call to my_init_dynamic_array()
storage/myisam/ft_boolean_search.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_nlq_search.c:
Updated call to init_tree()
storage/myisam/ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_stopwords.c:
Updated call to init_tree()
storage/myisam/mi_check.c:
Updated call to init_alloc_root()
storage/myisam/mi_write.c:
Updated call to my_init_dynamic_array()
Updated call to init_tree()
storage/myisam/myisamlog.c:
Updated call to init_tree()
storage/myisam/myisampack.c:
Updated call to init_tree()
storage/myisam/sort.c:
Updated call to my_init_dynamic_array()
storage/myisammrg/ha_myisammrg.cc:
Updated call to init_sql_alloc()
storage/perfschema/pfs_check.cc:
Rest current_thd
storage/perfschema/pfs_instr.cc:
Removed DBUG_ENTER/DBUG_VOID_RETURN as at this point my_thread_var is not allocated anymore, which can cause problems.
support-files/compiler_warnings.supp:
Disable compiler warning from offsetof macro.
2013-01-23 16:16:14 +01:00
|
|
|
/* This should not be marked with MY_THREAD_SPECIFIC */
|
2006-07-13 10:59:58 +02:00
|
|
|
scheduler_param_value=
|
2020-01-29 13:50:26 +01:00
|
|
|
(struct scheduler_param *)my_malloc(key_memory_Event_scheduler_scheduler_param,
|
|
|
|
sizeof(struct scheduler_param), MYF(0));
|
2006-07-13 10:59:58 +02:00
|
|
|
scheduler_param_value->thd= new_thd;
|
|
|
|
scheduler_param_value->scheduler= this;
|
2006-07-12 10:37:30 +02:00
|
|
|
|
2006-08-31 17:18:39 +02:00
|
|
|
scheduler_thd= new_thd;
|
|
|
|
DBUG_PRINT("info", ("Setting state go RUNNING"));
|
|
|
|
state= RUNNING;
|
2017-09-19 19:45:17 +02:00
|
|
|
DBUG_PRINT("info", ("Forking new thread for scheduler. THD: %p", new_thd));
|
2013-07-24 12:14:41 +02:00
|
|
|
if ((*err_no= mysql_thread_create(key_thread_event_scheduler,
|
|
|
|
&th, &connection_attrib,
|
|
|
|
event_scheduler_thread,
|
|
|
|
(void*)scheduler_param_value)))
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
|
|
|
DBUG_PRINT("error", ("cannot create a new thread"));
|
2013-07-24 12:14:41 +02:00
|
|
|
sql_print_error("Event scheduler: Failed to start scheduler,"
|
|
|
|
" Can not create thread for event scheduler (errno=%d)",
|
|
|
|
*err_no);
|
2006-07-12 10:37:30 +02:00
|
|
|
|
|
|
|
state= INITIALIZED;
|
2006-08-31 17:18:39 +02:00
|
|
|
scheduler_thd= NULL;
|
2017-02-28 12:23:44 +01:00
|
|
|
deinit_event_thread(new_thd);
|
2006-07-12 10:37:30 +02:00
|
|
|
|
2013-07-24 12:14:41 +02:00
|
|
|
delete scheduler_param_value;
|
|
|
|
ret= true;
|
2006-07-12 10:37:30 +02:00
|
|
|
}
|
2013-07-24 12:14:41 +02:00
|
|
|
|
2006-08-31 17:18:39 +02:00
|
|
|
end:
|
|
|
|
UNLOCK_DATA();
|
2006-07-12 10:37:30 +02:00
|
|
|
DBUG_RETURN(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
The main loop of the scheduler.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_scheduler::run()
|
|
|
|
thd Thread
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
FALSE OK
|
|
|
|
TRUE Error (Serious error)
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool
|
|
|
|
Event_scheduler::run(THD *thd)
|
|
|
|
{
|
2006-08-17 14:22:59 +02:00
|
|
|
int res= FALSE;
|
2006-07-12 10:37:30 +02:00
|
|
|
DBUG_ENTER("Event_scheduler::run");
|
|
|
|
|
2007-03-23 17:14:08 +01:00
|
|
|
sql_print_information("Event Scheduler: scheduler thread started with id %lu",
|
2016-02-01 11:45:39 +01:00
|
|
|
(ulong) thd->thread_id);
|
2006-07-12 10:37:30 +02:00
|
|
|
/*
|
|
|
|
Recalculate the values in the queue because there could have been stops
|
|
|
|
in executions of the scheduler and some times could have passed by.
|
|
|
|
*/
|
|
|
|
queue->recalculate_activation_times(thd);
|
2006-08-31 17:18:39 +02:00
|
|
|
|
|
|
|
while (is_running())
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
2007-01-29 18:46:29 +01:00
|
|
|
Event_queue_element_for_exec *event_name;
|
|
|
|
|
2006-07-12 10:37:30 +02:00
|
|
|
/* Gets a minimized version */
|
2007-01-29 18:46:29 +01:00
|
|
|
if (queue->get_top_for_execution_if_time(thd, &event_name))
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
2007-03-23 17:14:08 +01:00
|
|
|
sql_print_information("Event Scheduler: "
|
|
|
|
"Serious error during getting next "
|
2006-08-31 17:18:39 +02:00
|
|
|
"event to execute. Stopping");
|
2006-07-12 10:37:30 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-03-02 00:39:00 +01:00
|
|
|
DBUG_PRINT("info", ("get_top_for_execution_if_time returned "
|
2017-09-19 19:45:17 +02:00
|
|
|
"event_name=%p", event_name));
|
2007-01-29 18:46:29 +01:00
|
|
|
if (event_name)
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
2007-03-23 16:14:03 +01:00
|
|
|
if ((res= execute_top(event_name)))
|
2006-08-31 17:18:39 +02:00
|
|
|
break;
|
2006-07-12 10:37:30 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-08-31 17:18:39 +02:00
|
|
|
DBUG_ASSERT(thd->killed);
|
|
|
|
DBUG_PRINT("info", ("job_data is NULL, the thread was killed"));
|
2006-07-12 10:37:30 +02:00
|
|
|
}
|
|
|
|
DBUG_PRINT("info", ("state=%s", scheduler_states_names[state].str));
|
|
|
|
}
|
2007-04-06 17:44:14 +02:00
|
|
|
|
2006-08-31 17:18:39 +02:00
|
|
|
LOCK_DATA();
|
2007-04-06 17:44:14 +02:00
|
|
|
scheduler_thd= NULL;
|
2006-07-12 10:37:30 +02:00
|
|
|
state= INITIALIZED;
|
2010-04-14 09:30:57 +02:00
|
|
|
DBUG_PRINT("info", ("Broadcasting COND_state back to the stoppers"));
|
|
|
|
mysql_cond_broadcast(&COND_state);
|
2006-07-13 16:24:55 +02:00
|
|
|
UNLOCK_DATA();
|
2006-07-12 10:37:30 +02:00
|
|
|
|
|
|
|
DBUG_RETURN(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Creates a new THD instance and then forks a new thread, while passing
|
|
|
|
the THD pointer and job_data to it.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_scheduler::execute_top()
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
FALSE OK
|
|
|
|
TRUE Error (Serious error)
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool
|
2007-03-23 16:14:03 +01:00
|
|
|
Event_scheduler::execute_top(Event_queue_element_for_exec *event_name)
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
|
|
|
THD *new_thd;
|
|
|
|
pthread_t th;
|
|
|
|
int res= 0;
|
|
|
|
DBUG_ENTER("Event_scheduler::execute_top");
|
MDEV-4011 Added per thread memory counting and usage
Base code and idea from a patch from by plinux at Taobao.
The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC.
Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc().
There are plenty of new asserts to ensure that for a debug server the counting is correct.
Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS.
- The later is there mainly to show how query is progressing.
The following changes in interfaces was needed to get this to work:
- init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root()
- my_init_dynamic_array() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- Added flag for hash_init() so that one can mark hash table to be thread specific.
- Added flags to init_tree() so that one can mark tree to be thread specific.
- Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
- Added flag to Warning_info::Warning_info() if the structure should be fully initialized.
- String elements can now be marked as thread specific.
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Changed type of myf from int to ulong, as this is always a set of bit flags.
Other things:
- Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
- We now also show EXAMINED_ROWS in SHOW PROCESSLIST
- Added new variable 'memory_used'
- Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
- Removed calls to the obsoleted function init_dynamic_array()
- Use set_current_thd() instead of my_pthread_setspecific_ptr(THR_THD,...)
client/completion_hash.cc:
Updated call to init_alloc_root()
client/mysql.cc:
Updated call to init_alloc_root()
client/mysqlbinlog.cc:
init_dynamic_array() -> my_init_dynamic_array()
Updated call to init_alloc_root()
client/mysqlcheck.c:
Updated call to my_init_dynamic_array()
client/mysqldump.c:
Updated call to init_alloc_root()
client/mysqltest.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Fixed compiler warnings
extra/comp_err.c:
Updated call to my_init_dynamic_array()
extra/resolve_stack_dump.c:
Updated call to my_init_dynamic_array()
include/hash.h:
Added HASH_THREAD_SPECIFIC
include/heap.h:
Added flag is internal temporary table.
include/my_dir.h:
Safety fix: Ensure that MY_DONT_SORT and MY_WANT_STAT don't interfer with other mysys flags
include/my_global.h:
Changed type of myf from int to ulong, as this is always a set of bit flags.
include/my_sys.h:
Added MY_THREAD_SPECIFIC and MY_THREAD_MOVE
Added malloc_flags to DYNAMIC_ARRAY
Added extra mysys flag argument to my_init_dynamic_array()
Removed deprecated functions init_dynamic_array() and my_init_dynamic_array.._ci
Updated paramaters for init_alloc_root()
include/my_tree.h:
Added my_flags to allow one to use MY_THREAD_SPECIFIC with hash tables.
Removed with_delete. One should now instead use MY_TREE_WITH_DELETE_FLAG
Updated parameters to init_tree()
include/myisamchk.h:
Added malloc_flags to allow one to use MY_THREAD_SPECIFIC for checks.
include/mysql.h:
Added MYSQL_THREAD_SPECIFIC_MALLOC
Used 'unused1' to mark memory as thread specific.
include/mysql.h.pp:
Updated file
include/mysql_com.h:
Used 'unused1' to mark memory as thread specific.
Updated parameters for my_net_init()
libmysql/libmysql.c:
Updated call to init_alloc_root() to mark memory thread specific.
libmysqld/emb_qcache.cc:
Updated call to init_alloc_root()
libmysqld/lib_sql.cc:
Updated call to init_alloc_root()
mysql-test/r/create.result:
Updated results
mysql-test/r/user_var.result:
Updated results
mysql-test/suite/funcs_1/datadict/processlist_priv.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/is_columns_is.result:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result:
Updated results
mysql-test/suite/funcs_1/r/processlist_val_no_prot.result:
Updated results
mysql-test/t/show_explain.test:
Fixed usage of debug variable so that one can run test with --debug
mysql-test/t/user_var.test:
Added test of memory_usage variable.
mysys/array.c:
Added extra my_flags option to init_dynamic_array() and init_dynamic_array2() so that one can mark memory with MY_THREAD_SPECIFIC
All allocated memory is marked with the given my_flags.
Removed obsolete function init_dynamic_array()
mysys/default.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
mysys/hash.c:
Updated call to my_init_dynamic_array_ci().
Allocated memory is marked with MY_THREAD_SPECIFIC if HASH_THREAD_SPECIFIC is used.
mysys/ma_dyncol.c:
init_dynamic_array() -> my_init_dynamic_array()
Added #if to get rid of compiler warnings
mysys/mf_tempdir.c:
Updated call to my_init_dynamic_array()
mysys/my_alloc.c:
Added extra parameter to init_alloc_root() so that one can mark memory with MY_THREAD_SPECIFIC
Extend MEM_ROOT with a flag if memory is thread specific.
This is stored in block_size, to keep the size of the MEM_ROOT object identical as before.
Allocated memory is marked with MY_THREAD_SPECIFIC if used with init_alloc_root()
mysys/my_chmod.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_chsize.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_copy.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_create.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_delete.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_error.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fopen.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fstream.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_getwd.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_lib.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Updated DBUG_PRINT because of change of myf type
mysys/my_lock.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_malloc.c:
Store at start of each allocated memory block the size of the block and if the block is thread specific.
Call malloc_size_cb_func, if set, with the memory allocated/freed.
Updated DBUG_PRINT because of change of myf type
mysys/my_open.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_pread.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_read.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_redel.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_rename.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_seek.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_sync.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_thr_init.c:
Ensure that one can call my_thread_dbug_id() even if thread is not properly initialized.
mysys/my_write.c:
Updated DBUG_PRINT because of change of myf type
mysys/mysys_priv.h:
Updated parameters to sf_malloc and sf_realloc()
mysys/safemalloc.c:
Added checking that for memory marked with MY_THREAD_SPECIFIC that it's the same thread that is allocation and freeing the memory.
Added sf_malloc_dbug_id() to allow MariaDB to specify which THD is handling the memory.
Added my_flags arguments to sf_malloc() and sf_realloc() to be able to mark memory with MY_THREAD_SPECIFIC.
Added sf_report_leaked_memory() to get list of memory not freed by a thread.
mysys/tree.c:
Added flags to init_tree() so that one can mark tree to be thread specific.
Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
Updated call to init_alloc_root()
All allocated memory is marked with the given malloc flags
mysys/waiting_threads.c:
Updated call to my_init_dynamic_array()
sql-common/client.c:
Updated call to init_alloc_root() and my_net_init() to mark memory thread specific.
Updated call to my_init_dynamic_array().
Added MYSQL_THREAD_SPECIFIC_MALLOC so that client can mark memory as MY_THREAD_SPECIFIC.
sql-common/client_plugin.c:
Updated call to init_alloc_root()
sql/debug_sync.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/event_scheduler.cc:
Removed calls to net_end() as this is now done in ~THD()
Call set_current_thd() to ensure that memory is assigned to right thread.
sql/events.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/filesort.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/filesort_utils.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/ha_ndbcluster.cc:
Updated call to init_alloc_root()
Updated call to my_net_init()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_ndbcluster_binlog.cc:
Updated call to my_net_init()
Updated call to init_sql_alloc()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_partition.cc:
Updated call to init_alloc_root()
sql/handler.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
Added missing call to my_dir_end()
sql/item_func.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_subselect.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_sum.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/log.cc:
More DBUG
Updated call to init_alloc_root()
sql/mdl.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/mysqld.cc:
Added total_memory_used
Updated call to init_alloc_root()
Move mysql_cond_broadcast() before my_thread_end()
Added mariadb_dbug_id() to count memory per THD instead of per thread.
Added my_malloc_size_cb_func() callback function for my_malloc() to count memory.
Move initialization of mysqld_server_started and mysqld_server_initialized earlier.
Updated call to my_init_dynamic_array().
Updated call to my_net_init().
Call my_pthread_setspecific_ptr(THR_THD,...) to ensure that memory is assigned to right thread.
Added status variable 'memory_used'.
Updated call to init_alloc_root()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/mysqld.h:
Added set_current_thd()
sql/net_serv.cc:
Added new parameter to my_net_init() so that one can mark memory with MY_THREAD_SPECIFIC.
Store in net->thread_specific_malloc if memory is thread specific.
Mark memory to be thread specific if requested.
sql/opt_range.cc:
Updated call to my_init_dynamic_array()
Updated call to init_sql_alloc()
Added MY_THREAD_SPECIFIC to allocated memory.
sql/opt_subselect.cc:
Updated call to init_sql_alloc() to mark memory thread specific.
sql/protocol.cc:
Fixed compiler warning
sql/records.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/rpl_filter.cc:
Updated call to my_init_dynamic_array()
sql/rpl_handler.cc:
Updated call to my_init_dynamic_array2()
sql/rpl_handler.h:
Updated call to init_sql_alloc()
sql/rpl_mi.cc:
Updated call to my_init_dynamic_array()
sql/rpl_tblmap.cc:
Updated call to init_alloc_root()
sql/rpl_utility.cc:
Updated call to my_init_dynamic_array()
sql/slave.cc:
Initialize things properly before calling functions that allocate memory.
Removed calls to net_end() as this is now done in ~THD()
sql/sp_head.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
Added parameter to warning_info() that it should be fully initialized.
sql/sp_pcontext.cc:
Updated call to my_init_dynamic_array()
sql/sql_acl.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_admin.cc:
Added parameter to warning_info() that it should be fully initialized.
sql/sql_analyse.h:
Updated call to init_tree() to mark memory thread specific.
sql/sql_array.h:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_audit.cc:
Updated call to my_init_dynamic_array()
sql/sql_base.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_cache.cc:
Updated comment
sql/sql_class.cc:
Added parameter to warning_info() that not initialize it until THD is fully created.
Updated call to init_sql_alloc()
Mark THD::user_vars has to be thread specific.
Updated call to my_init_dynamic_array()
Ensure that memory allocated by THD is assigned to the THD.
More DBUG
Always acll net_end() in ~THD()
Assert that all memory signed to this THD is really deleted at ~THD.
Fixed set_status_var_init() to not reset memory_used.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_class.h:
Added MY_THREAD_SPECIFIC to allocated memory.
Added malloc_size to THD to record allocated memory per THD.
sql/sql_delete.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_error.cc:
Added 'initialize' parameter to Warning_info() to say if should allocate memory for it's structures.
This is used by THD::THD() to not allocate memory until THD is ready.
Added Warning_info::free_memory()
sql/sql_error.h:
Updated Warning_info() class.
sql/sql_handler.cc:
Updated call to init_alloc_root() to mark memory thread specific.
sql/sql_insert.cc:
More DBUG
sql/sql_join_cache.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_lex.cc:
Updated call to my_init_dynamic_array()
sql/sql_lex.h:
Updated call to my_init_dynamic_array()
sql/sql_load.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_parse.cc:
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
Ensure that examined_row_count() is reset before query.
Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Don't restore thd->status_var.memory_used when restoring thd->status_var
sql/sql_plugin.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Don't allocate THD on the stack, as this causes problems with valgrind when doing thd memory counting.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_prepare.cc:
Added parameter to warning_info() that it should be fully initialized.
Updated call to init_sql_alloc() to mark memory thread specific.
sql/sql_reload.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_select.cc:
Updated call to my_init_dynamic_array() and init_sql_alloc() to mark memory thread specific.
Added MY_THREAD_SPECIFIC to allocated memory.
More DBUG
sql/sql_servers.cc:
Updated call to init_sql_alloc() to mark memory some memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_show.cc:
Updated call to my_init_dynamic_array()
Mark my_dir() memory thread specific.
Use my_pthread_setspecific_ptr(THR_THD,...) to mark that allocated memory should be allocated to calling thread.
More DBUG.
Added malloc_size and examined_row_count to SHOW PROCESSLIST.
Added MY_THREAD_SPECIFIC to allocated memory.
Updated call to init_sql_alloc()
Added parameter to warning_info() that it should be fully initialized.
sql/sql_statistics.cc:
Fixed compiler warning
sql/sql_string.cc:
String elements can now be marked as thread specific.
sql/sql_string.h:
String elements can now be marked as thread specific.
sql/sql_table.cc:
Updated call to init_sql_alloc() and my_malloc() to mark memory thread specific
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Fixed compiler warning
sql/sql_test.cc:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_trigger.cc:
Updated call to init_sql_alloc()
sql/sql_udf.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_update.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/table.cc:
Updated call to init_sql_alloc().
Mark memory used by temporary tables, that are not for slave threads, as MY_THREAD_SPECIFIC
Updated call to init_sql_alloc()
sql/thr_malloc.cc:
Added my_flags argument to init_sql_alloc() to be able to mark memory as MY_THREAD_SPECIFIC.
sql/thr_malloc.h:
Updated prototype for init_sql_alloc()
sql/tztime.cc:
Updated call to init_sql_alloc()
Updated call to init_alloc_root() to mark memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/uniques.cc:
Updated calls to init_tree(), my_init_dynamic_array() and my_malloc() to mark memory thread specific.
sql/unireg.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/csv/ha_tina.cc:
Updated call to init_alloc_root()
storage/federated/ha_federated.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Ensure that memory allocated by fedarated is registered for the system, not for the thread.
storage/federatedx/federatedx_io_mysql.cc:
Updated call to my_init_dynamic_array()
storage/federatedx/ha_federatedx.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
storage/heap/ha_heap.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/heap/heapdef.h:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_block.c:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_create.c:
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Use MY_TREE_WITH_DELETE instead of removed option 'with_delete'.
storage/heap/hp_open.c:
Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
storage/heap/hp_write.c:
Added new parameter to hp_get_new_block()
storage/maria/ma_bitmap.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_blockrec.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_check.c:
Updated call to init_alloc_root()
storage/maria/ma_ft_boolean_search.c:
Updated calls to init_tree() and init_alloc_root()
storage/maria/ma_ft_nlq_search.c:
Updated call to init_tree()
storage/maria/ma_ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/maria/ma_loghandler.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_open.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_sort.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_write.c:
Updated calls to my_init_dynamic_array() and init_tree()
storage/maria/maria_pack.c:
Updated call to init_tree()
storage/maria/unittest/sequence_storage.c:
Updated call to my_init_dynamic_array()
storage/myisam/ft_boolean_search.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_nlq_search.c:
Updated call to init_tree()
storage/myisam/ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_stopwords.c:
Updated call to init_tree()
storage/myisam/mi_check.c:
Updated call to init_alloc_root()
storage/myisam/mi_write.c:
Updated call to my_init_dynamic_array()
Updated call to init_tree()
storage/myisam/myisamlog.c:
Updated call to init_tree()
storage/myisam/myisampack.c:
Updated call to init_tree()
storage/myisam/sort.c:
Updated call to my_init_dynamic_array()
storage/myisammrg/ha_myisammrg.cc:
Updated call to init_sql_alloc()
storage/perfschema/pfs_check.cc:
Rest current_thd
storage/perfschema/pfs_instr.cc:
Removed DBUG_ENTER/DBUG_VOID_RETURN as at this point my_thread_var is not allocated anymore, which can cause problems.
support-files/compiler_warnings.supp:
Disable compiler warning from offsetof macro.
2013-01-23 16:16:14 +01:00
|
|
|
|
2016-04-07 18:51:40 +02:00
|
|
|
if (!(new_thd= new THD(next_thread_id())))
|
2006-07-12 10:37:30 +02:00
|
|
|
goto error;
|
|
|
|
|
2006-07-13 10:59:58 +02:00
|
|
|
pre_init_event_thread(new_thd);
|
2006-07-12 10:37:30 +02:00
|
|
|
new_thd->system_thread= SYSTEM_THREAD_EVENT_WORKER;
|
2007-01-29 18:46:29 +01:00
|
|
|
event_name->thd= new_thd;
|
2007-03-02 00:39:00 +01:00
|
|
|
DBUG_PRINT("info", ("Event %s@%s ready for start",
|
2007-01-29 18:46:29 +01:00
|
|
|
event_name->dbname.str, event_name->name.str));
|
2006-07-12 10:37:30 +02:00
|
|
|
|
BUG#16420: Events: timestamps become UTC
BUG#26429: SHOW CREATE EVENT is incorrect for an event that
STARTS NOW()
BUG#26431: Impossible to re-create an event from backup if its
STARTS clause is in the past
WL#3698: Events: execution in local time zone
The problem was that local times specified by the user in AT, STARTS
and ENDS of CREATE EVENT/ALTER EVENT statement were converted to UTC,
and the original time zone was forgotten. This way, event scheduler
couldn't honor Daylight Saving Time shifts, and times shown to the
user were also in UTC. Additionally, CREATE EVENT didn't allow times
in the past, thus preventing straightforward event restoration from
old backups.
This patch reworks event scheduler time computations, performing them
in the time zone associated with the event. Also it allows times to
be in the past.
The patch adds time_zone column to mysql.event table.
NOTE: The patch is almost final, but the bug#9953 should be pushed
first.
client/mysqldump.c:
Before every CREATE EVENT, output its time zone.
mysql-test/include/wait_condition.inc:
Add optional $wait_timeout parameter.
mysql-test/lib/init_db.sql:
Add time_zone column.
mysql-test/r/events.result:
Update result.
mysql-test/r/events_bugs.result:
Update result.
mysql-test/r/events_grant.result:
Update result.
mysql-test/r/events_restart_phase1.result:
Update result.
mysql-test/r/events_scheduling.result:
Update result.
mysql-test/r/mysqldump.result:
Update result.
mysql-test/r/ps.result:
Update result.
mysql-test/r/system_mysql_db.result:
Update result.
mysql-test/t/events.test:
Remove STARTS from the result, as it depends on current time.
mysql-test/t/events_bugs.test:
Time in the past is no longer an error.
mysql-test/t/events_restart_phase1.test:
Fill new column 'time_zone' in mysql.event.
mysql-test/t/events_scheduling.test:
Cleanup: disable event scheduler.
scripts/mysql_create_system_tables.sh:
Add new column 'time_zone' to mysql.event.
scripts/mysql_fix_privilege_tables.sql:
Add new column 'time_zone' to mysql.event.
sql/event_data_objects.cc:
The essence of the change is the following:
- for internal times use my_time_t instead of TIME. Assignment and
comparison is done now on plain numbers.
- in init_execute_at(), init_starts(), init_ends() convert given time
to number of seconds since Epoch (aka Unix time, in UTC).
- handle time_zone field loading and storing.
- in get_next_time(), Unix time is converted back to event time zone,
interval is added, and the result is converted to UTC again.
- fix Event_timed::get_create_event() to report STARTS and ENDS.
- before executing the event body we set thread time zone to the
event time zone.
sql/event_data_objects.h:
Add time_zone member to Event_basic class.
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_db_repository.cc:
Add time_zone column handling.
Give a warning and do not create an event if its execution time is in
the past, and ON COMPLETION NOT PRESERVE is set, because such an event
should be dropped by that time. Also, do not allow ALTER EVENT to
set execution time in the past when ON COMPLETION NOT PRESERVE is set.
sql/event_db_repository.h:
Add enum member for new time zone column.
sql/event_queue.cc:
Replace handling of broken down times with simple handling of
my_time_t.
sql/event_queue.h:
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_scheduler.cc:
Add TODO comment.
sql/events.cc:
Send time_zone column for SHOW CREATE EVENT.
sql/share/errmsg.txt:
Update error message, and add two more errors.
sql/sql_show.cc:
Add TIME_ZONE column to the output of SHOW EVENTS.
mysql-test/r/events_time_zone.result:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/r/events_time_zone.result
mysql-test/t/events_time_zone.test:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/t/events_time_zone.test
2007-03-16 15:31:07 +01:00
|
|
|
/*
|
|
|
|
TODO: should use thread pool here, preferably with an upper limit
|
|
|
|
on number of threads: if too many events are scheduled for the
|
|
|
|
same time, starting all of them at once won't help them run truly
|
|
|
|
in parallel (because of the great amount of synchronization), so
|
|
|
|
we may as well execute them in sequence, keeping concurrency at a
|
|
|
|
reasonable level.
|
|
|
|
*/
|
2006-07-12 10:37:30 +02:00
|
|
|
/* Major failure */
|
2010-01-07 06:42:07 +01:00
|
|
|
if ((res= mysql_thread_create(key_thread_event_worker,
|
|
|
|
&th, &connection_attrib, event_worker_thread,
|
|
|
|
event_name)))
|
2013-07-24 12:14:41 +02:00
|
|
|
{
|
|
|
|
mysql_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
Events::opt_event_scheduler= Events::EVENTS_OFF;
|
|
|
|
mysql_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
|
|
|
|
sql_print_error("Event_scheduler::execute_top: Can not create event worker"
|
|
|
|
" thread (errno=%d). Stopping event scheduler", res);
|
|
|
|
|
2017-02-28 12:23:44 +01:00
|
|
|
deinit_event_thread(new_thd);
|
2006-07-12 10:37:30 +02:00
|
|
|
goto error;
|
2013-07-24 12:14:41 +02:00
|
|
|
}
|
2006-07-12 10:37:30 +02:00
|
|
|
|
2012-09-09 00:22:06 +02:00
|
|
|
started_events++;
|
|
|
|
executed_events++; // For SHOW STATUS
|
2006-08-31 17:18:39 +02:00
|
|
|
|
2017-09-19 19:45:17 +02:00
|
|
|
DBUG_PRINT("info", ("Event is in THD: %p", new_thd));
|
2006-07-12 10:37:30 +02:00
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
|
|
|
|
error:
|
2007-03-02 00:39:00 +01:00
|
|
|
DBUG_PRINT("error", ("Event_scheduler::execute_top() res: %d", res));
|
2007-01-29 18:46:29 +01:00
|
|
|
delete event_name;
|
2006-07-12 10:37:30 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-31 17:18:39 +02:00
|
|
|
/*
|
2006-09-01 14:08:50 +02:00
|
|
|
Checks whether the state of the scheduler is RUNNING
|
2006-08-31 17:18:39 +02:00
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_scheduler::is_running()
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
TRUE RUNNING
|
|
|
|
FALSE Not RUNNING
|
|
|
|
*/
|
|
|
|
|
2006-09-01 14:15:47 +02:00
|
|
|
bool
|
2006-08-31 17:18:39 +02:00
|
|
|
Event_scheduler::is_running()
|
|
|
|
{
|
|
|
|
LOCK_DATA();
|
|
|
|
bool ret= (state == RUNNING);
|
|
|
|
UNLOCK_DATA();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-23 16:14:03 +01:00
|
|
|
/**
|
2006-07-13 16:24:55 +02:00
|
|
|
Stops the scheduler (again). Waits for acknowledgement from the
|
|
|
|
scheduler that it has stopped - synchronous stopping.
|
2006-07-12 10:37:30 +02:00
|
|
|
|
A set of changes aiming to make the Event Scheduler more user-friendly
when there are no up-to-date system tables to support it:
- initialize the scheduler before reporting "Ready for connections".
This ensures that warnings, if any, are printed before "Ready for
connections", and this message is not mangled.
- do not abort the scheduler if there are no system tables
- check the tables once at start up, remember the status and disable
the scheduler if the tables are not up to date.
If one attempts to use the scheduler with bad tables,
issue an error message.
- clean up the behaviour of the module under LOCK TABLES and pre-locking
mode
- make sure implicit commit of Events DDL works as expected.
- add more tests
Collateral clean ups in the events code.
This patch fixes Bug#23631 Events: SHOW VARIABLES doesn't work
when mysql.event is damaged
mysql-test/r/events.result:
Update results.
mysql-test/r/events_bugs.result:
Update results.
mysql-test/r/events_restart_phase1.result:
Update results.
mysql-test/r/events_restart_phase2.result:
Update results.
mysql-test/r/events_restart_phase3.result:
Update results.
mysql-test/r/events_scheduling.result:
Update results.
mysql-test/r/events_time_zone.result:
Update results.
mysql-test/t/events.test:
Add new tests for tampering with mysql.event and some more
tests for sub-statements, LOCK TABLES mode and pre-locking.
mysql-test/t/events_bugs.test:
Move the non-concurrent part of test for Bug 16420 to this file.
mysql-test/t/events_restart_phase1.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase2.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase3.test:
Rewrite events_restart_* tests to take into account that now
we check mysql.event table only once, at server startup.
mysql-test/t/events_scheduling.test:
Add more coverage for event_scheduler global variable.
mysql-test/t/events_time_zone.test:
Move the non-concurrent part of the tests for Bug 16420 to
events_bugs.test
sql/event_data_objects.cc:
Move update_timing_fields functionality to Event_db_repository.
Make loading of events from a table record more robust to tampering
with the table - now we do not check mysql.event on every table open.
sql/event_data_objects.h:
Cleanup.
sql/event_db_repository.cc:
Now Event_db_repository is responsible for table I/O only.
All the logic of events DDL is handled outside, in Events class please
refer to the added test coverage to see how this change affected
the behavior of Event Scheduler.
Dependency on sp_head.h and sp.h removed.
Make this module robust to tweaks with mysql.event table.
Move check_system_tables from events.cc to this file
sql/event_db_repository.h:
Cleanup declarations (remove unused ones, change return type to bool
from int).
sql/event_queue.cc:
Update to adapt to the new start up scheme of the Event Scheduler.
sql/event_queue.h:
Cleanup declarations.
sql/event_scheduler.cc:
Make all the error messages uniform:
[SEVERITY] Event Scheduler: [user][schema.event] message
Using append_identifier for error logging was an overkill - we may
need it only if the system character set may have NUL (null character)
as part of a valid identifier, this is currently never the case,
whereas additional quoting did not look nice in the log.
sql/event_scheduler.h:
Cleanup the headers.
sql/events.cc:
Use a different start up procedure of Event Scheduler:
- at start up, try to check the system tables first.
If they are not up-to-date, disable the scheduler.
- try to load all the active events. In case of a load error, abort
start up.
- do not parse an event on start up. Parsing only gives some information
about event validity, but far not all.
Consolidate the business logic of Events DDL in this module.
Now opt_event_scheduler may change after start up and thus is protected
by LOCK_event_metadata mutex.
sql/events.h:
Use all-static-data-members approach to implement Singleton pattern.
sql/mysqld.cc:
New invocation scheme of Events. Move some logic to events.cc.
Initialize the scheduler before reporting "Ready for connections".
sql/set_var.cc:
Clean up sys_var_thd_sql_mode::symbolic_mode_representation
to work with a LEX_STRING.
Move more logic related to @@events_scheduler global variable to Events
module.
sql/set_var.h:
Update declarations.
sql/share/errmsg.txt:
If someone tampered with mysql.event table after the server has
started we no longer give him/her a complete report what was actually
broken. Do not send the user to look at the error log in such case,
as there is nothing there (check_table_intact is not executed).
sql/sp_head.cc:
Update to a new declaration of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_db.cc:
New invocation scheme of Events module.
sql/sql_parse.cc:
Move more logic to Events module. Make sure that we are consistent
in the way access rights are checked for Events DDL: always
after committing the current transaction and checking the system tables.
sql/sql_show.cc:
Update to the new declarations of
sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_test.cc:
New invocation scheme of events.
sql/table.cc:
mysql.event is a system table.
Update check_table_intact to be concurrent, more verbose, and less smart.
sql/table.h:
Add a helper method.
mysql-test/r/events_trans.result:
New BitKeeper file ``mysql-test/r/events_trans.result''
mysql-test/t/events_trans.test:
New BitKeeper file ``mysql-test/t/events_trans.test'':
test cases for Event Scheduler that require a transactional
storage engine.
2007-04-05 13:24:34 +02:00
|
|
|
Already running events will not be stopped. If the user needs
|
|
|
|
them stopped manual intervention is needed.
|
|
|
|
|
2006-07-12 10:37:30 +02:00
|
|
|
SYNOPSIS
|
2006-07-13 16:24:55 +02:00
|
|
|
Event_scheduler::stop()
|
2006-07-12 10:37:30 +02:00
|
|
|
|
|
|
|
RETURN VALUE
|
2006-07-13 16:24:55 +02:00
|
|
|
FALSE OK
|
|
|
|
TRUE Error (not reported)
|
2006-07-12 10:37:30 +02:00
|
|
|
*/
|
|
|
|
|
2006-07-13 16:24:55 +02:00
|
|
|
bool
|
|
|
|
Event_scheduler::stop()
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
2006-07-13 16:24:55 +02:00
|
|
|
THD *thd= current_thd;
|
|
|
|
DBUG_ENTER("Event_scheduler::stop");
|
2017-09-19 19:45:17 +02:00
|
|
|
DBUG_PRINT("enter", ("thd: %p", thd));
|
2006-07-13 16:24:55 +02:00
|
|
|
|
|
|
|
LOCK_DATA();
|
2006-11-27 00:47:38 +01:00
|
|
|
DBUG_PRINT("info", ("state before action %s", scheduler_states_names[state].str));
|
2006-07-13 16:24:55 +02:00
|
|
|
if (state != RUNNING)
|
2009-10-13 20:29:28 +02:00
|
|
|
{
|
|
|
|
/* Synchronously wait until the scheduler stops. */
|
|
|
|
while (state != INITIALIZED)
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
COND_STATE_WAIT(thd, NULL, &stage_waiting_for_scheduler_to_stop);
|
2006-07-13 16:24:55 +02:00
|
|
|
goto end;
|
2009-10-13 20:29:28 +02:00
|
|
|
}
|
2006-07-13 16:24:55 +02:00
|
|
|
|
|
|
|
/* Guarantee we don't catch spurious signals */
|
|
|
|
do {
|
2007-03-23 17:14:08 +01:00
|
|
|
DBUG_PRINT("info", ("Waiting for COND_started_or_stopped from "
|
|
|
|
"the scheduler thread. Current value of state is %s . "
|
2006-07-13 16:24:55 +02:00
|
|
|
"workers count=%d", scheduler_states_names[state].str,
|
|
|
|
workers_count()));
|
2006-08-31 17:18:39 +02:00
|
|
|
/*
|
|
|
|
NOTE: We don't use kill_one_thread() because it can't kill COM_DEAMON
|
|
|
|
threads. In addition, kill_one_thread() requires THD but during shutdown
|
|
|
|
current_thd is NULL. Hence, if kill_one_thread should be used it has to
|
|
|
|
be modified to kill also daemons, by adding a flag, and also we have to
|
|
|
|
create artificial THD here. To save all this work, we just do what
|
|
|
|
kill_one_thread() does to kill a thread. See also sql_repl.cc for similar
|
|
|
|
usage.
|
|
|
|
*/
|
|
|
|
|
|
|
|
state= STOPPING;
|
2007-03-23 17:14:08 +01:00
|
|
|
DBUG_PRINT("info", ("Scheduler thread has id %lu",
|
2016-02-01 11:45:39 +01:00
|
|
|
(ulong) scheduler_thd->thread_id));
|
2006-08-31 17:18:39 +02:00
|
|
|
/* This will wake up the thread if it waits on Queue's conditional */
|
2007-03-23 17:14:08 +01:00
|
|
|
sql_print_information("Event Scheduler: Killing the scheduler thread, "
|
|
|
|
"thread id %lu",
|
2016-02-01 11:45:39 +01:00
|
|
|
(ulong) scheduler_thd->thread_id);
|
2011-09-23 00:13:38 +02:00
|
|
|
scheduler_thd->awake(KILL_CONNECTION);
|
2006-08-31 17:18:39 +02:00
|
|
|
|
2006-07-13 16:24:55 +02:00
|
|
|
/* thd could be 0x0, when shutting down */
|
2007-03-23 17:14:08 +01:00
|
|
|
sql_print_information("Event Scheduler: "
|
|
|
|
"Waiting for the scheduler thread to reply");
|
2011-05-09 14:14:04 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Wait only 2 seconds, as there is a small chance the thread missed the
|
|
|
|
above awake() call and we may have to do it again
|
|
|
|
*/
|
|
|
|
struct timespec top_time;
|
|
|
|
set_timespec(top_time, 2);
|
2013-01-31 09:48:19 +01:00
|
|
|
COND_STATE_WAIT(thd, &top_time, &stage_waiting_for_scheduler_to_stop);
|
2006-07-13 16:24:55 +02:00
|
|
|
} while (state == STOPPING);
|
2007-03-23 17:14:08 +01:00
|
|
|
DBUG_PRINT("info", ("Scheduler thread has cleaned up. Set state to INIT"));
|
2007-04-06 17:44:14 +02:00
|
|
|
sql_print_information("Event Scheduler: Stopped");
|
2006-07-13 16:24:55 +02:00
|
|
|
end:
|
|
|
|
UNLOCK_DATA();
|
|
|
|
DBUG_RETURN(FALSE);
|
2006-07-12 10:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Returns the number of living event worker threads.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_scheduler::workers_count()
|
|
|
|
*/
|
|
|
|
|
2019-01-19 23:32:35 +01:00
|
|
|
static my_bool workers_count_callback(THD *thd, uint32_t *count)
|
|
|
|
{
|
|
|
|
if (thd->system_thread == SYSTEM_THREAD_EVENT_WORKER)
|
|
|
|
++*count;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-12 10:37:30 +02:00
|
|
|
uint
|
|
|
|
Event_scheduler::workers_count()
|
|
|
|
{
|
2019-01-19 23:32:35 +01:00
|
|
|
uint32_t count= 0;
|
2006-07-12 10:37:30 +02:00
|
|
|
DBUG_ENTER("Event_scheduler::workers_count");
|
2019-01-19 23:32:35 +01:00
|
|
|
server_threads.iterate(workers_count_callback, &count);
|
2006-07-12 10:37:30 +02:00
|
|
|
DBUG_RETURN(count);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Auxiliary function for locking LOCK_scheduler_state. Used
|
2006-07-13 16:24:55 +02:00
|
|
|
by the LOCK_DATA macro.
|
2006-07-12 10:37:30 +02:00
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_scheduler::lock_data()
|
|
|
|
func Which function is requesting mutex lock
|
|
|
|
line On which line mutex lock is requested
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
Event_scheduler::lock_data(const char *func, uint line)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("Event_scheduler::lock_data");
|
|
|
|
DBUG_PRINT("enter", ("func=%s line=%u", func, line));
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_scheduler_state);
|
2006-07-12 10:37:30 +02:00
|
|
|
mutex_last_locked_in_func= func;
|
|
|
|
mutex_last_locked_at_line= line;
|
|
|
|
mutex_scheduler_data_locked= TRUE;
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Auxiliary function for unlocking LOCK_scheduler_state. Used
|
2006-07-13 16:24:55 +02:00
|
|
|
by the UNLOCK_DATA macro.
|
2006-07-12 10:37:30 +02:00
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_scheduler::unlock_data()
|
|
|
|
func Which function is requesting mutex unlock
|
|
|
|
line On which line mutex unlock is requested
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
Event_scheduler::unlock_data(const char *func, uint line)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("Event_scheduler::unlock_data");
|
|
|
|
DBUG_PRINT("enter", ("func=%s line=%u", func, line));
|
|
|
|
mutex_last_unlocked_at_line= line;
|
|
|
|
mutex_scheduler_data_locked= FALSE;
|
|
|
|
mutex_last_unlocked_in_func= func;
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_scheduler_state);
|
2006-07-12 10:37:30 +02:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2010-01-12 02:47:27 +01:00
|
|
|
Wrapper for mysql_cond_wait/timedwait
|
2006-07-12 10:37:30 +02:00
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_scheduler::cond_wait()
|
2006-07-17 16:52:45 +02:00
|
|
|
thd Thread (Could be NULL during shutdown procedure)
|
2010-01-12 02:47:27 +01:00
|
|
|
abstime If not null then call mysql_cond_timedwait()
|
2006-08-31 17:18:39 +02:00
|
|
|
msg Message for thd->proc_info
|
2006-07-17 16:52:45 +02:00
|
|
|
func Which function is requesting cond_wait
|
|
|
|
line On which line cond_wait is requested
|
2006-07-12 10:37:30 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
Event_scheduler::cond_wait(THD *thd, struct timespec *abstime, const PSI_stage_info *stage,
|
|
|
|
const char *src_func, const char *src_file, uint src_line)
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
2006-07-17 16:52:45 +02:00
|
|
|
DBUG_ENTER("Event_scheduler::cond_wait");
|
2006-07-12 10:37:30 +02:00
|
|
|
waiting_on_cond= TRUE;
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
mutex_last_unlocked_at_line= src_line;
|
2006-07-12 10:37:30 +02:00
|
|
|
mutex_scheduler_data_locked= FALSE;
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
mutex_last_unlocked_in_func= src_func;
|
2006-07-17 16:52:45 +02:00
|
|
|
if (thd)
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
thd->enter_cond(&COND_state, &LOCK_scheduler_state, stage,
|
|
|
|
NULL, src_func, src_file, src_line);
|
2006-07-17 16:52:45 +02:00
|
|
|
|
2010-01-12 02:47:27 +01:00
|
|
|
DBUG_PRINT("info", ("mysql_cond_%swait", abstime? "timed":""));
|
2006-07-13 16:24:55 +02:00
|
|
|
if (!abstime)
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_cond_wait(&COND_state, &LOCK_scheduler_state);
|
2006-07-13 16:24:55 +02:00
|
|
|
else
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_cond_timedwait(&COND_state, &LOCK_scheduler_state, abstime);
|
2006-07-17 16:52:45 +02:00
|
|
|
if (thd)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
This will free the lock so we need to relock. Not the best thing to
|
|
|
|
do but we need to obey cond_wait()
|
|
|
|
*/
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
thd->exit_cond(NULL, src_func, src_file, src_line);
|
2006-07-17 16:52:45 +02:00
|
|
|
LOCK_DATA();
|
|
|
|
}
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
mutex_last_locked_in_func= src_func;
|
|
|
|
mutex_last_locked_at_line= src_line;
|
2006-07-12 10:37:30 +02:00
|
|
|
mutex_scheduler_data_locked= TRUE;
|
|
|
|
waiting_on_cond= FALSE;
|
2006-07-17 16:52:45 +02:00
|
|
|
DBUG_VOID_RETURN;
|
2006-07-13 16:24:55 +02:00
|
|
|
}
|
2006-07-12 10:37:30 +02:00
|
|
|
|
2006-07-13 16:24:55 +02:00
|
|
|
|
2006-07-12 10:37:30 +02:00
|
|
|
/*
|
|
|
|
Dumps the internal status of the scheduler
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_scheduler::dump_internal_status()
|
|
|
|
*/
|
|
|
|
|
2006-09-12 12:26:12 +02:00
|
|
|
void
|
|
|
|
Event_scheduler::dump_internal_status()
|
2006-07-12 10:37:30 +02:00
|
|
|
{
|
|
|
|
DBUG_ENTER("Event_scheduler::dump_internal_status");
|
|
|
|
|
2006-09-12 12:26:12 +02:00
|
|
|
puts("");
|
|
|
|
puts("Event scheduler status:");
|
|
|
|
printf("State : %s\n", scheduler_states_names[state].str);
|
2016-02-01 11:45:39 +01:00
|
|
|
printf("Thread id : %lu\n", scheduler_thd ?
|
|
|
|
(ulong) scheduler_thd->thread_id : (ulong) 0);
|
2006-09-12 12:26:12 +02:00
|
|
|
printf("LLA : %s:%u\n", mutex_last_locked_in_func,
|
|
|
|
mutex_last_locked_at_line);
|
|
|
|
printf("LUA : %s:%u\n", mutex_last_unlocked_in_func,
|
|
|
|
mutex_last_unlocked_at_line);
|
|
|
|
printf("WOC : %s\n", waiting_on_cond? "YES":"NO");
|
|
|
|
printf("Workers : %u\n", workers_count());
|
2006-11-27 17:16:08 +01:00
|
|
|
printf("Executed : %lu\n", (ulong) started_events);
|
2006-09-12 12:26:12 +02:00
|
|
|
printf("Data locked: %s\n", mutex_scheduler_data_locked ? "YES":"NO");
|
2006-07-12 10:37:30 +02:00
|
|
|
|
2006-09-12 12:26:12 +02:00
|
|
|
DBUG_VOID_RETURN;
|
2006-07-12 10:37:30 +02:00
|
|
|
}
|
2007-08-15 17:08:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
@} (End of group Event_Scheduler)
|
|
|
|
*/
|