diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2016-12-28 15:54:24 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2016-12-28 15:54:24 +0200 |
commit | d50cf42bc05b1faa5d39c766389ac345e119037e (patch) | |
tree | a5cc81b5d0612dc9a0f1e7d8092005096818420d | |
parent | dc9f5dfcbb8efbc7c1f178313f945981b01d229b (diff) | |
download | mariadb-git-d50cf42bc05b1faa5d39c766389ac345e119037e.tar.gz |
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.
-rw-r--r-- | storage/innobase/api/api0misc.cc | 4 | ||||
-rw-r--r-- | storage/innobase/buf/buf0dblwr.cc | 15 | ||||
-rw-r--r-- | storage/innobase/fil/fil0fil.cc | 2 | ||||
-rw-r--r-- | storage/innobase/include/fts0ast.h | 3 | ||||
-rw-r--r-- | storage/innobase/log/log0log.cc | 20 | ||||
-rw-r--r-- | storage/innobase/os/os0file.cc | 2 | ||||
-rw-r--r-- | storage/innobase/os/os0thread.cc | 6 | ||||
-rw-r--r-- | storage/innobase/row/row0mysql.cc | 4 | ||||
-rw-r--r-- | storage/innobase/row/row0undo.cc | 3 | ||||
-rw-r--r-- | storage/innobase/srv/srv0start.cc | 13 | ||||
-rw-r--r-- | storage/xtradb/api/api0misc.cc | 4 | ||||
-rw-r--r-- | storage/xtradb/buf/buf0dblwr.cc | 15 | ||||
-rw-r--r-- | storage/xtradb/fil/fil0fil.cc | 2 | ||||
-rw-r--r-- | storage/xtradb/include/fts0ast.h | 3 | ||||
-rw-r--r-- | storage/xtradb/log/log0log.cc | 30 | ||||
-rw-r--r-- | storage/xtradb/log/log0online.cc | 19 | ||||
-rw-r--r-- | storage/xtradb/os/os0file.cc | 2 | ||||
-rw-r--r-- | storage/xtradb/os/os0thread.cc | 6 | ||||
-rw-r--r-- | storage/xtradb/row/row0mysql.cc | 4 | ||||
-rw-r--r-- | storage/xtradb/row/row0undo.cc | 3 | ||||
-rw-r--r-- | storage/xtradb/srv/srv0start.cc | 13 |
21 files changed, 40 insertions, 133 deletions
diff --git a/storage/innobase/api/api0misc.cc b/storage/innobase/api/api0misc.cc index a980d32c33f..5daee5de4c9 100644 --- a/storage/innobase/api/api0misc.cc +++ b/storage/innobase/api/api0misc.cc @@ -184,10 +184,6 @@ handle_new_error: 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; diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 16877818ba9..cc5fe52f80a 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -224,12 +224,10 @@ start_again: + 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 @@ start_again: 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 @@ start_again: 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; diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 03f6b9148ba..22352d94332 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -4599,7 +4599,7 @@ will_not_choose: return; } - exit(1); + abort(); } if (def.success && remote.success) { diff --git a/storage/innobase/include/fts0ast.h b/storage/innobase/include/fts0ast.h index 50f62063893..6229869e8d0 100644 --- a/storage/innobase/include/fts0ast.h +++ b/storage/innobase/include/fts0ast.h @@ -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 @@ -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 */ diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 89b616aba01..a8326571366 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -815,24 +815,10 @@ failure: 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); diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 2db53c25b04..46518ef8d35 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -814,7 +814,7 @@ os_file_handle_error_cond_exit( } if (should_exit) { - exit(1); + abort(); } } diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc index a5b0f7de6ae..88f4292d6fe 100644 --- a/storage/innobase/os/os0thread.cc +++ b/storage/innobase/os/os0thread.cc @@ -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); diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 35011247105..1c02590933f 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -660,9 +660,7 @@ handle_new_error: "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" diff --git a/storage/innobase/row/row0undo.cc b/storage/innobase/row/row0undo.cc index 149dc671930..82b1ab049fa 100644 --- a/storage/innobase/row/row0undo.cc +++ b/storage/innobase/row/row0undo.cc @@ -363,8 +363,7 @@ row_undo_step( "InnoDB: Out of tablespace.\n" "InnoDB: Consider increasing" " your tablespace.\n"); - - exit(1); + abort(); } ut_error; diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 1f5d6eef0e8..bbb9dc0205e 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -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 @@ files_checked: /* 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); diff --git a/storage/xtradb/api/api0misc.cc b/storage/xtradb/api/api0misc.cc index a980d32c33f..5daee5de4c9 100644 --- a/storage/xtradb/api/api0misc.cc +++ b/storage/xtradb/api/api0misc.cc @@ -184,10 +184,6 @@ handle_new_error: 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; diff --git a/storage/xtradb/buf/buf0dblwr.cc b/storage/xtradb/buf/buf0dblwr.cc index d8d85c25289..62ed17296f5 100644 --- a/storage/xtradb/buf/buf0dblwr.cc +++ b/storage/xtradb/buf/buf0dblwr.cc @@ -224,12 +224,10 @@ start_again: + 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 @@ start_again: 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 @@ start_again: 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; diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index 28f262b50c7..5900bdb2140 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -4618,7 +4618,7 @@ will_not_choose: return; } - exit(1); + abort(); } if (def.success && remote.success) { diff --git a/storage/xtradb/include/fts0ast.h b/storage/xtradb/include/fts0ast.h index 50f62063893..6229869e8d0 100644 --- a/storage/xtradb/include/fts0ast.h +++ b/storage/xtradb/include/fts0ast.h @@ -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 @@ -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 */ diff --git a/storage/xtradb/log/log0log.cc b/storage/xtradb/log/log0log.cc index a01a2ed9570..f3a3486017c 100644 --- a/storage/xtradb/log/log0log.cc +++ b/storage/xtradb/log/log0log.cc @@ -920,24 +920,10 @@ failure: 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 @@ loop: } 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 diff --git a/storage/xtradb/log/log0online.cc b/storage/xtradb/log/log0online.cc index 2a1ac63dc5b..4e6ad65a906 100644 --- a/storage/xtradb/log/log0online.cc +++ b/storage/xtradb/log/log0online.cc @@ -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 @@ -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) { diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc index 007b100285d..5e107dac0eb 100644 --- a/storage/xtradb/os/os0file.cc +++ b/storage/xtradb/os/os0file.cc @@ -920,7 +920,7 @@ os_file_handle_error_cond_exit( } if (should_exit) { - exit(1); + abort(); } } diff --git a/storage/xtradb/os/os0thread.cc b/storage/xtradb/os/os0thread.cc index af826027efc..5ddc40b0eeb 100644 --- a/storage/xtradb/os/os0thread.cc +++ b/storage/xtradb/os/os0thread.cc @@ -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); diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc index 0bdee1282f8..e53a0ea9586 100644 --- a/storage/xtradb/row/row0mysql.cc +++ b/storage/xtradb/row/row0mysql.cc @@ -1196,9 +1196,7 @@ handle_new_error: "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" diff --git a/storage/xtradb/row/row0undo.cc b/storage/xtradb/row/row0undo.cc index 149dc671930..82b1ab049fa 100644 --- a/storage/xtradb/row/row0undo.cc +++ b/storage/xtradb/row/row0undo.cc @@ -363,8 +363,7 @@ row_undo_step( "InnoDB: Out of tablespace.\n" "InnoDB: Consider increasing" " your tablespace.\n"); - - exit(1); + abort(); } ut_error; diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc index ada91c64524..2dd0285d03f 100644 --- a/storage/xtradb/srv/srv0start.cc +++ b/storage/xtradb/srv/srv0start.cc @@ -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 @@ files_checked: /* 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); |