4070 prabakaran thirumalai 2012-07-17
Bug#13032999 RPL.RPL_PARALLEL_DDL FAILS OCCASIONALLY ON PB2
Analysis:
During drop database, for all the files present in the db
directory, check is made to ensure that their extensions
belong to either mysql or underlying storage engines.
ha_known_exts() function gives list of all file extensions
of all underlying storage engines. Two global variables
known_extensions and known_extensions_id used in this
function are not guarded by mutex. Because of this, when two
connections try to drop database concurrently, both of them
may enter my_once_alloc() function call leaving
known_extensions.type_names structure in an inconsistent state.
This could either lead to drop database error or crash in
worst case.
Fix:
Global variables, known_extensions(cache of all extensions) and
known_extensions_id are removed. Caching of known_extensions
seems unnecessary and introduces new mutex to guard this structure.
Moreover, ha_known_exts() function is called only during drop
database statement which is a seldom used SQL statement.
As part of the fix, known_extensions is declared locally inside
find_db_tables_and_rm_known_files() function.
modified:
include/my_sys.h
mysys/my_init.c
sql/handler.cc
sql/handler.h
sql/sql_db.cc
4069 prabakaran thirumalai 2012-07-17
Bug#13002460 CRASH WHEN SHUTTING DOWN SERVER AND TOGGLING
EVENT_SCHEDULER AT RUNTIME
Analysis:
static objects declared in Events (events.cc) is not guarded
by mutex. This leads to race condition during shutdown.
Client connection thread which toggles EVENT_SCHEDULER calls
scheduler->start() or scheduler->stop() depending on the
flag set.
During shutdown, close_connections() calls Events::deinit()
from kill_server_thread, which destroys scheduler object
before waiting for all client connection threads to end.
This leads to scheduler->start() or scheduler->stop() being
called on destroyed scheduler object
Fix:
Moved Events::deinit() call after stopping all the client
connection threads.
Additional Notes:
No test case added because send_shutdown command of mtr
does not call Events::deinit(). Moreover scenario described
in the bug description cannot be synchronized using mtr
as they are two different process(mysqlslap and mysqladmin)
modified:
sql/events.cc
sql/mysqld.cc
=== modified file 'include/my_sys.h'
--- a/include/my_sys.h 2012-05-31 15:33:21 +0000
+++ b/include/my_sys.h 2012-07-17 11:40:27 +0000
@@ -251,7 +251,6 @@ extern CHARSET_INFO compiled_charsets[];
/* statistics */
extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
extern ulong my_file_total_opened;
-extern uint mysys_usage_id;
extern my_bool my_init_done;
/* Point to current my_message() */
=== modified file 'mysys/my_init.c'
--- a/mysys/my_init.c 2012-03-06 14:29:42 +0000
+++ b/mysys/my_init.c 2012-07-17 11:40:27 +0000
@@ -38,7 +38,6 @@ static my_bool win32_init_tcp_ip();
#define SCALE_USEC 10000
my_bool my_init_done= 0;
-uint mysys_usage_id= 0; /* Incremented for each my_init() */
ulong my_thread_stack_size= 65536;
static ulong atoi_octal(const char *str)
@@ -72,7 +71,6 @@ my_bool my_init(void)
my_init_done= 1;
- mysys_usage_id++;
my_umask= 0660; /* Default umask for new files */
my_umask_dir= 0700; /* Default umask for new directories */
=== modified file 'sql/handler.cc'
--- a/sql/handler.cc 2012-07-13 05:03:39 +0000
+++ b/sql/handler.cc 2012-07-17 11:40:27 +0000
@@ -103,9 +103,6 @@ const char *tx_isolation_names[] =
TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names)-1,"",
tx_isolation_names, NULL};
-static TYPELIB known_extensions= {0,"known_exts", NULL, NULL};
-uint known_extensions_id= 0;
-
#ifndef DBUG_OFF
const char *ha_legacy_type_name(legacy_db_type legacy_type)
@@ -6704,34 +6701,33 @@ static my_bool exts_handlerton(THD *unus
return FALSE;
}
-TYPELIB *ha_known_exts(void)
+TYPELIB* ha_known_exts()
{
- if (!known_extensions.type_names || mysys_usage_id != known_extensions_id)
- {
- List<char> found_exts;
- const char **ext, *old_ext;
+ TYPELIB *known_extensions = (TYPELIB*) sql_alloc(sizeof(TYPELIB));
+ known_extensions->name= "known_exts";
+ known_extensions->type_lengths= NULL;
+
+ List<char> found_exts;
+ const char **ext, *old_ext;
- known_extensions_id= mysys_usage_id;
- found_exts.push_back((char*) TRG_EXT);
- found_exts.push_back((char*) TRN_EXT);
-
- plugin_foreach(NULL, exts_handlerton,
- MYSQL_STORAGE_ENGINE_PLUGIN, &found_exts);
-
- ext= (const char **) my_once_alloc(sizeof(char *)*
- (found_exts.elements+1),
- MYF(MY_WME | MY_FAE));
-
- DBUG_ASSERT(ext != 0);
- known_extensions.count= found_exts.elements;
- known_extensions.type_names= ext;
-
- List_iterator_fast<char> it(found_exts);
- while ((old_ext= it++))
- *ext++= old_ext;
- *ext= 0;
- }
- return &known_extensions;
+ found_exts.push_back((char*) TRG_EXT);
+ found_exts.push_back((char*) TRN_EXT);
+
+ plugin_foreach(NULL, exts_handlerton,
+ MYSQL_STORAGE_ENGINE_PLUGIN, &found_exts);
+
+ size_t arr_length= sizeof(char *)* (found_exts.elements+1);
+ ext= (const char **) sql_alloc(arr_length);
+
+ DBUG_ASSERT(NULL != ext);
+ known_extensions->count= found_exts.elements;
+ known_extensions->type_names= ext;
+
+ List_iterator_fast<char> it(found_exts);
+ while ((old_ext= it++))
+ *ext++= old_ext;
+ *ext= NULL;
+ return known_extensions;
}
=== modified file 'sql/handler.h'
--- a/sql/handler.h 2012-07-16 07:21:48 +0000
+++ b/sql/handler.h 2012-07-17 11:40:27 +0000
@@ -3251,7 +3251,7 @@ int ha_end(void);
int ha_initialize_handlerton(st_plugin_int *plugin);
int ha_finalize_handlerton(st_plugin_int *plugin);
-TYPELIB *ha_known_exts(void);
+TYPELIB* ha_known_exts();
int ha_panic(enum ha_panic_function flag);
void ha_close_connection(THD* thd);
bool ha_flush_logs(handlerton *db_type);
=== modified file 'sql/sql_db.cc'
--- a/sql/sql_db.cc 2012-04-30 07:13:31 +0000
+++ b/sql/sql_db.cc 2012-07-17 11:40:27 +0000
@@ -1008,6 +1008,7 @@ static bool find_db_tables_and_rm_known_
TABLE_LIST *tot_list=0, **tot_list_next_local, **tot_list_next_global;
DBUG_ENTER("find_db_tables_and_rm_known_files");
DBUG_PRINT("enter",("path: %s", path));
+ TYPELIB *known_extensions= ha_known_exts();
tot_list_next_local= tot_list_next_global= &tot_list;
@@ -1049,8 +1050,8 @@ static bool find_db_tables_and_rm_known_
extension= strend(file->name);
if (find_type(extension, &deletable_extentions, FIND_TYPE_NO_PREFIX) <= 0)
{
- if (find_type(extension, ha_known_exts(), FIND_TYPE_NO_PREFIX) <= 0)
- *found_other_files= true;
+ if (find_type(extension, known_extensions, FIND_TYPE_NO_PREFIX) <= 0)
+ *found_other_files= true;
continue;
}
/* just for safety we use files_charset_info */
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (prabakaran.thirumalai:4069 to 4070)Bug#13032999 | prabakaran thirumalai | 17 Jul |