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
1=== modified file 'xtrabackup.c'
2--- xtrabackup.c 2010-11-05 07:48:55 +0000
3+++ xtrabackup.c 2010-11-09 18:21:09 +0000
4@@ -1062,7 +1062,7 @@
5 break;
6 case '?':
7 usage();
8- exit(0);
9+ exit(EXIT_SUCCESS);
10 break;
11 default:
12 break;
13@@ -1612,7 +1612,7 @@
14 bzero((G_PTR) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
15
16 if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
17- exit(1);
18+ exit(EXIT_FAILURE);
19
20 /* dummy for initialize all_charsets[] */
21 get_charset_name(0);
22@@ -2908,7 +2908,7 @@
23 if (my_setwd(mysql_real_data_home,MYF(MY_WME)))
24 {
25 fprintf(stderr, "xtrabackup: cannot my_setwd %s\n", mysql_real_data_home);
26- exit(1);
27+ exit(EXIT_FAILURE);
28 }
29 fprintf(stderr, "xtrabackup: cd to %s\n", mysql_real_data_home);
30
31@@ -2921,7 +2921,7 @@
32
33 /* initialize components */
34 if(innodb_init_param())
35- exit(1);
36+ exit(EXIT_FAILURE);
37
38 if (srv_file_flush_method_str == NULL) {
39 /* These are the default options */
40@@ -2968,7 +2968,7 @@
41 fprintf(stderr,
42 "xtrabackup: Unrecognized value %s for innodb_flush_method\n",
43 srv_file_flush_method_str);
44- exit(1);
45+ exit(EXIT_FAILURE);
46 }
47
48 #ifndef INNODB_VERSION_SHORT
49@@ -3105,13 +3105,13 @@
50 "xtrabackup: remove old data files which contain your precious data!\n");
51
52 //return((int) err);
53- exit(1);
54+ exit(EXIT_FAILURE);
55 }
56
57 /* create_new_db must not be TRUE.. */
58 if (create_new_db) {
59 fprintf(stderr, "xtrabackup: Something wrong with source files...\n");
60- exit(1);
61+ exit(EXIT_FAILURE);
62 }
63
64 for (i = 0; i < srv_n_log_files; i++) {
65@@ -3120,7 +3120,7 @@
66 if (err != DB_SUCCESS) {
67
68 //return((int) err);
69- exit(1);
70+ exit(EXIT_FAILURE);
71 }
72
73 if (log_file_created) {
74@@ -3139,14 +3139,14 @@
75 "xtrabackup: and start the database again.\n");
76
77 //return(DB_ERROR);
78- exit(1);
79+ exit(EXIT_FAILURE);
80 }
81 }
82
83 /* log_file_created must not be TRUE, if online */
84 if (log_file_created) {
85 fprintf(stderr, "xtrabackup: Something wrong with source files...\n");
86- exit(1);
87+ exit(EXIT_FAILURE);
88 }
89
90 fil_load_single_table_tablespaces();
91@@ -3159,7 +3159,7 @@
92 if (!my_stat(xtrabackup_target_dir,&stat_info,MYF(0))
93 && (my_mkdir(xtrabackup_target_dir,0777,MYF(0)) < 0)){
94 fprintf(stderr,"xtrabackup: Error: cannot mkdir %d: %s\n",my_errno,xtrabackup_target_dir);
95- exit(1);
96+ exit(EXIT_FAILURE);
97 }
98
99 } else {
100@@ -3204,7 +3204,7 @@
101
102 if (err != DB_SUCCESS) {
103
104- exit(1);
105+ exit(EXIT_FAILURE);
106 }
107
108 log_group_read_checkpoint_info(max_cp_group, max_cp_field);
109@@ -3226,7 +3226,7 @@
110
111 if (err != DB_SUCCESS) {
112
113- exit(1);
114+ exit(EXIT_FAILURE);
115 }
116
117 log_group_read_checkpoint_info(max_cp_group, max_cp_field);
118@@ -3259,7 +3259,7 @@
119 fprintf(stderr,
120 "xtrabackup: error: cannot open %s\n",
121 dst_log_path);
122- exit(1);
123+ exit(EXIT_FAILURE);
124 }
125
126 #ifdef USE_POSIX_FADVISE
127@@ -3292,7 +3292,7 @@
128 if (!success) {
129 if (dst_log != -1)
130 os_file_close(dst_log);
131- exit(1);
132+ exit(EXIT_FAILURE);
133 }
134
135 /* start flag */
136@@ -3311,7 +3311,7 @@
137
138 /* copy log file by current position */
139 if(xtrabackup_copy_logfile(checkpoint_lsn_start, FALSE))
140- exit(1);
141+ exit(EXIT_FAILURE);
142
143
144 os_thread_create(log_copying_thread, NULL, &log_copying_thread_id);
145@@ -3352,7 +3352,7 @@
146 && (my_mkdir(path,0777,MYF(0)) < 0)){
147
148 fprintf(stderr,"xtrabackup: Error: cannot mkdir %d: %s\n",my_errno,path);
149- exit(1);
150+ exit(EXIT_FAILURE);
151 }
152 }
153
154@@ -3365,7 +3365,7 @@
155 if(xtrabackup_copy_datafile(node)) {
156 if(node->space->id == 0) {
157 fprintf(stderr,"xtrabackup: Error: failed to copy system datafile.\n");
158- exit(1);
159+ exit(EXIT_FAILURE);
160 } else {
161 printf("xtrabackup: Warining: failed to copy, but continuing.\n");
162 }
163@@ -3496,7 +3496,7 @@
164
165 if (!log_copying_succeed) {
166 fprintf(stderr, "xtrabackup: Error: log_copying_thread failed.\n");
167- exit(1);
168+ exit(EXIT_FAILURE);
169 }
170
171 if (!xtrabackup_stream)
172@@ -3793,7 +3793,7 @@
173 if (my_setwd(mysql_real_data_home,MYF(MY_WME)))
174 {
175 fprintf(stderr, "xtrabackup: cannot my_setwd %s\n", mysql_real_data_home);
176- exit(1);
177+ exit(EXIT_FAILURE);
178 }
179 fprintf(stderr, "xtrabackup: cd to %s\n", mysql_real_data_home);
180
181@@ -3807,14 +3807,14 @@
182
183 /* initialize components */
184 if(innodb_init_param())
185- exit(1);
186+ exit(EXIT_FAILURE);
187
188 fprintf(stderr, "xtrabackup: Starting 'read-only' InnoDB instance to gather index statistics.\n"
189 "xtrabackup: Using %lld bytes for buffer pool (set by --use-memory parameter)\n",
190 xtrabackup_use_memory);
191
192 if(innodb_init())
193- exit(1);
194+ exit(EXIT_FAILURE);
195
196 fprintf(stdout, "\n\n<INDEX STATISTICS>\n");
197
198@@ -4030,7 +4030,7 @@
199
200 /* shutdown InnoDB */
201 if(innodb_end())
202- exit(1);
203+ exit(EXIT_FAILURE);
204 }
205
206 /* ================= prepare ================= */
207@@ -4742,7 +4742,7 @@
208 if (my_setwd(xtrabackup_real_target_dir,MYF(MY_WME)))
209 {
210 fprintf(stderr, "xtrabackup: cannot my_setwd %s\n", xtrabackup_real_target_dir);
211- exit(1);
212+ exit(EXIT_FAILURE);
213 }
214 fprintf(stderr, "xtrabackup: cd to %s\n", xtrabackup_real_target_dir);
215
216@@ -4771,14 +4771,14 @@
217 if (xtrabackup_incremental) {
218 fprintf(stderr,
219 "xtrabackup: error: applying incremental backup needs target prepared.\n");
220- exit(1);
221+ exit(EXIT_FAILURE);
222 }
223 skip_check:
224 if (xtrabackup_incremental
225 && ut_dulint_cmp(metadata_to_lsn, incremental_lsn) < 0) {
226 fprintf(stderr,
227 "xtrabackup: error: This incremental backup seems to be too new for the target.\n");
228- exit(1);
229+ exit(EXIT_FAILURE);
230 }
231 }
232
233@@ -5123,7 +5123,7 @@
234 os_io_init_simple();
235
236 if(xtrabackup_close_temp_log(TRUE))
237- exit(1);
238+ exit(EXIT_FAILURE);
239
240 /* output to metadata file */
241 {
242@@ -5166,7 +5166,7 @@
243 error:
244 xtrabackup_close_temp_log(FALSE);
245
246- exit(1);
247+ exit(EXIT_FAILURE);
248 }
249
250 /* ================= main =================== */
251@@ -5227,7 +5227,7 @@
252 if (!xtrabackup_print_param)
253 usage();
254 printf("\nxtrabackup: Error: Please set parameter 'datadir'\n");
255- exit(-1);
256+ exit(EXIT_FAILURE);
257 }
258
259 if (xtrabackup_tables) {
260@@ -5284,7 +5284,7 @@
261 fp = fopen(xtrabackup_tables_file,"r");
262 if (!fp) {
263 fprintf(stderr, "xtrabackup: cannot open %s\n", xtrabackup_tables_file);
264- exit(-1);
265+ exit(EXIT_FAILURE);
266 }
267 for (;;) {
268 xtrabackup_tables_t* table;
269@@ -5363,7 +5363,7 @@
270 if (error) {
271 fprintf(stderr, "xtrabackup: value '%s' may be wrong format for incremental option.\n",
272 xtrabackup_incremental);
273- exit(-1);
274+ exit(EXIT_FAILURE);
275 }
276
277 /* allocate buffer for incremental backup (4096 pages) */
278@@ -5378,7 +5378,7 @@
279 fprintf(stderr,
280 "xtrabackup: error: failed to read metadata from %s\n",
281 filename);
282- exit(-1);
283+ exit(EXIT_FAILURE);
284 }
285
286 incremental_lsn = metadata_to_lsn;
287@@ -5396,7 +5396,7 @@
288 fprintf(stderr,
289 "xtrabackup: error: failed to read metadata from %s\n",
290 filename);
291- exit(-1);
292+ exit(EXIT_FAILURE);
293 }
294
295 incremental_lsn = metadata_from_lsn;
296@@ -5420,7 +5420,7 @@
297 bzero((G_PTR) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
298
299 if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
300- exit(1);
301+ exit(EXIT_FAILURE);
302
303 printf("# This MySQL options file was generated by XtraBackup.\n");
304 printf("[mysqld]\n");
305@@ -5434,7 +5434,7 @@
306 innobase_log_group_home_dir ? innobase_log_group_home_dir : mysql_data_home);
307 printf("innodb_log_files_in_group = %ld\n", innobase_log_files_in_group);
308 printf("innodb_log_file_size = %lld\n", innobase_log_file_size);
309- exit(0);
310+ exit(EXIT_SUCCESS);
311 }
312
313 if (!xtrabackup_stream) {
314@@ -5464,7 +5464,7 @@
315 if (xtrabackup_prepare) num++;
316 if (num != 1) { /* !XOR (for now) */
317 usage();
318- exit(-1);
319+ exit(EXIT_FAILURE);
320 }
321 }
322
323@@ -5516,5 +5516,5 @@
324 hash_table_free(tables_hash);
325 }
326
327- exit(0);
328+ exit(EXIT_SUCCESS);
329 }

Subscribers

People subscribed via source and target branches