Merge lp:~percona-dev/percona-xtrabackup/exit_codes into lp:percona-xtrabackup/2.0

Proposed by Aleksandr Kuzminsky
Status: Merged
Approved by: Vadim Tkachenko
Approved revision: no longer in the source branch.
Merged at revision: 208
Proposed branch: lp:~percona-dev/percona-xtrabackup/exit_codes
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 329 lines (+37/-37)
1 file modified
xtrabackup.c (+37/-37)
To merge this branch: bzr merge lp:~percona-dev/percona-xtrabackup/exit_codes
Reviewer Review Type Date Requested Status
Vadim Tkachenko Approve
Review via email: mp+40469@code.launchpad.net

Description of the change

use macroses EXIT_SUCCESS and EXIT_FAILURE as exit codes

To post a comment you must log in.
Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

seem OK

review: Approve
Revision history for this message
Baron Schwartz (baron-xaprb) wrote :

In the original code, there were three magic numbers: 0, 1, and -1. There seemed to be an important difference between -1 and 1, but I have not seen an explanation of it. I tried to document my best guess: http://www.percona.com/docs/wiki/percona-xtrabackup:xtrabackup:exit_codes

I am not sure that both 1 and -1 should be replaced with a single exit code. Maybe we need Yasufumi to explain the difference. It might be important for scripting, cron jobs, etc. At least we should document why it was wrong for them to be different.

Revision history for this message
Vadim Tkachenko (vadim-tk) :
review: Needs Fixing
Revision history for this message
Yasufumi Kinoshita (yasufumi-kinoshita) wrote :

If innobackupex doesn't depend on the code, the change should be OK.

Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

I do not see it used differently in innobackupex

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'xtrabackup.c'
--- xtrabackup.c 2010-11-05 07:48:55 +0000
+++ xtrabackup.c 2010-11-09 18:21:09 +0000
@@ -1062,7 +1062,7 @@
1062 break;1062 break;
1063 case '?':1063 case '?':
1064 usage();1064 usage();
1065 exit(0);1065 exit(EXIT_SUCCESS);
1066 break;1066 break;
1067 default:1067 default:
1068 break;1068 break;
@@ -1612,7 +1612,7 @@
1612 bzero((G_PTR) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));1612 bzero((G_PTR) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
16131613
1614 if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))1614 if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
1615 exit(1);1615 exit(EXIT_FAILURE);
16161616
1617 /* dummy for initialize all_charsets[] */1617 /* dummy for initialize all_charsets[] */
1618 get_charset_name(0);1618 get_charset_name(0);
@@ -2908,7 +2908,7 @@
2908 if (my_setwd(mysql_real_data_home,MYF(MY_WME)))2908 if (my_setwd(mysql_real_data_home,MYF(MY_WME)))
2909 {2909 {
2910 fprintf(stderr, "xtrabackup: cannot my_setwd %s\n", mysql_real_data_home);2910 fprintf(stderr, "xtrabackup: cannot my_setwd %s\n", mysql_real_data_home);
2911 exit(1);2911 exit(EXIT_FAILURE);
2912 }2912 }
2913 fprintf(stderr, "xtrabackup: cd to %s\n", mysql_real_data_home);2913 fprintf(stderr, "xtrabackup: cd to %s\n", mysql_real_data_home);
29142914
@@ -2921,7 +2921,7 @@
29212921
2922 /* initialize components */2922 /* initialize components */
2923 if(innodb_init_param())2923 if(innodb_init_param())
2924 exit(1);2924 exit(EXIT_FAILURE);
29252925
2926 if (srv_file_flush_method_str == NULL) {2926 if (srv_file_flush_method_str == NULL) {
2927 /* These are the default options */2927 /* These are the default options */
@@ -2968,7 +2968,7 @@
2968 fprintf(stderr, 2968 fprintf(stderr,
2969 "xtrabackup: Unrecognized value %s for innodb_flush_method\n",2969 "xtrabackup: Unrecognized value %s for innodb_flush_method\n",
2970 srv_file_flush_method_str);2970 srv_file_flush_method_str);
2971 exit(1);2971 exit(EXIT_FAILURE);
2972 }2972 }
29732973
2974#ifndef INNODB_VERSION_SHORT2974#ifndef INNODB_VERSION_SHORT
@@ -3105,13 +3105,13 @@
3105"xtrabackup: remove old data files which contain your precious data!\n");3105"xtrabackup: remove old data files which contain your precious data!\n");
31063106
3107 //return((int) err);3107 //return((int) err);
3108 exit(1);3108 exit(EXIT_FAILURE);
3109 }3109 }
31103110
3111 /* create_new_db must not be TRUE.. */3111 /* create_new_db must not be TRUE.. */
3112 if (create_new_db) {3112 if (create_new_db) {
3113 fprintf(stderr, "xtrabackup: Something wrong with source files...\n");3113 fprintf(stderr, "xtrabackup: Something wrong with source files...\n");
3114 exit(1);3114 exit(EXIT_FAILURE);
3115 }3115 }
31163116
3117 for (i = 0; i < srv_n_log_files; i++) {3117 for (i = 0; i < srv_n_log_files; i++) {
@@ -3120,7 +3120,7 @@
3120 if (err != DB_SUCCESS) {3120 if (err != DB_SUCCESS) {
31213121
3122 //return((int) err);3122 //return((int) err);
3123 exit(1);3123 exit(EXIT_FAILURE);
3124 }3124 }
31253125
3126 if (log_file_created) {3126 if (log_file_created) {
@@ -3139,14 +3139,14 @@
3139 "xtrabackup: and start the database again.\n");3139 "xtrabackup: and start the database again.\n");
31403140
3141 //return(DB_ERROR);3141 //return(DB_ERROR);
3142 exit(1);3142 exit(EXIT_FAILURE);
3143 }3143 }
3144 }3144 }
31453145
3146 /* log_file_created must not be TRUE, if online */3146 /* log_file_created must not be TRUE, if online */
3147 if (log_file_created) {3147 if (log_file_created) {
3148 fprintf(stderr, "xtrabackup: Something wrong with source files...\n");3148 fprintf(stderr, "xtrabackup: Something wrong with source files...\n");
3149 exit(1);3149 exit(EXIT_FAILURE);
3150 }3150 }
31513151
3152 fil_load_single_table_tablespaces();3152 fil_load_single_table_tablespaces();
@@ -3159,7 +3159,7 @@
3159 if (!my_stat(xtrabackup_target_dir,&stat_info,MYF(0))3159 if (!my_stat(xtrabackup_target_dir,&stat_info,MYF(0))
3160 && (my_mkdir(xtrabackup_target_dir,0777,MYF(0)) < 0)){3160 && (my_mkdir(xtrabackup_target_dir,0777,MYF(0)) < 0)){
3161 fprintf(stderr,"xtrabackup: Error: cannot mkdir %d: %s\n",my_errno,xtrabackup_target_dir);3161 fprintf(stderr,"xtrabackup: Error: cannot mkdir %d: %s\n",my_errno,xtrabackup_target_dir);
3162 exit(1);3162 exit(EXIT_FAILURE);
3163 }3163 }
31643164
3165 } else {3165 } else {
@@ -3204,7 +3204,7 @@
32043204
3205 if (err != DB_SUCCESS) {3205 if (err != DB_SUCCESS) {
32063206
3207 exit(1);3207 exit(EXIT_FAILURE);
3208 }3208 }
3209 3209
3210 log_group_read_checkpoint_info(max_cp_group, max_cp_field);3210 log_group_read_checkpoint_info(max_cp_group, max_cp_field);
@@ -3226,7 +3226,7 @@
32263226
3227 if (err != DB_SUCCESS) {3227 if (err != DB_SUCCESS) {
32283228
3229 exit(1);3229 exit(EXIT_FAILURE);
3230 }3230 }
32313231
3232 log_group_read_checkpoint_info(max_cp_group, max_cp_field);3232 log_group_read_checkpoint_info(max_cp_group, max_cp_field);
@@ -3259,7 +3259,7 @@
3259 fprintf(stderr,3259 fprintf(stderr,
3260"xtrabackup: error: cannot open %s\n",3260"xtrabackup: error: cannot open %s\n",
3261 dst_log_path);3261 dst_log_path);
3262 exit(1);3262 exit(EXIT_FAILURE);
3263 }3263 }
32643264
3265#ifdef USE_POSIX_FADVISE3265#ifdef USE_POSIX_FADVISE
@@ -3292,7 +3292,7 @@
3292 if (!success) {3292 if (!success) {
3293 if (dst_log != -1)3293 if (dst_log != -1)
3294 os_file_close(dst_log);3294 os_file_close(dst_log);
3295 exit(1);3295 exit(EXIT_FAILURE);
3296 }3296 }
32973297
3298 /* start flag */3298 /* start flag */
@@ -3311,7 +3311,7 @@
33113311
3312 /* copy log file by current position */3312 /* copy log file by current position */
3313 if(xtrabackup_copy_logfile(checkpoint_lsn_start, FALSE))3313 if(xtrabackup_copy_logfile(checkpoint_lsn_start, FALSE))
3314 exit(1);3314 exit(EXIT_FAILURE);
33153315
33163316
3317 os_thread_create(log_copying_thread, NULL, &log_copying_thread_id);3317 os_thread_create(log_copying_thread, NULL, &log_copying_thread_id);
@@ -3352,7 +3352,7 @@
3352 && (my_mkdir(path,0777,MYF(0)) < 0)){3352 && (my_mkdir(path,0777,MYF(0)) < 0)){
33533353
3354 fprintf(stderr,"xtrabackup: Error: cannot mkdir %d: %s\n",my_errno,path);3354 fprintf(stderr,"xtrabackup: Error: cannot mkdir %d: %s\n",my_errno,path);
3355 exit(1);3355 exit(EXIT_FAILURE);
3356 }3356 }
3357 }3357 }
33583358
@@ -3365,7 +3365,7 @@
3365 if(xtrabackup_copy_datafile(node)) {3365 if(xtrabackup_copy_datafile(node)) {
3366 if(node->space->id == 0) {3366 if(node->space->id == 0) {
3367 fprintf(stderr,"xtrabackup: Error: failed to copy system datafile.\n");3367 fprintf(stderr,"xtrabackup: Error: failed to copy system datafile.\n");
3368 exit(1);3368 exit(EXIT_FAILURE);
3369 } else {3369 } else {
3370 printf("xtrabackup: Warining: failed to copy, but continuing.\n");3370 printf("xtrabackup: Warining: failed to copy, but continuing.\n");
3371 }3371 }
@@ -3496,7 +3496,7 @@
34963496
3497 if (!log_copying_succeed) {3497 if (!log_copying_succeed) {
3498 fprintf(stderr, "xtrabackup: Error: log_copying_thread failed.\n");3498 fprintf(stderr, "xtrabackup: Error: log_copying_thread failed.\n");
3499 exit(1);3499 exit(EXIT_FAILURE);
3500 }3500 }
35013501
3502 if (!xtrabackup_stream)3502 if (!xtrabackup_stream)
@@ -3793,7 +3793,7 @@
3793 if (my_setwd(mysql_real_data_home,MYF(MY_WME)))3793 if (my_setwd(mysql_real_data_home,MYF(MY_WME)))
3794 {3794 {
3795 fprintf(stderr, "xtrabackup: cannot my_setwd %s\n", mysql_real_data_home);3795 fprintf(stderr, "xtrabackup: cannot my_setwd %s\n", mysql_real_data_home);
3796 exit(1);3796 exit(EXIT_FAILURE);
3797 }3797 }
3798 fprintf(stderr, "xtrabackup: cd to %s\n", mysql_real_data_home);3798 fprintf(stderr, "xtrabackup: cd to %s\n", mysql_real_data_home);
37993799
@@ -3807,14 +3807,14 @@
38073807
3808 /* initialize components */3808 /* initialize components */
3809 if(innodb_init_param())3809 if(innodb_init_param())
3810 exit(1);3810 exit(EXIT_FAILURE);
38113811
3812 fprintf(stderr, "xtrabackup: Starting 'read-only' InnoDB instance to gather index statistics.\n"3812 fprintf(stderr, "xtrabackup: Starting 'read-only' InnoDB instance to gather index statistics.\n"
3813 "xtrabackup: Using %lld bytes for buffer pool (set by --use-memory parameter)\n",3813 "xtrabackup: Using %lld bytes for buffer pool (set by --use-memory parameter)\n",
3814 xtrabackup_use_memory);3814 xtrabackup_use_memory);
38153815
3816 if(innodb_init())3816 if(innodb_init())
3817 exit(1);3817 exit(EXIT_FAILURE);
38183818
3819 fprintf(stdout, "\n\n<INDEX STATISTICS>\n");3819 fprintf(stdout, "\n\n<INDEX STATISTICS>\n");
38203820
@@ -4030,7 +4030,7 @@
40304030
4031 /* shutdown InnoDB */4031 /* shutdown InnoDB */
4032 if(innodb_end())4032 if(innodb_end())
4033 exit(1);4033 exit(EXIT_FAILURE);
4034}4034}
40354035
4036/* ================= prepare ================= */4036/* ================= prepare ================= */
@@ -4742,7 +4742,7 @@
4742 if (my_setwd(xtrabackup_real_target_dir,MYF(MY_WME)))4742 if (my_setwd(xtrabackup_real_target_dir,MYF(MY_WME)))
4743 {4743 {
4744 fprintf(stderr, "xtrabackup: cannot my_setwd %s\n", xtrabackup_real_target_dir);4744 fprintf(stderr, "xtrabackup: cannot my_setwd %s\n", xtrabackup_real_target_dir);
4745 exit(1);4745 exit(EXIT_FAILURE);
4746 }4746 }
4747 fprintf(stderr, "xtrabackup: cd to %s\n", xtrabackup_real_target_dir);4747 fprintf(stderr, "xtrabackup: cd to %s\n", xtrabackup_real_target_dir);
47484748
@@ -4771,14 +4771,14 @@
4771 if (xtrabackup_incremental) {4771 if (xtrabackup_incremental) {
4772 fprintf(stderr,4772 fprintf(stderr,
4773 "xtrabackup: error: applying incremental backup needs target prepared.\n");4773 "xtrabackup: error: applying incremental backup needs target prepared.\n");
4774 exit(1);4774 exit(EXIT_FAILURE);
4775 }4775 }
4776skip_check:4776skip_check:
4777 if (xtrabackup_incremental4777 if (xtrabackup_incremental
4778 && ut_dulint_cmp(metadata_to_lsn, incremental_lsn) < 0) {4778 && ut_dulint_cmp(metadata_to_lsn, incremental_lsn) < 0) {
4779 fprintf(stderr,4779 fprintf(stderr,
4780 "xtrabackup: error: This incremental backup seems to be too new for the target.\n");4780 "xtrabackup: error: This incremental backup seems to be too new for the target.\n");
4781 exit(1);4781 exit(EXIT_FAILURE);
4782 }4782 }
4783 }4783 }
47844784
@@ -5123,7 +5123,7 @@
5123 os_io_init_simple();5123 os_io_init_simple();
51245124
5125 if(xtrabackup_close_temp_log(TRUE))5125 if(xtrabackup_close_temp_log(TRUE))
5126 exit(1);5126 exit(EXIT_FAILURE);
51275127
5128 /* output to metadata file */5128 /* output to metadata file */
5129 {5129 {
@@ -5166,7 +5166,7 @@
5166error:5166error:
5167 xtrabackup_close_temp_log(FALSE);5167 xtrabackup_close_temp_log(FALSE);
51685168
5169 exit(1);5169 exit(EXIT_FAILURE);
5170}5170}
51715171
5172/* ================= main =================== */5172/* ================= main =================== */
@@ -5227,7 +5227,7 @@
5227 if (!xtrabackup_print_param)5227 if (!xtrabackup_print_param)
5228 usage();5228 usage();
5229 printf("\nxtrabackup: Error: Please set parameter 'datadir'\n");5229 printf("\nxtrabackup: Error: Please set parameter 'datadir'\n");
5230 exit(-1);5230 exit(EXIT_FAILURE);
5231 }5231 }
52325232
5233 if (xtrabackup_tables) {5233 if (xtrabackup_tables) {
@@ -5284,7 +5284,7 @@
5284 fp = fopen(xtrabackup_tables_file,"r");5284 fp = fopen(xtrabackup_tables_file,"r");
5285 if (!fp) {5285 if (!fp) {
5286 fprintf(stderr, "xtrabackup: cannot open %s\n", xtrabackup_tables_file);5286 fprintf(stderr, "xtrabackup: cannot open %s\n", xtrabackup_tables_file);
5287 exit(-1);5287 exit(EXIT_FAILURE);
5288 }5288 }
5289 for (;;) {5289 for (;;) {
5290 xtrabackup_tables_t* table;5290 xtrabackup_tables_t* table;
@@ -5363,7 +5363,7 @@
5363 if (error) {5363 if (error) {
5364 fprintf(stderr, "xtrabackup: value '%s' may be wrong format for incremental option.\n",5364 fprintf(stderr, "xtrabackup: value '%s' may be wrong format for incremental option.\n",
5365 xtrabackup_incremental);5365 xtrabackup_incremental);
5366 exit(-1);5366 exit(EXIT_FAILURE);
5367 }5367 }
53685368
5369 /* allocate buffer for incremental backup (4096 pages) */5369 /* allocate buffer for incremental backup (4096 pages) */
@@ -5378,7 +5378,7 @@
5378 fprintf(stderr,5378 fprintf(stderr,
5379 "xtrabackup: error: failed to read metadata from %s\n",5379 "xtrabackup: error: failed to read metadata from %s\n",
5380 filename);5380 filename);
5381 exit(-1);5381 exit(EXIT_FAILURE);
5382 }5382 }
53835383
5384 incremental_lsn = metadata_to_lsn;5384 incremental_lsn = metadata_to_lsn;
@@ -5396,7 +5396,7 @@
5396 fprintf(stderr,5396 fprintf(stderr,
5397 "xtrabackup: error: failed to read metadata from %s\n",5397 "xtrabackup: error: failed to read metadata from %s\n",
5398 filename);5398 filename);
5399 exit(-1);5399 exit(EXIT_FAILURE);
5400 }5400 }
54015401
5402 incremental_lsn = metadata_from_lsn;5402 incremental_lsn = metadata_from_lsn;
@@ -5420,7 +5420,7 @@
5420 bzero((G_PTR) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));5420 bzero((G_PTR) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
54215421
5422 if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))5422 if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
5423 exit(1);5423 exit(EXIT_FAILURE);
54245424
5425 printf("# This MySQL options file was generated by XtraBackup.\n");5425 printf("# This MySQL options file was generated by XtraBackup.\n");
5426 printf("[mysqld]\n");5426 printf("[mysqld]\n");
@@ -5434,7 +5434,7 @@
5434 innobase_log_group_home_dir ? innobase_log_group_home_dir : mysql_data_home);5434 innobase_log_group_home_dir ? innobase_log_group_home_dir : mysql_data_home);
5435 printf("innodb_log_files_in_group = %ld\n", innobase_log_files_in_group);5435 printf("innodb_log_files_in_group = %ld\n", innobase_log_files_in_group);
5436 printf("innodb_log_file_size = %lld\n", innobase_log_file_size);5436 printf("innodb_log_file_size = %lld\n", innobase_log_file_size);
5437 exit(0);5437 exit(EXIT_SUCCESS);
5438 }5438 }
54395439
5440 if (!xtrabackup_stream) {5440 if (!xtrabackup_stream) {
@@ -5464,7 +5464,7 @@
5464 if (xtrabackup_prepare) num++;5464 if (xtrabackup_prepare) num++;
5465 if (num != 1) { /* !XOR (for now) */5465 if (num != 1) { /* !XOR (for now) */
5466 usage();5466 usage();
5467 exit(-1);5467 exit(EXIT_FAILURE);
5468 }5468 }
5469 }5469 }
54705470
@@ -5516,5 +5516,5 @@
5516 hash_table_free(tables_hash);5516 hash_table_free(tables_hash);
5517 }5517 }
55185518
5519 exit(0);5519 exit(EXIT_SUCCESS);
5520}5520}

Subscribers

People subscribed via source and target branches