mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Fix some serious bugs in archive recovery, now that bgwriter is active
during it: When bgwriter is active, the startup process can't perform mdsync() correctly because it won't see the fsync requests accumulated in bgwriter's private pendingOpsTable. Therefore make bgwriter responsible for the end-of-recovery checkpoint as well, when it's active. When bgwriter is active (= archive recovery), the startup process must not accumulate fsync requests to its own pendingOpsTable, since bgwriter won't see them there when it performs restartpoints. Make startup process drop its pendingOpsTable when bgwriter is launched to avoid that. Update minimum recovery point one last time when leaving archive recovery. It won't be updated by the end-of-recovery checkpoint because XLogFlush() sees us as out of recovery already. This fixes bug #4879 reported by Fujii Masao.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.146 2009/06/11 14:49:02 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.147 2009/06/25 21:36:00 heikki Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -203,6 +203,21 @@ mdinit(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* In archive recovery, we rely on bgwriter to do fsyncs(), but we don't
|
||||
* know that we do archive recovery at process startup when pendingOpsTable
|
||||
* has already been created. Calling this function drops pendingOpsTable
|
||||
* and causes any subsequent requests to be forwarded to bgwriter.
|
||||
*/
|
||||
void
|
||||
SetForwardFsyncRequests(void)
|
||||
{
|
||||
/* Perform any pending ops we may have queued up */
|
||||
if (pendingOpsTable)
|
||||
mdsync();
|
||||
pendingOpsTable = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* mdexists() -- Does the physical file exist?
|
||||
*
|
||||
|
Reference in New Issue
Block a user