@ -1,7 +1,7 @@
/*****************************************************************************
Copyright ( c ) 2009 , 2018 , Oracle and / or its affiliates . All Rights Reserved .
Copyright ( c ) 2015 , 2018 , MariaDB Corporation .
Copyright ( c ) 2015 , 2019 , MariaDB Corporation .
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 the Free Software
@ -283,8 +283,7 @@ dict_stats_exec_sql(
dberr_t err ;
bool trx_started = false ;
ut_ad ( rw_lock_own ( dict_operation_lock , RW_LOCK_X ) ) ;
ut_ad ( mutex_own ( & dict_sys . mutex ) ) ;
ut_d ( dict_sys . assert_locked ( ) ) ;
if ( ! dict_stats_persistent_storage_check ( true ) ) {
pars_info_free ( pinfo ) ;
@ -2313,8 +2312,7 @@ dict_stats_save_index_stat(
char table_utf8 [ MAX_TABLE_UTF8_LEN ] ;
ut_ad ( ! trx | | trx - > internal | | trx - > mysql_thd ) ;
ut_ad ( rw_lock_own ( dict_operation_lock , RW_LOCK_X ) ) ;
ut_ad ( mutex_own ( & dict_sys . mutex ) ) ;
ut_d ( dict_sys . assert_locked ( ) ) ;
dict_fs2utf8 ( index - > table - > name . m_name , db_utf8 , sizeof ( db_utf8 ) ,
table_utf8 , sizeof ( table_utf8 ) ) ;
@ -2449,8 +2447,7 @@ dict_stats_save(
table_utf8 , sizeof ( table_utf8 ) ) ;
now = ut_time ( ) ;
rw_lock_x_lock ( dict_operation_lock ) ;
mutex_enter ( & dict_sys . mutex ) ;
dict_sys_lock ( ) ;
pinfo = pars_info_create ( ) ;
@ -2488,13 +2485,10 @@ dict_stats_save(
if ( ret ! = DB_SUCCESS ) {
ib : : error ( ) < < " Cannot save table statistics for table "
< < table - > name < < " : " < < ut_strerr ( ret ) ;
mutex_exit ( & dict_sys . mutex ) ;
rw_lock_x_unlock ( dict_operation_lock ) ;
func_exit :
dict_sys_unlock ( ) ;
dict_stats_snapshot_free ( table ) ;
return ( ret ) ;
return ret ;
}
trx_t * trx = trx_create ( ) ;
@ -2595,13 +2589,7 @@ dict_stats_save(
end :
trx_free ( trx ) ;
mutex_exit ( & dict_sys . mutex ) ;
rw_lock_x_unlock ( dict_operation_lock ) ;
dict_stats_snapshot_free ( table ) ;
return ( ret ) ;
goto func_exit ;
}
/*********************************************************************/ /**
@ -3406,8 +3394,7 @@ dict_stats_drop_index(
pars_info_add_str_literal ( pinfo , " index_name " , iname ) ;
rw_lock_x_lock ( dict_operation_lock ) ;
mutex_enter ( & dict_sys . mutex ) ;
dict_sys_lock ( ) ;
ret = dict_stats_exec_sql (
pinfo ,
@ -3419,8 +3406,7 @@ dict_stats_drop_index(
" index_name = :index_name; \n "
" END; \n " , NULL ) ;
mutex_exit ( & dict_sys . mutex ) ;
rw_lock_x_unlock ( dict_operation_lock ) ;
dict_sys_unlock ( ) ;
if ( ret = = DB_STATS_DO_NOT_EXIST ) {
ret = DB_SUCCESS ;
@ -3468,8 +3454,7 @@ dict_stats_delete_from_table_stats(
pars_info_t * pinfo ;
dberr_t ret ;
ut_ad ( rw_lock_own ( dict_operation_lock , RW_LOCK_X ) ) ;
ut_ad ( mutex_own ( & dict_sys . mutex ) ) ;
ut_d ( dict_sys . assert_locked ( ) ) ;
pinfo = pars_info_create ( ) ;
@ -3504,8 +3489,7 @@ dict_stats_delete_from_index_stats(
pars_info_t * pinfo ;
dberr_t ret ;
ut_ad ( rw_lock_own ( dict_operation_lock , RW_LOCK_X ) ) ;
ut_ad ( mutex_own ( & dict_sys . mutex ) ) ;
ut_d ( dict_sys . assert_locked ( ) ) ;
pinfo = pars_info_create ( ) ;
@ -3541,8 +3525,7 @@ dict_stats_drop_table(
char table_utf8 [ MAX_TABLE_UTF8_LEN ] ;
dberr_t ret ;
ut_ad ( rw_lock_own ( dict_operation_lock , RW_LOCK_X ) ) ;
ut_ad ( mutex_own ( & dict_sys . mutex ) ) ;
ut_d ( dict_sys . assert_locked ( ) ) ;
/* skip tables that do not contain a database name
e . g . if we are dropping SYS_TABLES */
@ -3617,8 +3600,7 @@ dict_stats_rename_table_in_table_stats(
pars_info_t * pinfo ;
dberr_t ret ;
ut_ad ( rw_lock_own ( dict_operation_lock , RW_LOCK_X ) ) ;
ut_ad ( mutex_own ( & dict_sys . mutex ) ) ;
ut_d ( dict_sys . assert_locked ( ) ) ;
pinfo = pars_info_create ( ) ;
@ -3661,8 +3643,7 @@ dict_stats_rename_table_in_index_stats(
pars_info_t * pinfo ;
dberr_t ret ;
ut_ad ( rw_lock_own ( dict_operation_lock , RW_LOCK_X ) ) ;
ut_ad ( mutex_own ( & dict_sys . mutex ) ) ;
ut_d ( dict_sys . assert_locked ( ) ) ;
pinfo = pars_info_create ( ) ;
@ -3705,9 +3686,6 @@ dict_stats_rename_table(
char new_table_utf8 [ MAX_TABLE_UTF8_LEN ] ;
dberr_t ret ;
ut_ad ( ! rw_lock_own ( dict_operation_lock , RW_LOCK_X ) ) ;
ut_ad ( ! mutex_own ( & dict_sys . mutex ) ) ;
/* skip innodb_table_stats and innodb_index_stats themselves */
if ( strcmp ( old_name , TABLE_STATS_NAME ) = = 0
| | strcmp ( old_name , INDEX_STATS_NAME ) = = 0
@ -3723,8 +3701,7 @@ dict_stats_rename_table(
dict_fs2utf8 ( new_name , new_db_utf8 , sizeof ( new_db_utf8 ) ,
new_table_utf8 , sizeof ( new_table_utf8 ) ) ;
rw_lock_x_lock ( dict_operation_lock ) ;
mutex_enter ( & dict_sys . mutex ) ;
dict_sys_lock ( ) ;
ulint n_attempts = 0 ;
do {
@ -3744,11 +3721,9 @@ dict_stats_rename_table(
}
if ( ret ! = DB_SUCCESS ) {
mutex_exit ( & dict_sys . mutex ) ;
rw_lock_x_unlock ( dict_operation_lock ) ;
dict_sys_unlock ( ) ;
os_thread_sleep ( 200000 /* 0.2 sec */ ) ;
rw_lock_x_lock ( dict_operation_lock ) ;
mutex_enter ( & dict_sys . mutex ) ;
dict_sys_lock ( ) ;
}
} while ( ( ret = = DB_DEADLOCK
| | ret = = DB_DUPLICATE_KEY
@ -3776,8 +3751,7 @@ dict_stats_rename_table(
TABLE_STATS_NAME_PRINT ,
new_db_utf8 , new_table_utf8 ,
old_db_utf8 , old_table_utf8 ) ;
mutex_exit ( & dict_sys . mutex ) ;
rw_lock_x_unlock ( dict_operation_lock ) ;
dict_sys_unlock ( ) ;
return ( ret ) ;
}
/* else */
@ -3800,19 +3774,16 @@ dict_stats_rename_table(
}
if ( ret ! = DB_SUCCESS ) {
mutex_exit ( & dict_sys . mutex ) ;
rw_lock_x_unlock ( dict_operation_lock ) ;
dict_sys_unlock ( ) ;
os_thread_sleep ( 200000 /* 0.2 sec */ ) ;
rw_lock_x_lock ( dict_operation_lock ) ;
mutex_enter ( & dict_sys . mutex ) ;
dict_sys_lock ( ) ;
}
} while ( ( ret = = DB_DEADLOCK
| | ret = = DB_DUPLICATE_KEY
| | ret = = DB_LOCK_WAIT_TIMEOUT )
& & n_attempts < 5 ) ;
mutex_exit ( & dict_sys . mutex ) ;
rw_lock_x_unlock ( dict_operation_lock ) ;
dict_sys_unlock ( ) ;
if ( ret ! = DB_SUCCESS ) {
snprintf ( errstr , errstr_sz ,
@ -3853,12 +3824,10 @@ dict_stats_rename_index(
const char * old_index_name , /*!< in: old index name */
const char * new_index_name ) /*!< in: new index name */
{
rw_lock_x_lock ( dict_operation_lock ) ;
mutex_enter ( & dict_sys . mutex ) ;
dict_sys_lock ( ) ;
if ( ! dict_stats_persistent_storage_check ( true ) ) {
mutex_exit ( & dict_sys . mutex ) ;
rw_lock_x_unlock ( dict_operation_lock ) ;
dict_sys_unlock ( ) ;
return ( DB_STATS_DO_NOT_EXIST ) ;
}
@ -3891,8 +3860,7 @@ dict_stats_rename_index(
" index_name = :old_index_name; \n "
" END; \n " , NULL ) ;
mutex_exit ( & dict_sys . mutex ) ;
rw_lock_x_unlock ( dict_operation_lock ) ;
dict_sys_unlock ( ) ;
return ( ret ) ;
}