Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit856de3b

Browse files
committed
Add some missing exit() calls in error paths for various binaries
The following changes are done:- In pg_archivecleanup, the cleanup of older WAL segments would neverfail immediately.- In pgbench, the initialization of a thread barrier would not failhard.- In pg_recvlogical, a stat() failure never got the call.- In pg_basebackup, two chmod() reported a failure without exit()'ingwhen unpacking some tar data freshly received. It may be possible tocontinue writing some data even after this failure, but that could beconfusing to the user at the end.These are arguably bugs, but they would happen for code paths where afailure is unlikely going to happen, so no backpatch is done.Reviewed-by: Robert Haas, Fabien CoelhoDiscussion:https://postgr.es/m/YQDMdB+B68yePFeT@paquier.xyz
1 parent2ad98fd commit856de3b

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

‎src/bin/pg_archivecleanup/pg_archivecleanup.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,30 @@ CleanupPriorWALFiles(void)
151151
{
152152
pg_log_error("could not remove file \"%s\": %m",
153153
WALFilePath);
154-
break;
154+
exit(1);
155155
}
156156
}
157157
}
158158

159159
if (errno)
160+
{
160161
pg_log_error("could not read archive location \"%s\": %m",
161162
archiveLocation);
163+
exit(1);
164+
}
162165
if (closedir(xldir))
166+
{
163167
pg_log_error("could not close archive location \"%s\": %m",
164168
archiveLocation);
169+
exit(1);
170+
}
165171
}
166172
else
173+
{
167174
pg_log_error("could not open archive location \"%s\": %m",
168175
archiveLocation);
176+
exit(1);
177+
}
169178
}
170179

171180
/*

‎src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,8 +1626,11 @@ ReceiveTarAndUnpackCopyChunk(size_t r, char *copybuf, void *callback_data)
16261626
}
16271627
#ifndefWIN32
16281628
if (chmod(state->filename, (mode_t)filemode))
1629+
{
16291630
pg_log_error("could not set permissions on directory \"%s\": %m",
16301631
state->filename);
1632+
exit(1);
1633+
}
16311634
#endif
16321635
}
16331636
elseif (copybuf[156]=='2')
@@ -1676,8 +1679,11 @@ ReceiveTarAndUnpackCopyChunk(size_t r, char *copybuf, void *callback_data)
16761679

16771680
#ifndefWIN32
16781681
if (chmod(state->filename, (mode_t)filemode))
1682+
{
16791683
pg_log_error("could not set permissions on file \"%s\": %m",
16801684
state->filename);
1685+
exit(1);
1686+
}
16811687
#endif
16821688

16831689
if (state->current_len_left==0)

‎src/bin/pg_basebackup/pg_recvlogical.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,10 @@ StreamLogicalLog(void)
341341
}
342342

343343
if (fstat(outfd,&statbuf)!=0)
344+
{
344345
pg_log_error("could not stat file \"%s\": %m",outfile);
346+
gotoerror;
347+
}
345348

346349
output_isfile=S_ISREG(statbuf.st_mode)&& !isatty(outfd);
347350
}

‎src/bin/pgbench/pgbench.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6469,7 +6469,10 @@ main(int argc, char **argv)
64696469

64706470
errno=THREAD_BARRIER_INIT(&barrier,nthreads);
64716471
if (errno!=0)
6472+
{
64726473
pg_log_fatal("could not initialize barrier: %m");
6474+
exit(1);
6475+
}
64736476

64746477
#ifdefENABLE_THREAD_SAFETY
64756478
/* start all threads but thread 0 which is executed directly later */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp