Bug #58620 Performance schema failed assert, pfs_instr_class.cc, line 956
Submitted: 1 Dec 2010 6:27 Modified: 11 Dec 2010 17:06
Reporter: Marc Alff Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S3 (Non-critical)
Version:5.6 OS:Any
Assigned to: Marc Alff CPU Architecture:Any

[1 Dec 2010 6:27] Marc Alff
Description:
Spurious failure seen in mysql-trunk-stage.

Assertion failed: pfs->m_refcount > 0, file /tmp/pb2/build/sb_0-2611430-1291128040.47/mysql-5.6.1-m5/storage/perfschema/pfs_instr_class.cc, line 956

The code is:

void release_table_share(PFS_table_share *pfs)
{
  DBUG_ASSERT(pfs->m_refcount > 0);
  pfs->m_refcount--;
}

Problem: PFS_table_share::m_refcount should use atomic operations,
since an exact count is required.

Full log:

main.handler_innodb w6 [ fail ]
        Test ended at 2010-11-30 16:24:46

CURRENT_TEST: main.handler_innodb
mysqltest: In included file "./include/handler.inc": At line 407: query 'reap' failed: 2013: Lost connection to MySQL server during query

The result from queries just before the failure was:
< snip >
ERROR 42S02: Unknown table 'h1_3' in HANDLER
drop table t1;
drop table t2;
drop table t3;
drop table t4;
drop table t5;
create table t1 (c1 int);
insert into t1 values (1);
handler t1 open;
handler t1 read first;
c1
1
send the below to another connection, do not wait for the result
optimize table t1;
proceed with the normal connection
handler t1 read next;
c1
1
handler t1 close;
read the result from the other connection

More results from queries before failure can be found in /tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/mysql-test/var-ps_row/6/log/handler_innodb.log

Server [mysqld.1 - pid: 13097, winpid: 13097, exit: 256] failed during test run
Server log from this test:
----------SERVER LOG START-----------
Assertion failed: pfs->m_refcount > 0, file /tmp/pb2/build/sb_0-2611430-1291128040.47/mysql-5.6.1-m5/storage/perfschema/pfs_instr_class.cc, line 956
101130 18:24:41 - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=1048576
read_buffer_size=131072
max_used_connections=2
max_threads=151
thread_count=2
connection_count=2
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 60812 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0x104a9b6a0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:my_print_stacktrace+0x38
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:handle_segfault+0x464
/lib/sparcv9/libc.so.1:0xd6fdc
/lib/sparcv9/libc.so.1:0xcab70
/lib/sparcv9/libc.so.1:0xcad7c
/lib/sparcv9/libc.so.1:__lwp_kill+0x8 [ Signal 6 (ABRT)]
/lib/sparcv9/libc.so.1:abort+0xd0
/lib/sparcv9/libc.so.1:_assert+0x74
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cTrelease_table_share6FpnPPFS_table_share__v_+0x50
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:0xa88f88
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cLTABLE_SHAREHdestroy6M_v_+0x1b0
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cQfree_table_share6FpnLTABLE_SHARE__v_+0xfc
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:0x24a624
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:my_hash_delete+0x5b4
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cTrelease_table_share6FpnLTABLE_SHARE__v_+0x1d8
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cIclosefrm6FpnFTABLE_b_i_+0x20c
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cSintern_close_table6FpnFTABLE__v_+0x16c
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:0x24c1ac
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cSclose_thread_table6FpnDTHD_ppnFTABLE__b_+0x350
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cZclose_all_tables_for_name6FpnDTHD_pnLTABLE_SHARE_b_v_+0x1f4
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cRmysql_alter_table6FpnDTHD_pc2pnYst_ha_create_information_pnKTABLE_LIST_pnKAlter_info_IpnIst_order_b_b_+0x2db0
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cUmysql_recreate_table6FpnDTHD_pnKTABLE_LIST__b_+0x170
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:0x41610c
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cWSql_cmd_optimize_tableHexecute6MpnDTHD__b_+0x198
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cVmysql_execute_command6FpnDTHD__i_+0x8bd8
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cLmysql_parse6FpnDTHD_pcIpnMParser_state__v_+0x308
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cQdispatch_command6FnTenum_server_command_pnDTHD_pcI_b_+0x834
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cKdo_command6FpnDTHD__b_+0x314
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:__1cYdo_handle_one_connection6FpnDTHD__v_+0x338
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:handle_one_connection+0x2c
/tmp/pb2/test/sb_1-2611529-1291128997.25/mysql-5.6.1-m5-solaris10-sparc-64bit-test/bin/mysqld:pfs_spawn_thread+0x158
/lib/sparcv9/libc.so.1:0xd6eb0
Please read http://dev.mysql.com/doc/refman/5.1/en/resolve-stack-dump.html
and follow instructions on how to resolve the stack trace.
Resolved stack trace is much more helpful in diagnosing the
problem, so please do resolve it
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 104a1ce90 = optimize table t1
thd->thread_id=15
thd->killed=NOT_KILLED
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
Writing a core file
----------SERVER LOG END-------------

How to repeat:
N/A

Suggested fix:
Use atomics for PFS_table_share::m_refcount
[1 Dec 2010 8:34] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/125614

3401 Marc Alff	2010-12-01
      Bug#58620 Performance schema failed assert, pfs_instr_class.cc, line 956
      
      Before this fix, the member PFS_table_share::m_refcount was maintained
      with ++ and -- operations.
      
      This is not thread safe, since two threads may open or close table
      handles on the same table share, and compete when updating m_refcount.
      
      This fix uses atomic operations to maintain this reference counter,
      making the counter safe.
[1 Dec 2010 17:25] Christopher Powers
Patch approved. I wonder if there are other counts that need to be made atomic.
[1 Dec 2010 19:10] Marc Alff
Pushed into:
- mysql-trunk-bugfixing
[5 Dec 2010 12:37] Bugs System
Pushed into mysql-trunk 5.6.1 (revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (version source revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (merge vers: 5.6.1) (pib:23)
[11 Dec 2010 17:06] Paul Dubois
Bug not present in any 5.6.x release. No changelog entry needed.