Bug #70577 Read/Write mutexes on Binlog delegate classes are not counted on perf schema
Submitted: 9 Oct 2013 21:47 Modified: 15 Oct 2013 18:19
Reporter: Yoshinori Matsunobu (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S3 (Non-critical)
Version:5.6.14 OS:Any
Assigned to: Marc Alff
Triage: Needs Triage: D5 (Feature request)

[9 Oct 2013 21:47] Yoshinori Matsunobu
Description:
Binlog delegate classes (used for semisync replication) use read/write mutexes internally, but they are not counted on performance schema statistics.
At least below classes are affected.

Trans_delegate
Binlog_storage_delegate
Binlog_transmit_delegate
Binlog_relay_IO_delegate

On parent class Delegate, there is a member variable "rw_lock_t lock", and within some member functions, lock is held by "rw_rdlock(&lock)" etc.

rw_rdlock is mapped to pthread_rwlock_rdlock. This should be mysql_rwlock_rdlock so that performance schema can cover.

While investigating bug#70218, we noticed that Binlog_transmit_delegate::lock caused lots of contentions, but they were not visible from performance schema.

How to repeat:
Read sql/rpl_handler.h and include/my_pthread.h
[10 Oct 2013 18:20] Sveta Smirnova
Thank you for the report.

Verified as described.
[15 Oct 2013 18:19] Paul Dubois
Noted in 5.6.15, 5.7.3 changelogs.

The Performance Schema now instruments the read/write lock
Delegate::lock, which is used for the following classes:

Trans_delegate
Binlog_storage_delegate
Binlog_transmit_delegate
Binlog_relay_IO_delegate

A different instrument name is used for each subclass, to have
distinct statistics for distinct uses. The instruments are visible in
the schema.setup_instruments table and have these names:
      
wait/synch/rwlock/sql/Trans_delegate::lock
wait/synch/rwlock/sql/Binlog_storage_delegate::lock
wait/synch/rwlock/sql/Binlog_transmit_delegate::lock
wait/synch/rwlock/sql/Binlog_relay_IO_delegate::lock
[4 Dec 2013 11:55] Laurynas Biveinis
5.6$ bzr log -r 5513 -n0
------------------------------------------------------------
revno: 5513 [merge]
committer: Marc Alff <marc.alff@oracle.com>
branch nick: mysql-5.6-push
timestamp: Sat 2013-10-12 01:22:41 +0200
message:
  Merge to mysql-5.6
    ------------------------------------------------------------
    revno: 5510.1.1
    committer: Marc Alff <marc.alff@oracle.com>
    branch nick: mysql-5.6-bug17590161
    timestamp: Fri 2013-10-11 17:31:42 +0200
    message:
      Bug#17590161 READ/WRITE MUTEXES ON BINLOG DELEGATE CLASSES ARE NOT COUNTED
      ON PERF SCHEMA 
      
      Prior to this fix, the read write lock Delegate::lock was not instrumented 
      for the performance schema.
      This lock is used in particular for the following classes:
      - Trans_delegate
      - Binlog_storage_delegate
      - Binlog_transmit_delegate
      - Binlog_relay_IO_delegate
      
      With this fix, the read write lock is instrumented.
      For clarity, a different name is used for each sub class,
      to have distinct statistics for distinct uses.
      
      The instruments added are visible in table 
      performance_schema.setup_instruments as:
      - wait/synch/rwlock/sql/Trans_delegate::lock
      - wait/synch/rwlock/sql/Binlog_storage_delegate::lock
      - wait/synch/rwlock/sql/Binlog_transmit_delegate::lock
      - wait/synch/rwlock/sql/Binlog_relay_IO_delegate::lock