Merge lp:~akopytov/percona-xtrabackup/bug766305 into lp:percona-xtrabackup/2.2

Proposed by Alexey Kopytov
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 5022
Proposed branch: lp:~akopytov/percona-xtrabackup/bug766305
Merge into: lp:percona-xtrabackup/2.2
Diff against target: 250 lines (+65/-94)
6 files modified
configure.cmake (+2/-1)
sql/signal_handler.cc (+5/-84)
storage/innobase/include/univ.i (+3/-9)
storage/innobase/xtrabackup/src/CMakeLists.txt (+2/-0)
storage/innobase/xtrabackup/src/xtrabackup.cc (+17/-0)
storage/innobase/xtrabackup/test/t/bug766305.sh (+36/-0)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug766305
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+235387@code.launchpad.net

Description of the change

    Bug #766305: Use MySQL Code to get stack trace

    Implemented the following to reuse MySQL stacktrace dump code:

    - set up handle_fatal_signal() as a signal handler for certain signals
    in xtrabackup.cc::main().

    - handle_fatal_signal() has been modified to avoid
    dumping some server-specific information.

    - the hidden visibility attribute in UNIV_INTERN symbols does not make
    any sense for XtraBackup, but prevents fully resolved stacktraces on
    Linux, so it has been removed.

    - backtrace_symbols() requires passing -export-dynamic to the linker on
    Linux, so the corresponding property has been added for the xtrabackup
    CMake target.

    - fixed cxxabi.h detection in configure.cmake to make symbol demangling
    possible.

http://jenkins.percona.com/view/PXB%202.2/job/percona-xtrabackup-2.2-param/212/

To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'configure.cmake'
--- configure.cmake 2014-09-15 08:52:36 +0000
+++ configure.cmake 2014-09-20 19:02:31 +0000
@@ -264,6 +264,7 @@
264# Tests for header files264# Tests for header files
265#265#
266INCLUDE (CheckIncludeFiles)266INCLUDE (CheckIncludeFiles)
267INCLUDE (CheckIncludeFileCXX)
267268
268CHECK_INCLUDE_FILES ("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)269CHECK_INCLUDE_FILES ("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
269CHECK_INCLUDE_FILES (sys/types.h HAVE_SYS_TYPES_H)270CHECK_INCLUDE_FILES (sys/types.h HAVE_SYS_TYPES_H)
@@ -271,7 +272,7 @@
271CHECK_INCLUDE_FILES (aio.h HAVE_AIO_H)272CHECK_INCLUDE_FILES (aio.h HAVE_AIO_H)
272CHECK_INCLUDE_FILES (arpa/inet.h HAVE_ARPA_INET_H)273CHECK_INCLUDE_FILES (arpa/inet.h HAVE_ARPA_INET_H)
273CHECK_INCLUDE_FILES (crypt.h HAVE_CRYPT_H)274CHECK_INCLUDE_FILES (crypt.h HAVE_CRYPT_H)
274CHECK_INCLUDE_FILES (cxxabi.h HAVE_CXXABI_H)275CHECK_INCLUDE_FILE_CXX (cxxabi.h HAVE_CXXABI_H)
275CHECK_INCLUDE_FILES (dirent.h HAVE_DIRENT_H)276CHECK_INCLUDE_FILES (dirent.h HAVE_DIRENT_H)
276CHECK_INCLUDE_FILES (dlfcn.h HAVE_DLFCN_H)277CHECK_INCLUDE_FILES (dlfcn.h HAVE_DLFCN_H)
277CHECK_INCLUDE_FILES (execinfo.h HAVE_EXECINFO_H)278CHECK_INCLUDE_FILES (execinfo.h HAVE_EXECINFO_H)
278279
=== modified file 'sql/signal_handler.cc'
--- sql/signal_handler.cc 2014-09-15 08:52:36 +0000
+++ sql/signal_handler.cc 2014-09-20 19:02:31 +0000
@@ -86,65 +86,18 @@
86 my_safe_itoa(10, mins, &mins_buf[2]);86 my_safe_itoa(10, mins, &mins_buf[2]);
87 my_safe_itoa(10, secs, &secs_buf[2]);87 my_safe_itoa(10, secs, &secs_buf[2]);
8888
89 my_safe_printf_stderr("%s:%s:%s UTC - mysqld got " SIGNAL_FMT " ;\n",89 my_safe_printf_stderr("%s:%s:%s UTC - xtrabackup got " SIGNAL_FMT " ;\n",
90 hrs_buf, mins_buf, secs_buf, sig);90 hrs_buf, mins_buf, secs_buf, sig);
9191
92 my_safe_printf_stderr("%s",92 my_safe_printf_stderr("%s",
93 "This could be because you hit a bug. It is also possible that this binary\n"93 "This could be because you hit a bug or data is corrupted.\n"
94 "or one of the libraries it was linked against is corrupt, improperly built,\n"94 "This error can also be caused by malfunctioning hardware.\n");
95 "or misconfigured. This error can also be caused by malfunctioning hardware.\n");
9695
97 my_safe_printf_stderr("%s",96 my_safe_printf_stderr("%s",
98 "We will try our best to scrape up some info that will hopefully help\n"97 "We will try our best to scrape up some info that will hopefully help\n"
99 "diagnose the problem, but since we have already crashed, \n"98 "diagnose the problem, but since we have already crashed, \n"
100 "something is definitely wrong and this may fail.\n\n");99 "something is definitely wrong and this may fail.\n\n");
101100
102 my_safe_printf_stderr("key_buffer_size=%lu\n",
103 (ulong) dflt_key_cache->key_cache_mem_size);
104
105 my_safe_printf_stderr("read_buffer_size=%ld\n",
106 (long) global_system_variables.read_buff_size);
107
108 my_safe_printf_stderr("max_used_connections=%lu\n",
109 (ulong) max_used_connections);
110
111 my_safe_printf_stderr("max_threads=%u\n",
112 (uint) thread_scheduler->max_threads);
113
114 my_safe_printf_stderr("thread_count=%u\n", get_thread_count());
115
116 my_safe_printf_stderr("connection_count=%u\n", (uint) connection_count);
117
118 my_safe_printf_stderr("It is possible that mysqld could use up to \n"
119 "key_buffer_size + "
120 "(read_buffer_size + sort_buffer_size)*max_threads = "
121 "%lu K bytes of memory\n",
122 ((ulong) dflt_key_cache->key_cache_mem_size +
123 (global_system_variables.read_buff_size +
124 global_system_variables.sortbuff_size) *
125 thread_scheduler->max_threads +
126 max_connections * sizeof(THD)) / 1024);
127
128 my_safe_printf_stderr("%s",
129 "Hope that's ok; if not, decrease some variables in the equation.\n\n");
130
131#if defined(HAVE_LINUXTHREADS)
132#define UNSAFE_DEFAULT_LINUX_THREADS 200
133 if (sizeof(char*) == 4 && thread_count > UNSAFE_DEFAULT_LINUX_THREADS)
134 {
135 my_safe_printf_stderr(
136 "You seem to be running 32-bit Linux and have "
137 "%d concurrent connections.\n"
138 "If you have not changed STACK_SIZE in LinuxThreads "
139 "and built the binary \n"
140 "yourself, LinuxThreads is quite likely to steal "
141 "a part of the global heap for\n"
142 "the thread stack. Please read "
143 "http://dev.mysql.com/doc/mysql/en/linux-installation.html\n\n"
144 thread_count);
145 }
146#endif /* HAVE_LINUXTHREADS */
147
148#ifdef HAVE_STACKTRACE101#ifdef HAVE_STACKTRACE
149 THD *thd=current_thd;102 THD *thd=current_thd;
150103
@@ -159,40 +112,8 @@
159 my_print_stacktrace(thd ? (uchar*) thd->thread_stack : NULL,112 my_print_stacktrace(thd ? (uchar*) thd->thread_stack : NULL,
160 my_thread_stack_size);113 my_thread_stack_size);
161 }114 }
162 if (thd)115 my_safe_printf_stderr("%s", "\n"
163 {116 "Please report a bug at https://bugs.launchpad.net/percona-xtrabackup\n");
164 const char *kreason= "UNKNOWN";
165 switch (thd->killed) {
166 case THD::NOT_KILLED:
167 kreason= "NOT_KILLED";
168 break;
169 case THD::KILL_BAD_DATA:
170 kreason= "KILL_BAD_DATA";
171 break;
172 case THD::KILL_CONNECTION:
173 kreason= "KILL_CONNECTION";
174 break;
175 case THD::KILL_QUERY:
176 kreason= "KILL_QUERY";
177 break;
178 case THD::KILLED_NO_VALUE:
179 kreason= "KILLED_NO_VALUE";
180 break;
181 }
182 my_safe_printf_stderr("%s", "\n"
183 "Trying to get some variables.\n"
184 "Some pointers may be invalid and cause the dump to abort.\n");
185
186 my_safe_printf_stderr("Query (%p): ", thd->query());
187 my_safe_print_str(thd->query(), MY_MIN(1024U, thd->query_length()));
188 my_safe_printf_stderr("Connection ID (thread ID): %lu\n",
189 (ulong) thd->thread_id);
190 my_safe_printf_stderr("Status: %s\n\n", kreason);
191 }
192 my_safe_printf_stderr("%s",
193 "The manual page at "
194 "http://dev.mysql.com/doc/mysql/en/crashing.html contains\n"
195 "information that should help you find out what is causing the crash.\n");
196117
197#endif /* HAVE_STACKTRACE */118#endif /* HAVE_STACKTRACE */
198119
199120
=== modified file 'storage/innobase/include/univ.i'
--- storage/innobase/include/univ.i 2014-09-15 08:52:36 +0000
+++ storage/innobase/include/univ.i 2014-09-20 19:02:31 +0000
@@ -247,15 +247,9 @@
247 at a buffer page write: it should be tested with this247 at a buffer page write: it should be tested with this
248 option off; also some ibuf tests are suppressed */248 option off; also some ibuf tests are suppressed */
249249
250/* Linkage specifier for non-static InnoDB symbols (variables and functions)250/* For XtraBackup, we disable the GCC visibility directive for InnoDB internal
251that are only referenced from within InnoDB, not from MySQL. We disable the251symbols as that allows XtraBackup print fully resolved stacktraces on Linux. */
252GCC visibility directive on all Sun operating systems because there is no252#define UNIV_INTERN
253easy way to get it to work. See http://bugs.mysql.com/bug.php?id=52263. */
254#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(sun) || defined(__INTEL_COMPILER)
255# define UNIV_INTERN __attribute__((visibility ("hidden")))
256#else
257# define UNIV_INTERN
258#endif
259#if defined(INNODB_COMPILER_HINTS) \253#if defined(INNODB_COMPILER_HINTS) \
260 && defined __GNUC__ \254 && defined __GNUC__ \
261 && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3)255 && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3)
262256
=== modified file 'storage/innobase/xtrabackup/src/CMakeLists.txt'
--- storage/innobase/xtrabackup/src/CMakeLists.txt 2014-09-04 16:53:33 +0000
+++ storage/innobase/xtrabackup/src/CMakeLists.txt 2014-09-20 19:02:31 +0000
@@ -58,6 +58,8 @@
58 xbstream_write.c58 xbstream_write.c
59 )59 )
6060
61SET_TARGET_PROPERTIES(xtrabackup PROPERTIES ENABLE_EXPORTS TRUE)
62
61TARGET_LINK_LIBRARIES(xtrabackup 63TARGET_LINK_LIBRARIES(xtrabackup
62 mysqlserver 64 mysqlserver
63 ${GCRYPT_LIBS} 65 ${GCRYPT_LIBS}
6466
=== modified file 'storage/innobase/xtrabackup/src/xtrabackup.cc'
--- storage/innobase/xtrabackup/src/xtrabackup.cc 2014-09-12 10:09:33 +0000
+++ storage/innobase/xtrabackup/src/xtrabackup.cc 2014-09-20 19:02:31 +0000
@@ -309,6 +309,8 @@
309ds_ctxt_t *ds_data = NULL;309ds_ctxt_t *ds_data = NULL;
310ds_ctxt_t *ds_meta = NULL;310ds_ctxt_t *ds_meta = NULL;
311311
312extern "C" sig_handler handle_fatal_signal(int sig);
313
312/* Simple datasink creation tracking...add datasinks in the reverse order you314/* Simple datasink creation tracking...add datasinks in the reverse order you
313want them destroyed. */315want them destroyed. */
314#define XTRABACKUP_MAX_DATASINKS 10316#define XTRABACKUP_MAX_DATASINKS 10
@@ -5979,8 +5981,23 @@
59795981
5980int main(int argc, char **argv)5982int main(int argc, char **argv)
5981{5983{
5984 struct sigaction sa;
5982 int ho_error;5985 int ho_error;
59835986
5987 /* Print a stacktrace on some signals */
5988 sa.sa_flags = SA_RESETHAND | SA_NODEFER;
5989 sigemptyset(&sa.sa_mask);
5990 sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL);
5991#ifdef HAVE_STACKTRACE
5992 my_init_stacktrace();
5993#endif
5994 sa.sa_handler = handle_fatal_signal;
5995 sigaction(SIGSEGV, &sa, NULL);
5996 sigaction(SIGABRT, &sa, NULL);
5997 sigaction(SIGBUS, &sa, NULL);
5998 sigaction(SIGILL, &sa, NULL);
5999 sigaction(SIGFPE, &sa, NULL);
6000
5984#ifdef __linux__6001#ifdef __linux__
5985 /* Ensure xtrabackup process is killed when the parent one6002 /* Ensure xtrabackup process is killed when the parent one
5986 (innobackupex) is terminated with an unhandled signal */6003 (innobackupex) is terminated with an unhandled signal */
59876004
=== added file 'storage/innobase/xtrabackup/test/t/bug766305.sh'
--- storage/innobase/xtrabackup/test/t/bug766305.sh 1970-01-01 00:00:00 +0000
+++ storage/innobase/xtrabackup/test/t/bug766305.sh 2014-09-20 19:02:31 +0000
@@ -0,0 +1,36 @@
1########################################################################
2# Bug #766305: Use MySQL Code to get stack trace
3########################################################################
4
5start_server --innodb_file_per_table
6
7if [ ${ASAN_OPTIONS:-undefined} = "undefined" ]
8then
9 skip_test "Incompatible with AddressSanitizer"
10fi
11
12mkdir $topdir/backup
13
14xtrabackup --backup --target-dir=$topdir/backup --debug-sync="data_copy_thread_func" &
15
16job_pid=$!
17pid_file=$topdir/backup/xtrabackup_debug_sync
18
19# Wait for xtrabackup to suspend
20i=0
21while [ ! -r "$pid_file" ]
22do
23 sleep 1
24 i=$((i+1))
25 echo "Waited $i seconds for $pid_file to be created"
26done
27
28xb_pid=`cat $pid_file`
29
30kill -SIGSEGV $xb_pid
31kill -SIGCONT $xb_pid
32
33run_cmd_expect_failure wait $job_pid
34
35grep -q "handle_fatal_signal" $OUTFILE || \
36 die "Could not find a resolved stacktrace in the log"

Subscribers

People subscribed via source and target branches

to all changes: