Commit d50cf42b authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-9282 Debian: the Lintian complains about "shlib-calls-exit" in ha_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.
parent dc9f5dfc
......@@ -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;
......
......@@ -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,
......@@ -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;
......@@ -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;
......
......@@ -4599,7 +4599,7 @@ fil_load_single_table_tablespace(
return;
}
exit(1);
abort();
}
if (def.success && remote.success) {
......
/*****************************************************************************
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
......@@ -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 */
......
......@@ -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);
......
......@@ -814,7 +814,7 @@ os_file_handle_error_cond_exit(
}
if (should_exit) {
exit(1);
abort();
}
}
......
......@@ -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);
......
......@@ -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"
......
......@@ -363,8 +363,7 @@ row_undo_step(
"InnoDB: Out of tablespace.\n"
"InnoDB: Consider increasing"
" your tablespace.\n");
exit(1);
abort();
}
ut_error;
......
......@@ -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
......@@ -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);
......
......@@ -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;
......
......@@ -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,
......@@ -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;
......@@ -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;
......
......@@ -4618,7 +4618,7 @@ fil_load_single_table_tablespace(
return;
}
exit(1);
abort();
}
if (def.success && remote.success) {
......
/*****************************************************************************
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
......@@ -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 */
......
......@@ -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);
......@@ -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
......
/*****************************************************************************
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
......@@ -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)
......@@ -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,
......@@ -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) {
......@@ -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 {
......@@ -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) {
......
......@@ -920,7 +920,7 @@ os_file_handle_error_cond_exit(
}
if (should_exit) {
exit(1);
abort();
}
}
......
......@@ -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);
......
......@@ -1196,9 +1196,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"
......
......@@ -363,8 +363,7 @@ row_undo_step(
"InnoDB: Out of tablespace.\n"
"InnoDB: Consider increasing"
" your tablespace.\n");
exit(1);
abort();
}
ut_error;
......
......@@ -630,7 +630,7 @@ create_log_file(
fprintf(stderr, "innodb_force_recovery_crash=%lu\n", \
srv_force_recovery_crash); \
fflush(stderr); \
exit(3); \
abort(); \
} \
} while (0)
#endif
......@@ -2979,16 +2979,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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment