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

Commit9fa01f6

Browse files
committed
Check for partial WAL files in standby mode. If restore_command restores
a partial WAL file, assume it's because the file is just being copied tothe archive and treat it the same as "file not found" in standby mode.pg_standby has a similar check, so it seems reasonable to have the samelevel of protection in the built-in standby mode.
1 parent7e30c00 commit9fa01f6

File tree

1 file changed

+23
-8
lines changed
  • src/backend/access/transam

1 file changed

+23
-8
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.370 2010/02/10 08:25:25 heikki Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.371 2010/02/12 07:36:44 heikki Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2891,21 +2891,36 @@ RestoreArchivedFile(char *path, const char *xlogfname,
28912891
/*
28922892
* command apparently succeeded, but let's make sure the file is
28932893
* really there now and has the correct size.
2894-
*
2895-
* XXX I made wrong-size a fatal error to ensure the DBA would notice
2896-
* it, but is that too strong?We could try to plow ahead with a
2897-
* local copy of the file ... but the problem is that there probably
2898-
* isn't one, and we'd incorrectly conclude we've reached the end of
2899-
* WAL and we're done recovering ...
29002894
*/
29012895
if (stat(xlogpath,&stat_buf)==0)
29022896
{
29032897
if (expectedSize>0&&stat_buf.st_size!=expectedSize)
2904-
ereport(FATAL,
2898+
{
2899+
intelevel;
2900+
2901+
/*
2902+
* If we find a partial file in standby mode, we assume it's
2903+
* because it's just being copied to the archive, and keep
2904+
* trying.
2905+
*
2906+
* Otherwise treat a wrong-sized file as FATAL to ensure the
2907+
* DBA would notice it, but is that too strong?We could try
2908+
* to plow ahead with a local copy of the file ... but the
2909+
* problem is that there probably isn't one, and we'd
2910+
* incorrectly conclude we've reached the end of WAL and
2911+
* we're done recovering ...
2912+
*/
2913+
if (StandbyMode&&stat_buf.st_size<expectedSize)
2914+
elevel=DEBUG1;
2915+
else
2916+
elevel=FATAL;
2917+
ereport(elevel,
29052918
(errmsg("archive file \"%s\" has wrong size: %lu instead of %lu",
29062919
xlogfname,
29072920
(unsigned long)stat_buf.st_size,
29082921
(unsigned long)expectedSize)));
2922+
return false;
2923+
}
29092924
else
29102925
{
29112926
ereport(LOG,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp