summaryrefslogtreecommitdiff
path: root/databases/mariadb1011-server/files/patch-PR279362
blob: f779ad442e1ed678ca19fb4d7976f5f77a40c409 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
From 45279cb03d55859423349df7e11caa5ae2b012c5 Mon Sep 17 00:00:00 2001
From: Dave Gosselin <dave.gosselin@mariadb.com>
Date: Mon, 13 May 2024 10:36:11 -0400
Subject: [PATCH] MDEV-34129 mariadb-install-db appears to hang on macOS

A bug in signal_handler thread initialization led to an overcomplicated
implementation of wait_for_signal_handler_to_end, namely that we could
fail to initialize the signal handler but mark it as active anyway.
This meant that we could wait for it to terminate when it didn't exist
in the first place.

Additionally, let's immediately close down the signal handler loop when
we decide to break connections--it's the start of process termination
anyway, and there's no need to wait once we've invoked break_connections.
--- mysql-test/suite/rpl/r/rpl_shutdown_sighup.result.orig	2024-05-10 21:02:44 UTC
+++ mysql-test/suite/rpl/r/rpl_shutdown_sighup.result
@@ -41,7 +41,6 @@ connection slave;
 shutdown;
 connection server_2;
 connection slave;
-include/assert_grep.inc [Ensure warning is issued that signal handler thread is still processing]
 #
 # Cleanup
 connection master;
 .../suite/rpl/r/rpl_shutdown_sighup.result    |  1 -
 .../suite/rpl/t/rpl_shutdown_sighup.test      |  7 ---
 sql/mysqld.cc                                 | 61 ++++++++++---------
 3 files changed, 32 insertions(+), 37 deletions(-)

--- mysql-test/suite/rpl/t/rpl_shutdown_sighup.test.orig	2024-05-10 21:02:44 UTC
+++ mysql-test/suite/rpl/t/rpl_shutdown_sighup.test
@@ -137,13 +137,6 @@ --source include/wait_until_connected_again.inc
 --enable_reconnect
 --source include/wait_until_connected_again.inc
 
---let $assert_text= Ensure warning is issued that signal handler thread is still processing
---let $assert_select= Signal handler thread did not exit in a timely manner.
---let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
---let $assert_count= 1
---let $assert_only_after = CURRENT_TEST: rpl.rpl_shutdown_sighup
---source include/assert_grep.inc
-
 
 --echo #
 --echo # Cleanup
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 5ae30282729..68d8a04430f 100644
--- sql/mysqld.cc.orig
+++ sql/mysqld.cc
@@ -3205,6 +3205,15 @@ static void start_signal_handler(void)
   DBUG_VOID_RETURN;
 }
 
+/** Called only from signal_hand function. */
+static void* exit_signal_handler()
+{
+    my_thread_end();
+    signal_thread_in_use= 0;
+    pthread_exit(0);  // Safety
+    return nullptr;  // Avoid compiler warnings
+}
+
 
 /** This threads handles all signals and alarms. */
 /* ARGSUSED */
@@ -3265,10 +3274,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
     if (abort_loop)
     {
       DBUG_PRINT("quit",("signal_handler: calling my_thread_end()"));
-      my_thread_end();
-      signal_thread_in_use= 0;
-      pthread_exit(0);				// Safety
-      return 0;                                 // Avoid compiler warnings
+      return exit_signal_handler();
     }
     switch (sig) {
     case SIGTERM:
@@ -3287,6 +3293,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
         PSI_CALL_delete_current_thread();
         my_sigset(sig, SIG_IGN);
         break_connect_loop(); // MIT THREAD has a alarm thread
+        return exit_signal_handler();
       }
       break;
     case SIGHUP: