Bug #73803 don't acquire global_sid_lock->rdlock if gtid is disabled
Submitted: 4 Sep 2014 8:40 Modified: 8 Jan 2019 13:05
Reporter: zhai weixiang (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Locking Severity:S3 (Non-critical)
Version:5.6.20 OS:Any
Assigned to: CPU Architecture:Any

[4 Sep 2014 8:40] zhai weixiang
Description:
Even gtid is disabled completely (means thd->owned_gtid.sidno always equal to zero). global_sid_lock->rdlock is  always acquired in two function:

quoted code from MYSQL_BIN_LOG::finish_commit:
6762   global_sid_lock->rdlock();
6763   gtid_state->update_on_commit(thd);
6764   global_sid_lock->unlock();

quoted code from MYSQL_BIN_LOG::write_cache:
5840       global_sid_lock->rdlock();
5841       if (gtid_state->update_on_flush(thd) != RETURN_STATUS_OK)
5842       {
5843         global_sid_lock->unlock();
5844         goto err;
5845       }
5846       global_sid_lock->unlock();

And that's why I can see such backtraces from the output of pt-pmp:

inline_mysql_rwlock_rdlock(mysql_thread.h:856),rdlock(mysql_thread.h:856),MYSQL_BIN_LOG::finish_commit(mysql_thread.h:856),MYSQL_BIN_LOG::ordered_commit(binlog.cc:6978),MYSQL_BIN_LOG::commit(binlog.cc:6354),ha_commit_trans(handler.cc:1499),trans_commit_stmt(transaction.cc:464),mysql_execute_command(sql_parse.cc:5460),mysql_parse(sql_parse.cc:6742),dispatch_command(sql_parse.cc:1647),threadpool_process_request(threadpool_common.cc:246),handle_event(threadpool_unix.cc:1553),worker_main(threadpool_unix.cc:1553),pfs_spawn_thread(pfs.cc:1858),start_thread(libpthread.so.0),clone(libc.so.6)
  

How to repeat:
read the code

Suggested fix:
don't acquire global_sid_lock->rdlock if gtid is disabled
[8 Jan 2019 13:05] MySQL Verification Team
I completely agree with you on this matter. I find your code analysis correct.

Verified as reported.