3421 Marc Alff 2011-09-21 [merge]
Local merge
modified:
sql/share/errmsg-utf8.txt
strings/dtoa.c
=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc 2011-09-14 15:03:55 +0000
+++ b/sql/sql_base.cc 2011-09-21 15:41:50 +0000
@@ -542,8 +542,6 @@ static void table_def_use_table(THD *thd
DBUG_ASSERT(table->db_stat && table->file);
/* The children must be detached from the table. */
DBUG_ASSERT(! table->file->extra(HA_EXTRA_IS_ATTACHED_CHILDREN));
-
- table->file->rebind_psi();
}
@@ -560,7 +558,6 @@ static void table_def_unuse_table(TABLE
DBUG_ASSERT(! table->s->has_old_version());
table->in_use= 0;
- table->file->unbind_psi();
/* Remove table from the list of tables used in this share. */
table->s->used_tables.remove(table);
@@ -1655,6 +1652,10 @@ bool close_thread_table(THD *thd, TABLE
table->file->ha_reset();
}
+ /* Do this *before* entering the LOCK_open critical section. */
+ if (table->file != NULL)
+ table->file->unbind_psi();
+
mysql_mutex_lock(&LOCK_open);
if (table->s->has_old_version() || table->needs_reopen() ||
@@ -2731,6 +2732,8 @@ bool open_table(THD *thd, TABLE_LIST *ta
int error;
TABLE_SHARE *share;
my_hash_value_type hash_value;
+ bool recycled_free_table;
+
DBUG_ENTER("open_table");
/*
@@ -3088,6 +3091,7 @@ retry_share:
{
table= share->free_tables.front();
table_def_use_table(thd, table);
+ recycled_free_table= true;
/* We need to release share as we have EXTRA reference to it in our hands. */
release_table_share(share);
}
@@ -3099,6 +3103,7 @@ retry_share:
mysql_mutex_unlock(&LOCK_open);
+ recycled_free_table= false;
/* make a new table */
if (!(table=(TABLE*) my_malloc(sizeof(*table),MYF(MY_WME))))
goto err_lock;
@@ -3140,6 +3145,13 @@ retry_share:
mysql_mutex_unlock(&LOCK_open);
+ /* Call rebind_psi outside of the LOCK_open critical section. */
+ if (recycled_free_table)
+ {
+ DBUG_ASSERT(table->file != NULL);
+ table->file->rebind_psi();
+ }
+
table->mdl_ticket= mdl_ticket;
table->next= thd->open_tables; /* Link into simple list */
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc 2011-09-14 10:42:54 +0000
+++ b/storage/perfschema/pfs.cc 2011-09-21 15:41:50 +0000
@@ -3710,6 +3710,8 @@ static void end_table_io_wait_v1(PSI_tab
insert_events_waits_history_long(wait);
thread->m_events_waits_count--;
}
+
+ table->m_has_io_stats= true;
}
/**
@@ -3787,6 +3789,8 @@ static void end_table_lock_wait_v1(PSI_t
insert_events_waits_history_long(wait);
thread->m_events_waits_count--;
}
+
+ table->m_has_lock_stats= true;
}
static void start_file_wait_v1(PSI_file_locker *locker,
=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc 2011-08-25 07:53:21 +0000
+++ b/storage/perfschema/pfs_instr.cc 2011-09-21 15:41:50 +0000
@@ -1302,6 +1302,8 @@ PFS_table* create_table(PFS_table_share
pfs->m_lock_enabled= share->m_enabled &&
flag_global_instrumentation && global_table_lock_class.m_enabled;
pfs->m_lock_timed= share->m_timed && global_table_lock_class.m_timed;
+ pfs->m_has_io_stats= false;
+ pfs->m_has_lock_stats= false;
share->inc_refcount();
pfs->m_table_stat.reset();
pfs->m_thread_owner= opening_thread;
@@ -1323,24 +1325,35 @@ void PFS_table::sanitized_aggregate(void
*/
PFS_table_share *safe_share= sanitize_table_share(m_share);
PFS_thread *safe_thread= sanitize_thread(m_thread_owner);
- if (safe_share != NULL && safe_thread != NULL)
+ if ((safe_share != NULL && safe_thread != NULL) &&
+ (m_has_io_stats || m_has_lock_stats))
+ {
safe_aggregate(& m_table_stat, safe_share, safe_thread);
+ m_has_io_stats= false;
+ m_has_lock_stats= false;
+ }
}
void PFS_table::sanitized_aggregate_io(void)
{
PFS_table_share *safe_share= sanitize_table_share(m_share);
PFS_thread *safe_thread= sanitize_thread(m_thread_owner);
- if (safe_share != NULL && safe_thread != NULL)
+ if (safe_share != NULL && safe_thread != NULL && m_has_io_stats)
+ {
safe_aggregate_io(& m_table_stat, safe_share, safe_thread);
+ m_has_io_stats= false;
+ }
}
void PFS_table::sanitized_aggregate_lock(void)
{
PFS_table_share *safe_share= sanitize_table_share(m_share);
PFS_thread *safe_thread= sanitize_thread(m_thread_owner);
- if (safe_share != NULL && safe_thread != NULL)
+ if (safe_share != NULL && safe_thread != NULL && m_has_lock_stats)
+ {
safe_aggregate_lock(& m_table_stat, safe_share, safe_thread);
+ m_has_lock_stats= false;
+ }
}
void PFS_table::safe_aggregate(PFS_table_stat *table_stat,
@@ -1357,11 +1370,17 @@ void PFS_table::safe_aggregate(PFS_table
uint index;
event_name_array= thread->m_instr_class_waits_stats;
- /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (for wait/io/table/sql/handler) */
+ /*
+ Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME
+ (for wait/io/table/sql/handler)
+ */
index= global_table_io_class.m_event_name_index;
table_stat->sum_io(& event_name_array[index]);
- /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (for wait/lock/table/sql/handler) */
+ /*
+ Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME
+ (for wait/lock/table/sql/handler)
+ */
index= global_table_lock_class.m_event_name_index;
table_stat->sum_lock(& event_name_array[index]);
}
@@ -1385,7 +1404,10 @@ void PFS_table::safe_aggregate_io(PFS_ta
uint index;
event_name_array= thread->m_instr_class_waits_stats;
- /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (for wait/io/table/sql/handler) */
+ /*
+ Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME
+ (for wait/io/table/sql/handler)
+ */
index= global_table_io_class.m_event_name_index;
table_stat->sum_io(& event_name_array[index]);
}
@@ -1409,7 +1431,10 @@ void PFS_table::safe_aggregate_lock(PFS_
uint index;
event_name_array= thread->m_instr_class_waits_stats;
- /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (for wait/lock/table/sql/handler) */
+ /*
+ Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME
+ (for wait/lock/table/sql/handler)
+ */
index= global_table_lock_class.m_event_name_index;
table_stat->sum_lock(& event_name_array[index]);
}
=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h 2011-09-13 20:58:14 +0000
+++ b/storage/perfschema/pfs_instr.h 2011-09-21 15:41:50 +0000
@@ -180,6 +180,12 @@ struct PFS_table
*/
bool m_lock_timed;
+ /** True if table io statistics have been collected. */
+ bool m_has_io_stats;
+
+ /** True if table lock statistics have been collected. */
+ bool m_has_lock_stats;
+
public:
/**
Aggregate this table handle statistics to the parents.
@@ -188,8 +194,12 @@ public:
*/
void aggregate(void)
{
- if (likely(m_thread_owner != NULL))
+ if (likely((m_thread_owner != NULL) && (m_has_io_stats || m_has_lock_stats)))
+ {
safe_aggregate(& m_table_stat, m_share, m_thread_owner);
+ m_has_io_stats= false;
+ m_has_lock_stats= false;
+ }
}
/**
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (marc.alff:3421) | Marc Alff | 22 Sep |