Hi, I suppose the attached patch is close to the solution.
> I think that this is an original intention of Heikki's patch.
I noticed that archive recovery will be turned on in
next_record_is_invalid thanks to your patch.
> On the other hand, your patch fixes that point but ReadRecord
> runs on the false page data. However the wrong record on the
> false page can be identified as broken, It should be an
> undesiable behavior.
All we should do to update minRecoveryPoint as needed when
XLogPageRead is failed in ReadRecord is to simply jump to
next_record_is_invalid if archive recovery is requested but doing
crash recovery yet.
Your modification in readTimeLineHistory and my modifictions in
XLogPageRead seem not necessary for the objective in this thread,
so removed.
--
Kyotaro Horiguchi
NTT Open Source Software Center
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 92adc4e..28d6f2e 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -4010,7 +4010,15 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt)retry: /* Read the page
containingthe record */ if (!XLogPageRead(RecPtr, emode, fetching_ckpt, randAccess))
+ {
+ /*
+ * If archive recovery was requested when crash recovery failed, go to
+ * the label next_record_is_invalid to switch to archive recovery.
+ */
+ if (!InArchiveRecovery && ArchiveRecoveryRequested)
+ goto next_record_is_invalid; return NULL;
+ } pageHeaderSize = XLogPageHeaderSize((XLogPageHeader) readBuf); targetRecOff = RecPtr->xrecoff %
XLOG_BLCKSZ;