|
7 | 7 | * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California
|
9 | 9 | *
|
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 $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -2891,21 +2891,36 @@ RestoreArchivedFile(char *path, const char *xlogfname,
|
2891 | 2891 | /*
|
2892 | 2892 | * command apparently succeeded, but let's make sure the file is
|
2893 | 2893 | * 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 ... |
2900 | 2894 | */
|
2901 | 2895 | if (stat(xlogpath, &stat_buf) == 0)
|
2902 | 2896 | {
|
2903 | 2897 | if (expectedSize > 0 && stat_buf.st_size != expectedSize)
|
2904 |
| - ereport(FATAL, |
| 2898 | + { |
| 2899 | + int elevel; |
| 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, |
2905 | 2918 | (errmsg("archive file \"%s\" has wrong size: %lu instead of %lu",
|
2906 | 2919 | xlogfname,
|
2907 | 2920 | (unsigned long) stat_buf.st_size,
|
2908 | 2921 | (unsigned long) expectedSize)));
|
| 2922 | + return false; |
| 2923 | + } |
2909 | 2924 | else
|
2910 | 2925 | {
|
2911 | 2926 | ereport(LOG,
|
|
0 commit comments