Skip to content

Commit

Permalink
Revert "Print stack traces before committing suicide"
Browse files Browse the repository at this point in the history
Summary:
This reverts commit 02473a2.

We have 3 stack traces every time we crash, which is too much noise. Using pstack never seemed to have worked anyway.

Reviewed By: hermanlee

Differential Revision: D6718182

fbshipit-source-id: 83ea751
  • Loading branch information
lth authored and facebook-github-bot committed Jan 16, 2018
1 parent eb5874c commit c58fbfc
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 113 deletions.
19 changes: 0 additions & 19 deletions include/my_stacktrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,6 @@ void my_write_core(int sig);
#endif


/* print stack traces for all threads */
void my_pstack();

/* print stack traces for all threads before assert failures */
#define assert_with_stack_traces(expr) \
do { if(!(expr)) { my_pstack(); assert(0); } } while(0)

/* print stack traces for all threads before abort. Please note
that when using this with ; in the end, a null statement will
be generated in the end. It is fine as long as compilers don't
complain.
*/

#define abort_with_stack_traces() \
{ my_pstack(); abort(); }

#define assert_0_with_stack_traces() \
{ my_pstack(); assert(0); }


/**
Async-signal-safe utility functions used by signal handler routines.
Expand Down
58 changes: 0 additions & 58 deletions mysys/stacktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,64 +473,6 @@ void my_write_core(int sig)
#endif
}


/* print stack traces for all threads */
void my_pstack()
{
#ifndef __WIN__
/* Print out the current stack trace */

static const int max_num_of_frames = 100;
void *stack_trace[max_num_of_frames];
int num_of_frames = backtrace(stack_trace, max_num_of_frames);
char **frames = backtrace_symbols(stack_trace, num_of_frames);
if (!frames)
{
my_safe_printf_stderr("backtrace_symbols didn't return valid data.");
return;
}

my_safe_printf_stderr("\nThe current stack traces:\n");
for (int i = 0; i < num_of_frames; ++i)
{
my_safe_printf_stderr("%s\n", frames[i]);
}
free(frames);

/* Print out all the stack traces */

char cmd[64];
pid_t pid = getpid();
sprintf(cmd, "pstack %d", pid);

my_safe_printf_stderr("\nAll stack traces from %s:\n", cmd);
FILE *fp = popen(cmd, "r");
if (!fp)
{
my_safe_printf_stderr("Couldn't run \"%s\" by popen.\n", cmd);
return;
}

static const size_t max_line_length = 4095;
char line_buf[max_line_length + 1];
uint output_lines = 0;
while (fgets(line_buf, max_line_length, fp))
{
my_write_stderr(line_buf, strlen(line_buf));
++output_lines;
}
fclose(fp);
if (0 == output_lines)
{
my_safe_printf_stderr("No stack traces were printed out. "
"This probably was because mysqld didn't have "
"sufficient privileges, and/or some required system "
"settings (suid_dumpable, ulimit, etc...) were not "
"set correctly.\n");
}
#endif /* not __WIN__ */
}

#else /* __WIN__*/

#include <dbghelp.h>
Expand Down
2 changes: 1 addition & 1 deletion sql/error_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void init_global_error_stats(void)
for (uint j = 0; j < (uint)errmsg_section_size[i]; j++) {
if (k >= array_elements(error_names) ||
error_names[k].code != errmsg_section_start[i] + j) {
abort_with_stack_traces();
abort();
}
k++;
}
Expand Down
3 changes: 1 addition & 2 deletions sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "sql_join_buffer.h" // JOIN_CACHE
#include "sql_optimizer.h" // JOIN
#include "sql_tmp_table.h" // tmp tables
#include "my_stacktrace.h" // abort_with_stack_traces

#ifdef TARGET_OS_LINUX
#include <sys/syscall.h>
Expand Down Expand Up @@ -2962,7 +2961,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
DBUG_PRINT("error",("Table type %d found",tab->type)); /* purecov: deadcode */
break; /* purecov: deadcode */
case JT_UNKNOWN:
abort_with_stack_traces(); /* purecov: deadcode */
abort(); /* purecov: deadcode */
}
// Materialize derived tables prior to accessing them.
if (tab->table->pos_in_table_list->uses_materialization())
Expand Down
4 changes: 2 additions & 2 deletions sql/srv_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Auto_rw_lock_read
rw_lock = lock;
else {
my_safe_printf_stderr("Failed to initialize Auto_rw_lock_read");
abort_with_stack_traces();
abort();
}
}

Expand All @@ -87,7 +87,7 @@ class Auto_rw_lock_write
rw_lock = lock;
else {
my_safe_printf_stderr("Failed to initialize Auto_rw_lock_write");
abort_with_stack_traces();
abort();
}
}

Expand Down
3 changes: 1 addition & 2 deletions sql/table_stats.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "sql_base.h"
#include "sql_show.h"
#include "my_atomic.h"
#include "my_stacktrace.h" // abort_with_stack_traces

HASH global_table_stats;

Expand Down Expand Up @@ -256,7 +255,7 @@ void init_global_table_stats(void)
0, 0, (my_hash_get_key)get_key_table_stats,
(my_hash_free_key)free_table_stats, 0)) {
sql_print_error("Initializing global_table_stats failed.");
abort_with_stack_traces();
abort();
}
}

Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/buf/buf0buf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ buf_page_is_corrupted(
read_buf + FIL_PAGE_LSN),
current_lsn);
#ifdef XTRABACKUP
abort_with_stack_traces();
abort();
#endif /* XTRABACKUP */
}
}
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6315,7 +6315,7 @@ _fil_io(
if (space->size > 0 && space->size <= block_offset) {
ulint actual_size;

assert_with_stack_traces(block_offset < 512 * 1024 * 1024);
assert(block_offset < 512 * 1024 * 1024);

mutex_exit(&fil_system->mutex);
fil_extend_space_to_desired_size(&actual_size, space->id,
Expand Down
6 changes: 2 additions & 4 deletions storage/innobase/include/ut0dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ Created 1/30/1994 Heikki Tuuri
#ifndef ut0dbg_h
#define ut0dbg_h

#include "my_stacktrace.h" // assert_0_with_stack_traces

#ifdef UNIV_INNOCHECKSUM
#define ut_a assert
#define ut_ad assert
#define ut_error assert_0_with_stack_traces()
#define ut_error assert(0)
#else /* !UNIV_INNOCHECKSUM */

#include "univ.i"
Expand Down Expand Up @@ -64,7 +62,7 @@ ut_dbg_assertion_failed(
UNIV_COLD MY_ATTRIBUTE((nonnull(2)));

/** Abort the execution. */
# define UT_DBG_PANIC abort_with_stack_traces()
# define UT_DBG_PANIC abort()

/** Abort execution if EXPR does not evaluate to nonzero.
@param EXPR assertion expression that should hold */
Expand Down
5 changes: 2 additions & 3 deletions storage/innobase/include/ut0rbt.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ Created 2007-03-20 Sunny Bains
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "my_stacktrace.h" //assert_with_stack_traces,assert_0_with_stack_traces

#define ut_malloc malloc
#define ut_free free
#define ulint unsigned long
#define ut_a(c) assert_with_stack_traces(c)
#define ut_error assert_0_with_stack_traces()
#define ut_a(c) assert(c)
#define ut_error assert(0)
#define ibool unsigned int
#define TRUE 1
#define FALSE 0
Expand Down
2 changes: 1 addition & 1 deletion storage/rocksdb/event_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void Rdb_event_listener::OnBackgroundError(
sql_print_error("RocksDB: BackgroundErrorReason: %d", (int)reason);
if (status->IsCorruption()) {
rdb_persist_corruption_marker();
abort_with_stack_traces();
abort();
}
}
} // namespace myrocks
12 changes: 6 additions & 6 deletions storage/rocksdb/ha_rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4710,7 +4710,7 @@ static ulonglong rdb_get_int_col_max_value(const Field *field) {
max_value = 0x7FFFFFFFFFFFFFFFULL;
break;
default:
abort_with_stack_traces();
abort();
}

return max_value;
Expand Down Expand Up @@ -10235,7 +10235,7 @@ void Rdb_drop_index_thread::run() {
"from cf id %u. MyRocks data dictionary may "
"get corrupted.",
d.cf_id);
abort_with_stack_traces();
abort();
}
rocksdb::ColumnFamilyHandle *cfh = cf_manager.get_cf(d.cf_id);
DBUG_ASSERT(cfh);
Expand Down Expand Up @@ -12333,7 +12333,7 @@ void rdb_handle_io_error(const rocksdb::Status status,
rdb_log_status_error(status, "failed to write to WAL");
/* NO_LINT_DEBUG */
sql_print_error("MyRocks: aborting on WAL write error.");
abort_with_stack_traces();
abort();
break;
}
case RDB_IO_ERROR_BG_THREAD: {
Expand All @@ -12344,7 +12344,7 @@ void rdb_handle_io_error(const rocksdb::Status status,
rdb_log_status_error(status, "failed on I/O");
/* NO_LINT_DEBUG */
sql_print_error("MyRocks: aborting on I/O error.");
abort_with_stack_traces();
abort();
break;
}
default:
Expand All @@ -12356,14 +12356,14 @@ void rdb_handle_io_error(const rocksdb::Status status,
rdb_persist_corruption_marker();
/* NO_LINT_DEBUG */
sql_print_error("MyRocks: aborting because of data corruption.");
abort_with_stack_traces();
abort();
} else if (!status.ok()) {
switch (err_type) {
case RDB_IO_ERROR_DICT_COMMIT: {
rdb_log_status_error(status, "Failed to write to WAL (dictionary)");
/* NO_LINT_DEBUG */
sql_print_error("MyRocks: aborting on WAL write error.");
abort_with_stack_traces();
abort();
break;
}
default:
Expand Down
4 changes: 2 additions & 2 deletions storage/rocksdb/properties_collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void Rdb_tbl_prop_coll::CollectStatsForRow(const rocksdb::Slice &key,
sql_print_error("RocksDB: Unexpected entry type found: %u. "
"This should not happen so aborting the system.",
type);
abort_with_stack_traces();
abort();
break;
}

Expand Down Expand Up @@ -362,7 +362,7 @@ int Rdb_index_stats::unmaterialize(const std::string &s,
sql_print_error("Index stats version %d was outside of supported range. "
"This should not happen so aborting the system.",
version);
abort_with_stack_traces();
abort();
}

size_t needed = sizeof(stats.m_gl_index_id.cf_id) +
Expand Down
2 changes: 1 addition & 1 deletion storage/rocksdb/rdb_compact_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class Rdb_compact_filter : public rocksdb::CompactionFilter {
sql_print_error("Decoding ttl from PK value failed in compaction filter, "
"for index (%u,%u), val: %s",
m_prev_index.cf_id, m_prev_index.index_id, buf.c_str());
abort_with_stack_traces();
abort();
}

/*
Expand Down
8 changes: 4 additions & 4 deletions storage/rocksdb/rdb_datadic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3501,7 +3501,7 @@ GL_INDEX_ID Rdb_tbl_def::get_autoincr_gl_index_id() {
}

// Every table must have a primary key, even if it's hidden.
abort_with_stack_traces();
abort();
return GL_INDEX_ID();
}

Expand Down Expand Up @@ -4780,7 +4780,7 @@ bool Rdb_dict_manager::get_index_info(
"and it may be a bug.",
index_info->m_index_dict_version, index_info->m_index_type,
index_info->m_kv_version, index_info->m_ttl_duration);
abort_with_stack_traces();
abort();
}

return found;
Expand Down Expand Up @@ -5043,7 +5043,7 @@ void Rdb_dict_manager::resume_drop_indexes() const {
"bug.",
max_index_id_in_dict, gl_index_id.cf_id,
gl_index_id.index_id);
abort_with_stack_traces();
abort();
}
}
}
Expand Down Expand Up @@ -5092,7 +5092,7 @@ void Rdb_dict_manager::log_start_drop_index(GL_INDEX_ID gl_index_id,
"from index id (%u,%u). MyRocks data dictionary may "
"get corrupted.",
gl_index_id.cf_id, gl_index_id.index_id);
abort_with_stack_traces();
abort();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions storage/rocksdb/rdb_datadic.h
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ class Rdb_system_merge_op : public rocksdb::AssociativeMergeOperator {
value.size() !=
RDB_SIZEOF_AUTO_INCREMENT_VERSION + ROCKSDB_SIZEOF_AUTOINC_VALUE ||
GetVersion(value) > Rdb_key_def::AUTO_INCREMENT_VERSION) {
abort_with_stack_traces();
abort();
}

uint64_t merged_value = Deserialize(value);
Expand All @@ -1428,7 +1428,7 @@ class Rdb_system_merge_op : public rocksdb::AssociativeMergeOperator {
if (existing_value->size() != RDB_SIZEOF_AUTO_INCREMENT_VERSION +
ROCKSDB_SIZEOF_AUTOINC_VALUE ||
GetVersion(*existing_value) > Rdb_key_def::AUTO_INCREMENT_VERSION) {
abort_with_stack_traces();
abort();
}

merged_value = std::max(merged_value, Deserialize(*existing_value));
Expand Down
2 changes: 1 addition & 1 deletion storage/rocksdb/rdb_i_s.cc
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ static int rdb_i_s_global_info_fill_table(
"from CF with id = %u. MyRocks data dictionary may "
"be corrupted.",
cf_handle->GetID());
abort_with_stack_traces();
abort();
}

snprintf(cf_id_buf, INT_BUF_LEN, "%u", cf_handle->GetID());
Expand Down
2 changes: 1 addition & 1 deletion storage/rocksdb/rdb_io_watchdog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void Rdb_io_watchdog::expire_io_callback(union sigval timer_data) {
"Shutting the service down.",
m_write_timeout);

abort_with_stack_traces();
abort();
}

void Rdb_io_watchdog::io_check_callback(union sigval timer_data) {
Expand Down
4 changes: 2 additions & 2 deletions storage/rocksdb/rdb_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace myrocks {
do { \
if (!(expr)) { \
my_safe_printf_stderr("\nShip assert failure: \'%s\'\n", #expr); \
abort_with_stack_traces(); \
abort(); \
} \
} while (0)
#endif // SHIP_ASSERT
Expand Down Expand Up @@ -235,7 +235,7 @@ inline void rdb_check_mutex_call_result(const char *function_name,

// This will hopefully result in a meaningful stack trace which we can use
// to efficiently debug the root cause.
abort_with_stack_traces();
abort();
}
}

Expand Down

0 comments on commit c58fbfc

Please sign in to comment.