Bug #83541 Assertion `tab->ref().use_count' failed.
Submitted: 26 Oct 2016 8:23 Modified: 18 Nov 2016 6:33
Reporter: Roel Van de Paar Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S1 (Critical)
Version:5.5.52, 5.6.34, 5.7.16 OS:Any
Assigned to: CPU Architecture:Any

[26 Oct 2016 8:23] Roel Van de Paar
Description:
2016-10-26T08:03:38.340703Z 0 [Note] /sda/MS071016-mysql-5.7.15-linux-x86_64-debug/bin/mysqld: ready for connections.
Version: '5.7.15-debug'  socket: '/sda/MS071016-mysql-5.7.15-linux-x86_64-debug/socket.sock'  port: 15713  MySQL Community Server (GPL)
mysqld: /git/mysql-server_dbg/sql/sql_executor.cc:2127: void join_read_key_unlock_row(QEP_TAB*): Assertion `tab->ref().use_count' failed.
08:03:46 UTC - mysqld got signal 6 ;

Program terminated with signal 6, Aborted.
#0  0x00007fe55e145741 in __pthread_kill (threadid=<optimized out>, signo=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
61        val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
(gdb) bt
+bt
#0  0x00007fe55e145741 in __pthread_kill (threadid=<optimized out>, signo=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
#1  0x0000000001822fb0 in my_write_core (sig=6) at /git/mysql-server_dbg/mysys/stacktrace.c:247
#2  0x0000000000e7457c in handle_fatal_signal (sig=6) at /git/mysql-server_dbg/sql/signal_handler.cc:220
#3  <signal handler called>
#4  0x00007fe55c4dc5f7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#5  0x00007fe55c4ddce8 in __GI_abort () at abort.c:90
#6  0x00007fe55c4d5566 in __assert_fail_base (fmt=0x7fe55c625ce8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x1f17055 "tab->ref().use_count", file=file@entry=0x1f16b70 "/git/mysql-server_dbg/sql/sql_executor.cc", line=line@entry=2127, function=function@entry=0x1f17dc0 <join_read_key_unlock_row(QEP_TAB*)::__PRETTY_FUNCTION__> "void join_read_key_unlock_row(QEP_TAB*)") at assert.c:92
#7  0x00007fe55c4d5612 in __GI___assert_fail (assertion=0x1f17055 "tab->ref().use_count", file=0x1f16b70 "/git/mysql-server_dbg/sql/sql_executor.cc", line=2127, function=0x1f17dc0 <join_read_key_unlock_row(QEP_TAB*)::__PRETTY_FUNCTION__> "void join_read_key_unlock_row(QEP_TAB*)") at assert.c:101
#8  0x00000000014ad481 in join_read_key_unlock_row (tab=0x7fe53214ae08) at /git/mysql-server_dbg/sql/sql_executor.cc:2127
#9  0x00000000014ac43e in evaluate_join_record (join=0x7fe532148d38, qep_tab=0x7fe53214ae08) at /git/mysql-server_dbg/sql/sql_executor.cc:1699
#10 0x00000000014ab5d9 in sub_select (join=0x7fe532148d38, qep_tab=0x7fe53214ae08, end_of_records=false) at /git/mysql-server_dbg/sql/sql_executor.cc:1291
#11 0x00000000014ac199 in evaluate_join_record (join=0x7fe532148d38, qep_tab=0x7fe53214ac90) at /git/mysql-server_dbg/sql/sql_executor.cc:1639
#12 0x00000000014ab5d9 in sub_select (join=0x7fe532148d38, qep_tab=0x7fe53214ac90, end_of_records=false) at /git/mysql-server_dbg/sql/sql_executor.cc:1291
#13 0x00000000014aae5a in do_select (join=0x7fe532148d38) at /git/mysql-server_dbg/sql/sql_executor.cc:944
#14 0x00000000014a8ddb in JOIN::exec (this=0x7fe532148d38) at /git/mysql-server_dbg/sql/sql_executor.cc:199
#15 0x00000000015428da in handle_query (thd=0x7fe532019000, lex=0x7fe53201b2f8, result=0x7fe532148030, added_options=0, removed_options=0) at /git/mysql-server_dbg/sql/sql_select.cc:184
#16 0x00000000014f88c7 in execute_sqlcom_select (thd=0x7fe532019000, all_tables=0x7fe53202bd80) at /git/mysql-server_dbg/sql/sql_parse.cc:5143
#17 0x00000000014f20d8 in mysql_execute_command (thd=0x7fe532019000, first_level=true) at /git/mysql-server_dbg/sql/sql_parse.cc:2756
#18 0x00000000014f97d5 in mysql_parse (thd=0x7fe532019000, parser_state=0x7fe55e738560) at /git/mysql-server_dbg/sql/sql_parse.cc:5559
#19 0x00000000014eef69 in dispatch_command (thd=0x7fe532019000, com_data=0x7fe55e738cb0, command=COM_QUERY) at /git/mysql-server_dbg/sql/sql_parse.cc:1427
#20 0x00000000014ede33 in do_command (thd=0x7fe532019000) at /git/mysql-server_dbg/sql/sql_parse.cc:995
#21 0x000000000161d370 in handle_connection (arg=0x7fe542be9840) at /git/mysql-server_dbg/sql/conn_handler/connection_handler_per_thread.cc:300
#22 0x000000000184f79c in pfs_spawn_thread (arg=0x7fe542a76120) at /git/mysql-server_dbg/storage/perfschema/pfs.cc:2188
#23 0x00007fe55e140dc5 in start_thread (arg=0x7fe55e739700) at pthread_create.c:308
#24 0x00007fe55c59dced in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

How to repeat:
# mysqld options required for replay:  --sql_mode=ONLY_FULL_GROUP_BY
DROP DATABASE test;CREATE DATABASE test;USE test;
create table t1(a int,b DATE);
insert INTO t1 values(2,'first value');
SET @@session.default_storage_engine='archive';
INSERT INTO t1 VALUES(0,0);
CREATE TABLE t2(a int auto_increment key,b int);
INSERT INTO t2 VALUES(1,1),(2,2),(3,2),(4,3),(5,3);
select * FROM t1 natural join t2;
[26 Oct 2016 9:05] MySQL Verification Team
Thanks for the report;  Affects debug builds of 5.5, 5.6, 5.7, 8.0

--
set sql_mode='';
drop table if exists t,s;
create table t(a int,b int)engine=innodb;
insert into t values(2,0),(0,0);
create table s(a int auto_increment key,b int)engine=archive;
insert into s values(1,1),(2,2),(3,2),(4,3),(5,3);
select * from t natural join s;
--

Version: '5.7.17-debug'  (Built on 2016/10/21)
Assertion failed: tab->ref().use_count, file sql_executor.cc, line 2127
abort() has been called

mysqld-debug.exe!my_sigabrt_handler()[my_thr_init.c:449]
mysqld-debug.exe!raise()[signal.cpp:522]
mysqld-debug.exe!abort()[abort.cpp:71]
mysqld-debug.exe!common_assert_to_stderr_direct()[assert.cpp:124]
mysqld-debug.exe!common_assert_to_stderr<wchar_t>()[assert.cpp:142]
mysqld-debug.exe!common_assert<wchar_t>()[assert.cpp:383]
mysqld-debug.exe!_wassert()[assert.cpp:405]
mysqld-debug.exe!join_read_key_unlock_row()[sql_executor.cc:2127]
mysqld-debug.exe!evaluate_join_record()[sql_executor.cc:1701]
mysqld-debug.exe!sub_select()[sql_executor.cc:1291]
mysqld-debug.exe!evaluate_join_record()[sql_executor.cc:1639]
mysqld-debug.exe!sub_select()[sql_executor.cc:1291]
mysqld-debug.exe!do_select()[sql_executor.cc:944]
mysqld-debug.exe!JOIN::exec()[sql_executor.cc:199]
mysqld-debug.exe!handle_query()[sql_select.cc:185]
mysqld-debug.exe!execute_sqlcom_select()[sql_parse.cc:5180]
mysqld-debug.exe!mysql_execute_command()[sql_parse.cc:2793]
mysqld-debug.exe!mysql_parse()[sql_parse.cc:5596]
mysqld-debug.exe!dispatch_command()[sql_parse.cc:1462]
mysqld-debug.exe!do_command()[sql_parse.cc:998]
mysqld-debug.exe!handle_connection()[connection_handler_per_thread.cc:300]
mysqld-debug.exe!pfs_spawn_thread()[pfs.cc:2190]
mysqld-debug.exe!win_thread_start()[my_thread.c:37]
mysqld-debug.exe!invoke_thread_procedure()[thread.cpp:92]
[26 Oct 2016 9:07] MySQL Verification Team
duplicate of:
 http://bugs.mysql.com/bug.php?id=74780
 Bug 20007114 - ASSERTION `TAB->REF.USE_COUNT' FAILED IN JOIN_READ_KEY_UNLOCK_ROW
[18 Nov 2016 6:33] Erlend Dahl
Duplicate of

Bug#74780 Assertion `tab->ref.use_count' failed in join_read_key_unlock_row