Skip to content

Commit

Permalink
MDEV-9282 Debian: the Lintian complains about "shlib-calls-exit" in h…
Browse files Browse the repository at this point in the history
…a_innodb.so

Replace all exit() calls in InnoDB with abort() [possibly via ut_a()].
Calling exit() in a multi-threaded program is problematic also for
the reason that other threads could see corrupted data structures
while some data structures are being cleaned up by atexit() handlers
or similar.

In the long term, all these calls should be replaced with something
that returns an error all the way up the call stack.
  • Loading branch information
dr-m committed Dec 28, 2016
1 parent dc9f5df commit d50cf42
Show file tree
Hide file tree
Showing 21 changed files with 40 additions and 133 deletions.
4 changes: 0 additions & 4 deletions storage/innobase/api/api0misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@ ib_handle_errors(
trx_rollback_for_mysql(trx);
break;

case DB_MUST_GET_MORE_FILE_SPACE:

exit(1);

case DB_CORRUPTION:
case DB_FOREIGN_EXCEED_MAX_CASCADE:
break;
Expand Down
15 changes: 3 additions & 12 deletions storage/innobase/buf/buf0dblwr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,10 @@ buf_dblwr_create(void)
+ FSP_EXTENT_SIZE / 2 + 100)
* UNIV_PAGE_SIZE)) {

ib_logf(IB_LOG_LEVEL_ERROR,
ib_logf(IB_LOG_LEVEL_FATAL,
"Cannot create doublewrite buffer: you must "
"increase your buffer pool size. Cannot continue "
"operation.");

exit(EXIT_FAILURE);
}

block2 = fseg_create(TRX_SYS_SPACE, TRX_SYS_PAGE_NO,
Expand All @@ -242,15 +240,10 @@ buf_dblwr_create(void)
buf_block_dbg_add_level(block2, SYNC_NO_ORDER_CHECK);

if (block2 == NULL) {
ib_logf(IB_LOG_LEVEL_ERROR,
ib_logf(IB_LOG_LEVEL_FATAL,
"Cannot create doublewrite buffer: you must "
"increase your tablespace size. "
"Cannot continue operation.");

/* We exit without committing the mtr to prevent
its modifications to the database getting to disk */

exit(EXIT_FAILURE);
}

fseg_header = doublewrite + TRX_SYS_DOUBLEWRITE_FSEG;
Expand All @@ -261,12 +254,10 @@ buf_dblwr_create(void)
new_block = fseg_alloc_free_page(
fseg_header, prev_page_no + 1, FSP_UP, &mtr);
if (new_block == NULL) {
ib_logf(IB_LOG_LEVEL_ERROR,
ib_logf(IB_LOG_LEVEL_FATAL,
"Cannot create doublewrite buffer: you must "
"increase your tablespace size. "
"Cannot continue operation.");

exit(EXIT_FAILURE);
}

/* We read the allocated pages to the buffer pool;
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 @@ -4599,7 +4599,7 @@ fil_load_single_table_tablespace(
return;
}

exit(1);
abort();
}

if (def.success && remote.success) {
Expand Down
3 changes: 3 additions & 0 deletions storage/innobase/include/fts0ast.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2016, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -29,6 +30,8 @@ Created 2007/03/16/03 Sunny Bains
#include "mem0mem.h"
#include "ha_prototypes.h"

#define exit(x) abort()

/* The type of AST Node */
enum fts_ast_type_t {
FTS_AST_OPER, /*!< Operator */
Expand Down
20 changes: 3 additions & 17 deletions storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -815,24 +815,10 @@ log_calc_max_ages(void)
mutex_exit(&(log_sys->mutex));

if (!success) {
fprintf(stderr,
"InnoDB: Error: ib_logfiles are too small"
" for innodb_thread_concurrency %lu.\n"
"InnoDB: The combined size of ib_logfiles"
ib_logf(IB_LOG_LEVEL_FATAL,
"The combined size of ib_logfiles"
" should be bigger than\n"
"InnoDB: 200 kB * innodb_thread_concurrency.\n"
"InnoDB: To get mysqld to start up, set"
" innodb_thread_concurrency in my.cnf\n"
"InnoDB: to a lower value, for example, to 8."
" After an ERROR-FREE shutdown\n"
"InnoDB: of mysqld you can adjust the size of"
" ib_logfiles, as explained in\n"
"InnoDB: " REFMAN "adding-and-removing.html\n"
"InnoDB: Cannot continue operation."
" Calling exit(1).\n",
(ulong) srv_thread_concurrency);

exit(1);
"InnoDB: 200 kB * innodb_thread_concurrency.");
}

return(success);
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ os_file_handle_error_cond_exit(
}

if (should_exit) {
exit(1);
abort();
}
}

Expand Down
6 changes: 1 addition & 5 deletions storage/innobase/os/os0thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ os_thread_create_func(
#else
ret = pthread_create(&pthread, &attr, func, arg);
#endif
if (ret) {
fprintf(stderr,
"InnoDB: Error: pthread_create returned %d\n", ret);
exit(1);
}
ut_a(ret == 0);

#ifndef UNIV_HPUX10
pthread_attr_destroy(&attr);
Expand Down
4 changes: 1 addition & 3 deletions storage/innobase/row/row0mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,7 @@ row_mysql_handle_errors(
"InnoDB: lack of space. You must add"
" a new data file to\n"
"InnoDB: my.cnf and restart the database.\n", stderr);

ut_ad(0);
exit(1);
abort();

case DB_CORRUPTION:
fputs("InnoDB: We detected index corruption"
Expand Down
3 changes: 1 addition & 2 deletions storage/innobase/row/row0undo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ row_undo_step(
"InnoDB: Out of tablespace.\n"
"InnoDB: Consider increasing"
" your tablespace.\n");

exit(1);
abort();
}

ut_error;
Expand Down
13 changes: 2 additions & 11 deletions storage/innobase/srv/srv0start.cc
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ create_log_file(
fprintf(stderr, "innodb_force_recovery_crash=%lu\n", \
srv_force_recovery_crash); \
fflush(stderr); \
exit(3); \
abort(); \
} \
} while (0)
#endif
Expand Down Expand Up @@ -2912,16 +2912,7 @@ innobase_start_or_create_for_mysql(void)
/* Check that os_fast_mutexes work as expected */
os_fast_mutex_init(PFS_NOT_INSTRUMENTED, &srv_os_test_mutex);

if (0 != os_fast_mutex_trylock(&srv_os_test_mutex)) {
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Error: pthread_mutex_trylock returns"
" an unexpected value on\n");
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: success! Cannot continue.\n");
exit(1);
}
ut_a(0 == os_fast_mutex_trylock(&srv_os_test_mutex));

os_fast_mutex_unlock(&srv_os_test_mutex);

Expand Down
4 changes: 0 additions & 4 deletions storage/xtradb/api/api0misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@ ib_handle_errors(
trx_rollback_for_mysql(trx);
break;

case DB_MUST_GET_MORE_FILE_SPACE:

exit(1);

case DB_CORRUPTION:
case DB_FOREIGN_EXCEED_MAX_CASCADE:
break;
Expand Down
15 changes: 3 additions & 12 deletions storage/xtradb/buf/buf0dblwr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,10 @@ buf_dblwr_create(void)
+ FSP_EXTENT_SIZE / 2 + 100)
* UNIV_PAGE_SIZE)) {

ib_logf(IB_LOG_LEVEL_ERROR,
ib_logf(IB_LOG_LEVEL_FATAL,
"Cannot create doublewrite buffer: you must "
"increase your buffer pool size. Cannot continue "
"operation.");

exit(EXIT_FAILURE);
}

block2 = fseg_create(TRX_SYS_SPACE, TRX_SYS_PAGE_NO,
Expand All @@ -242,15 +240,10 @@ buf_dblwr_create(void)
buf_block_dbg_add_level(block2, SYNC_NO_ORDER_CHECK);

if (block2 == NULL) {
ib_logf(IB_LOG_LEVEL_ERROR,
ib_logf(IB_LOG_LEVEL_FATAL,
"Cannot create doublewrite buffer: you must "
"increase your tablespace size. "
"Cannot continue operation.");

/* We exit without committing the mtr to prevent
its modifications to the database getting to disk */

exit(EXIT_FAILURE);
}

fseg_header = doublewrite + TRX_SYS_DOUBLEWRITE_FSEG;
Expand All @@ -261,12 +254,10 @@ buf_dblwr_create(void)
new_block = fseg_alloc_free_page(
fseg_header, prev_page_no + 1, FSP_UP, &mtr);
if (new_block == NULL) {
ib_logf(IB_LOG_LEVEL_ERROR,
ib_logf(IB_LOG_LEVEL_FATAL,
"Cannot create doublewrite buffer: you must "
"increase your tablespace size. "
"Cannot continue operation.");

exit(EXIT_FAILURE);
}

/* We read the allocated pages to the buffer pool;
Expand Down
2 changes: 1 addition & 1 deletion storage/xtradb/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4618,7 +4618,7 @@ fil_load_single_table_tablespace(
return;
}

exit(1);
abort();
}

if (def.success && remote.success) {
Expand Down
3 changes: 3 additions & 0 deletions storage/xtradb/include/fts0ast.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2016, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -29,6 +30,8 @@ Created 2007/03/16/03 Sunny Bains
#include "mem0mem.h"
#include "ha_prototypes.h"

#define exit(x) abort()

/* The type of AST Node */
enum fts_ast_type_t {
FTS_AST_OPER, /*!< Operator */
Expand Down
30 changes: 5 additions & 25 deletions storage/xtradb/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -920,24 +920,10 @@ log_calc_max_ages(void)
mutex_exit(&(log_sys->mutex));

if (!success) {
fprintf(stderr,
"InnoDB: Error: ib_logfiles are too small"
" for innodb_thread_concurrency %lu.\n"
"InnoDB: The combined size of ib_logfiles"
ib_logf(IB_LOG_LEVEL_FATAL,
"The combined size of ib_logfiles"
" should be bigger than\n"
"InnoDB: 200 kB * innodb_thread_concurrency.\n"
"InnoDB: To get mysqld to start up, set"
" innodb_thread_concurrency in my.cnf\n"
"InnoDB: to a lower value, for example, to 8."
" After an ERROR-FREE shutdown\n"
"InnoDB: of mysqld you can adjust the size of"
" ib_logfiles, as explained in\n"
"InnoDB: " REFMAN "adding-and-removing.html\n"
"InnoDB: Cannot continue operation."
" Calling exit(1).\n",
(ulong) srv_thread_concurrency);

exit(1);
"InnoDB: 200 kB * innodb_thread_concurrency.");
}

return(success);
Expand Down Expand Up @@ -2861,15 +2847,9 @@ log_group_archive(
}

if (!ret) {
fprintf(stderr,
ib_logf(IB_LOG_LEVEL_FATAL,
"InnoDB: Cannot create or open"
" archive log file %s.\n"
"InnoDB: Cannot continue operation.\n"
"InnoDB: Check that the log archive"
" directory exists,\n"
"InnoDB: you have access rights to it, and\n"
"InnoDB: there is space available.\n", name);
exit(1);
" archive log file %s.\n", name);
}

#ifdef UNIV_DEBUG
Expand Down
19 changes: 6 additions & 13 deletions storage/xtradb/log/log0online.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*****************************************************************************

Copyright (c) 2011-2012 Percona Inc. All Rights Reserved.
Copyright (C) 2016, MariaDB Corporation.

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -405,12 +406,11 @@ log_online_can_track_missing(
last_tracked_lsn = ut_max(last_tracked_lsn, MIN_TRACKED_LSN);

if (last_tracked_lsn > tracking_start_lsn) {
ib_logf(IB_LOG_LEVEL_ERROR,
ib_logf(IB_LOG_LEVEL_FATAL,
"last tracked LSN " LSN_PF " is ahead of tracking "
"start LSN " LSN_PF ". This can be caused by "
"mismatched bitmap files.",
last_tracked_lsn, tracking_start_lsn);
exit(1);
}

return (last_tracked_lsn == tracking_start_lsn)
Expand Down Expand Up @@ -450,9 +450,7 @@ log_online_track_missing_on_startup(
log_bmp_sys->start_lsn = ut_max(last_tracked_lsn,
MIN_TRACKED_LSN);
log_set_tracked_lsn(log_bmp_sys->start_lsn);
if (!log_online_follow_redo_log()) {
exit(1);
}
ut_a(log_online_follow_redo_log());
ut_ad(log_bmp_sys->end_lsn >= tracking_start_lsn);

ib_logf(IB_LOG_LEVEL_INFO,
Expand Down Expand Up @@ -677,9 +675,8 @@ log_online_read_init(void)

if (os_file_closedir(bitmap_dir)) {
os_file_get_last_error(TRUE);
ib_logf(IB_LOG_LEVEL_ERROR, "cannot close \'%s\'",
ib_logf(IB_LOG_LEVEL_FATAL, "cannot close \'%s\'",
log_bmp_sys->bmp_file_home);
exit(1);
}

if (!log_bmp_sys->out_seq_num) {
Expand All @@ -699,9 +696,7 @@ log_online_read_init(void)
if (!success) {

/* New file, tracking from scratch */
if (!log_online_start_bitmap_file()) {
exit(1);
}
ut_a(log_online_start_bitmap_file());
}
else {

Expand Down Expand Up @@ -738,9 +733,7 @@ log_online_read_init(void)
} else {
file_start_lsn = tracking_start_lsn;
}
if (!log_online_rotate_bitmap_file(file_start_lsn)) {
exit(1);
}
ut_a(log_online_rotate_bitmap_file(file_start_lsn));

if (last_tracked_lsn < tracking_start_lsn) {

Expand Down
2 changes: 1 addition & 1 deletion storage/xtradb/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ os_file_handle_error_cond_exit(
}

if (should_exit) {
exit(1);
abort();
}
}

Expand Down
6 changes: 1 addition & 5 deletions storage/xtradb/os/os0thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,7 @@ os_thread_create_func(
#else
ret = pthread_create(&pthread, &attr, func, arg);
#endif
if (ret) {
fprintf(stderr,
"InnoDB: Error: pthread_create returned %d\n", ret);
exit(1);
}
ut_a(ret == 0);

#ifndef UNIV_HPUX10
pthread_attr_destroy(&attr);
Expand Down
Loading

0 comments on commit d50cf42

Please sign in to comment.