|
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.408 2010/05/02 02:10:33 tgl Exp $ |
| 10 | + * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.409 2010/05/03 11:17:52 heikki Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -7920,11 +7920,28 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
|
7920 | 7920 | /* Update our copy of the parameters in pg_control */
|
7921 | 7921 | memcpy(&xlrec, XLogRecGetData(record), sizeof(xl_parameter_change));
|
7922 | 7922 |
|
| 7923 | + LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); |
7923 | 7924 | ControlFile->MaxConnections = xlrec.MaxConnections;
|
7924 | 7925 | ControlFile->max_prepared_xacts = xlrec.max_prepared_xacts;
|
7925 | 7926 | ControlFile->max_locks_per_xact = xlrec.max_locks_per_xact;
|
7926 | 7927 | ControlFile->wal_level = xlrec.wal_level;
|
| 7928 | + /* |
| 7929 | + * Update minRecoveryPoint to ensure that if recovery is aborted, |
| 7930 | + * we recover back up to this point before allowing hot standby |
| 7931 | + * again. This is particularly important if wal_level was set to |
| 7932 | + * 'archive' before, and is now 'hot_standby', to ensure you don't |
| 7933 | + * run queries against the WAL preceding the wal_level change. |
| 7934 | + * Same applies to decreasing max_* settings. |
| 7935 | + */ |
| 7936 | + minRecoveryPoint = ControlFile->minRecoveryPoint; |
| 7937 | + if ((minRecoveryPoint.xlogid != 0 || minRecoveryPoint.xrecoff != 0) |
| 7938 | + && XLByteLT(minRecoveryPoint, lsn)) |
| 7939 | + { |
| 7940 | + ControlFile->minRecoveryPoint = lsn; |
| 7941 | + } |
| 7942 | + |
7927 | 7943 | UpdateControlFile();
|
| 7944 | + LWLockRelease(ControlFileLock); |
7928 | 7945 |
|
7929 | 7946 | /* Check to see if any changes to max_connections give problems */
|
7930 | 7947 | CheckRequiredParameterValues();
|
|
0 commit comments