Fix some serious bugs in archive recovery, now that bgwriter is active
authorHeikki Linnakangas <heikki@enterprisedb.com>
Thu, 25 Jun 2009 21:36:00 +0000 (21:36 +0000)
committerHeikki Linnakangas <heikki@enterprisedb.com>
Thu, 25 Jun 2009 21:36:00 +0000 (21:36 +0000)
commite5e498f270796a4ae30f64644b188d3a63fb912c
treea37b167f4354ac7d5f722f2ae3acce89fff05468
parent515f4c1cbc135766f2072b378712cba9fe434e0f
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.
src/backend/access/transam/xlog.c
src/backend/postmaster/bgwriter.c
src/backend/storage/smgr/md.c
src/include/access/xlog.h
src/include/storage/smgr.h