From: Christopher Powers Date: August 26 2010 4:47pm Subject: bzr push into mysql-trunk-bugfixing branch (chris.powers:3242 to 3243) List-Archive: http://lists.mysql.com/commits/116931 Message-Id: <20100826164743.193401DB0368@xeno.mysql.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7576153894378252614==" --===============7576153894378252614== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 3243 Christopher Powers 2010-08-26 [merge] merge modified: storage/perfschema/pfs.cc storage/perfschema/pfs_stat.h 3242 Jon Olav Hauglid 2010-08-26 Bug #56241 Valgrind/CDB warnings for many tests in trunk-bugfixing The reason for the warnings was that the performance schema instrumentation function release_table_share() could be called on a TABLE_SHARE that had already been free'd. The bug was introduced during merging of the patch for Bug#52044 from mysql-5.5-bugfixing (which does not include the call to PSI release_table_share()) to mysql-trunk-bugfixing. This patch fixes the problem by moving the release_table_share() call to TABLE_SHARE::destroy() before the TABLE_SHARE is free'd. No test case added as this problem is detected by existing valgrind tests. modified: sql/table.cc === modified file 'storage/perfschema/pfs.cc' --- a/storage/perfschema/pfs.cc 2010-08-23 16:44:14 +0000 +++ b/storage/perfschema/pfs.cc 2010-08-26 16:44:02 +0000 @@ -1744,18 +1744,26 @@ static void end_mutex_wait_v1(PSI_mutex_ if (flag_events_waits_history_long) insert_events_waits_history_long(wait); - if (rc == 0 && wait->m_timer_state == TIMER_STATE_TIMED) + if (rc == 0) { /* Thread safe: we are protected by the instrumented mutex */ - PFS_single_stat_chain *stat; PFS_mutex *mutex= pfs_locker->m_target.m_mutex; + PFS_single_stat_chain *stat= find_per_thread_mutex_class_wait_stat(wait->m_thread, mutex->m_class); mutex->m_owner= wait->m_thread; mutex->m_last_locked= wait->m_timer_end; - ulonglong wait_time= wait->m_timer_end - wait->m_timer_start; - aggregate_single_stat_chain(&mutex->m_wait_stat, wait_time); - stat= find_per_thread_mutex_class_wait_stat(wait->m_thread, mutex->m_class); - aggregate_single_stat_chain(stat, wait_time); + /* If timed then aggregate stats, else increment the value counts only */ + if (wait->m_timer_state == TIMER_STATE_TIMED) + { + ulonglong wait_time= wait->m_timer_end - wait->m_timer_start; + aggregate_single_stat_chain(&mutex->m_wait_stat, wait_time); + aggregate_single_stat_chain(stat, wait_time); + } + else + { + increment_single_stat_chain(&mutex->m_wait_stat); + increment_single_stat_chain(stat); + } } wait->m_thread->m_wait_locker_count--; } @@ -1801,20 +1809,26 @@ static void end_rwlock_rdwait_v1(PSI_rwl The statistics generated are not safe, which is why they are just statistics, not facts. */ - PFS_single_stat_chain *stat; PFS_rwlock *rwlock= pfs_locker->m_target.m_rwlock; + PFS_single_stat_chain *stat= find_per_thread_rwlock_class_wait_stat(wait->m_thread, rwlock->m_class); + if (rwlock->m_readers == 0) rwlock->m_last_read= wait->m_timer_end; rwlock->m_writer= NULL; rwlock->m_readers++; + /* If timed then aggregate stats, else increment the value counts only */ if (wait->m_timer_state == TIMER_STATE_TIMED) { ulonglong wait_time= wait->m_timer_end - wait->m_timer_start; aggregate_single_stat_chain(&rwlock->m_wait_stat, wait_time); - stat= find_per_thread_rwlock_class_wait_stat(wait->m_thread, rwlock->m_class); aggregate_single_stat_chain(stat, wait_time); } + else + { + increment_single_stat_chain(&rwlock->m_wait_stat); + increment_single_stat_chain(stat); + } } wait->m_thread->m_wait_locker_count--; } @@ -1854,21 +1868,26 @@ static void end_rwlock_wrwait_v1(PSI_rwl if (rc == 0) { /* Thread safe : we are protected by the instrumented rwlock */ - PFS_single_stat_chain *stat; PFS_rwlock *rwlock= pfs_locker->m_target.m_rwlock; + PFS_single_stat_chain *stat= find_per_thread_rwlock_class_wait_stat(wait->m_thread, rwlock->m_class); rwlock->m_writer= wait->m_thread; rwlock->m_last_written= wait->m_timer_end; /* Reset the readers stats, they could be off */ rwlock->m_readers= 0; rwlock->m_last_read= 0; + /* If timed then aggregate stats, else increment the value counts only */ if (wait->m_timer_state == TIMER_STATE_TIMED) { ulonglong wait_time= wait->m_timer_end - wait->m_timer_start; aggregate_single_stat_chain(&rwlock->m_wait_stat, wait_time); - stat= find_per_thread_rwlock_class_wait_stat(wait->m_thread, rwlock->m_class); aggregate_single_stat_chain(stat, wait_time); } + else + { + increment_single_stat_chain(&rwlock->m_wait_stat); + increment_single_stat_chain(stat); + } } wait->m_thread->m_wait_locker_count--; } @@ -1922,16 +1941,21 @@ static void end_cond_wait_v1(PSI_cond_lo in condition B. This is accepted, the data will be slightly inaccurate. */ - PFS_single_stat_chain *stat; PFS_cond *cond= pfs_locker->m_target.m_cond; + PFS_single_stat_chain *stat= find_per_thread_cond_class_wait_stat(wait->m_thread, cond->m_class); + /* If timed then aggregate stats, else increment the value counts only */ if (wait->m_timer_state == TIMER_STATE_TIMED) { ulonglong wait_time= wait->m_timer_end - wait->m_timer_start; aggregate_single_stat_chain(&cond->m_wait_stat, wait_time); - stat= find_per_thread_cond_class_wait_stat(wait->m_thread, cond->m_class); aggregate_single_stat_chain(stat, wait_time); } + else + { + increment_single_stat_chain(&cond->m_wait_stat); + increment_single_stat_chain(stat); + } } wait->m_thread->m_wait_locker_count--; } @@ -1979,6 +2003,19 @@ static void end_table_wait_v1(PSI_table_ if (flag_events_waits_history_long) insert_events_waits_history_long(wait); + PFS_table *table= pfs_locker->m_target.m_table; + + /* If timed then aggregate stats, else increment the value counts only */ + if (wait->m_timer_state == TIMER_STATE_TIMED) + { + ulonglong wait_time= wait->m_timer_end - wait->m_timer_start; + aggregate_single_stat_chain(&table->m_wait_stat, wait_time); + } + else + { + increment_single_stat_chain(&table->m_wait_stat); + } + /* There is currently no per table and per thread aggregation. The number of tables in the application is arbitrary, and may be high. @@ -2079,14 +2116,21 @@ static void end_file_wait_v1(PSI_file_lo if (flag_events_waits_history_long) insert_events_waits_history_long(wait); - PFS_single_stat_chain *stat; PFS_file *file= pfs_locker->m_target.m_file; + PFS_single_stat_chain *stat= find_per_thread_file_class_wait_stat(wait->m_thread, file->m_class); - ulonglong wait_time= wait->m_timer_end - wait->m_timer_start; - aggregate_single_stat_chain(&file->m_wait_stat, wait_time); - stat= find_per_thread_file_class_wait_stat(wait->m_thread, - file->m_class); - aggregate_single_stat_chain(stat, wait_time); + /* If timed then aggregate stats, else increment the value counts only */ + if (wait->m_timer_state == TIMER_STATE_TIMED) + { + ulonglong wait_time= wait->m_timer_end - wait->m_timer_start; + aggregate_single_stat_chain(&file->m_wait_stat, wait_time); + aggregate_single_stat_chain(stat, wait_time); + } + else + { + increment_single_stat_chain(&file->m_wait_stat); + increment_single_stat_chain(stat); + } PFS_file_class *klass= file->m_class; === modified file 'storage/perfschema/pfs_stat.h' --- a/storage/perfschema/pfs_stat.h 2010-07-16 01:28:30 +0000 +++ b/storage/perfschema/pfs_stat.h 2010-08-26 16:44:02 +0000 @@ -83,6 +83,22 @@ inline void aggregate_single_stat_chain( while (stat); } +/** + Increment the value counts in a statistic chain. + Used for instruments that are 'ENABLED' but not 'TIMED'. + @param stat the aggregated statistic chain +*/ +inline void increment_single_stat_chain(PFS_single_stat_chain *stat) +{ + do + { + if (*stat->m_control_flag) + stat->m_count++; + stat= stat->m_parent; + } + while (stat); +} + /** Statistics for COND usage. */ struct PFS_cond_stat { --===============7576153894378252614== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/chris.powers@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: chris.powers@stripped # target_branch: file:///home/cpowers/work/dev/mysql-trunk-\ # bugfixing/mysql/ # testament_sha1: 6f5fd4f85cc10dcbeaf702dab0d510e20bc479a1 # timestamp: 2010-08-26 11:47:42 -0500 # source_branch: file:///home/cpowers/work/dev/dev-55-bugfixing/mysql/ # base_revision_id: jon.hauglid@stripped\ # h63yjr0li8fm4n95 # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWZxdbKcABuJ/gFAQAgBZ//// f2fegL////pgC32d92ccHWpSgoDW00oAkAfQAAAcZMm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