[MDEV-18388] Assertion `!thd->spcont' failed in net_send_error upon server shutdown Created: 2019-01-27  Updated: 2019-04-23  Resolved: 2019-04-23

Status: Closed
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.2
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Vladislav Vaintroub
Resolution: Cannot Reproduce Votes: 0
Labels: None


 Description   

Debug injection and the sample test, courtesy of svoj:

For 10.2

diff --git a/sql/item_func.cc b/sql/item_func.cc
index 89ca25b..77bcf22 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4584,6 +4584,7 @@ longlong Item_func_sleep::val_int()
   }
   thd_wait_end(thd);
   mysql_mutex_unlock(&LOCK_item_func_sleep);
+  sleep(3);
   mysql_mutex_lock(&thd->mysys_var->mutex);
   thd->mysys_var->current_mutex= 0;
   thd->mysys_var->current_cond=  0;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 7773660..860e4c3 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1760,7 +1760,7 @@ static void close_connections(void)
   */
   DBUG_PRINT("info", ("thread_count: %d", thread_count));
 
-  for (int i= 0; *(volatile int32*) &thread_count && i < 1000; i++)
+  for (int i= 0; *(volatile int32*) &thread_count && i < 100; i++)
     my_sleep(20000);
 
   /*

MTR test

CREATE PROCEDURE p1() SELECT SLEEP(10);
send CALL p1();

10.2 3fb6d2587d with the patch above

2019-01-27 18:41:59 139629072766720 [Note] /data/src/10.2-bug/sql/mysqld (initiated by: root[root] @ localhost [127.0.0.1]): Normal shutdown
2019-01-27 18:41:59 139629072766720 [Note] Event Scheduler: Purging the queue. 0 events
2019-01-27 18:42:01 139629072766720 [Warning] /data/src/10.2-bug/sql/mysqld: Forcing close of thread 4  user: 'root'
 
mysqld: /data/src/10.2-bug/sql/protocol.cc:155: bool net_send_error(THD*, uint, const char*, const char*): Assertion `!thd->spcont' failed.
190127 18:42:01 [ERROR] mysqld got signal 6 ;
 
#7  0x00007efdf323cee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000565482973c2d in net_send_error (thd=0x7efddc000b00, sql_errno=1053, err=0x5654868bad39 "Server shutdown in progress", sqlstate=0x0) at /data/src/10.2-bug/sql/protocol.cc:155
#9  0x000056548295c147 in close_connection (thd=0x7efddc000b00, sql_errno=1053) at /data/src/10.2-bug/sql/mysqld.cc:2830
#10 0x0000565482959b70 in close_connections () at /data/src/10.2-bug/sql/mysqld.cc:1794
#11 0x000056548295a330 in kill_server (sig_ptr=0x0) at /data/src/10.2-bug/sql/mysqld.cc:2019
#12 0x000056548295a3ab in kill_server_thread (arg=0x7efded5ace00) at /data/src/10.2-bug/sql/mysqld.cc:2051
#13 0x0000565482fb1f98 in pfs_spawn_thread (arg=0x7efde4001360) at /data/src/10.2-bug/storage/perfschema/pfs.cc:1862
#14 0x00007efdf4f13494 in start_thread (arg=0x7efded485700) at pthread_create.c:333
#15 0x00007efdf32f993f in clone () from /lib/x86_64-linux-gnu/libc.so.6
 
Some pointers may be invalid and cause the dump to abort.
Query (0x7efddc07be48): SELECT SLEEP(10)
Connection ID (thread ID): 4
Status: KILL_SERVER

I didn't check other versions.



 Comments   
Comment by Vladislav Vaintroub [ 2019-04-23 ]

After commit 20e19f69 in MDEV-17479, server won't try to send ER_SHUTDOWN anymore.
This reduces possibility of race conditions during shutdown, because net_send_error() is eliminated.

Generated at Thu Feb 08 08:43:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.