Archive Recovery and SR promote command is failed by “contrecord is requested” in ReadRecord() - Mailing list pgsql-hackers

From KONDO Mitsumasa
Subject Archive Recovery and SR promote command is failed by “contrecord is requested” in ReadRecord()
Date
Msg-id 5181D574.7060302@lab.ntt.co.jp
Whole thread Raw
List pgsql-hackers
Hi,

I found that archive recovery and SR promote command is failed by contrecord is requested by 0/4000020" in
ReadRecord(). 
I investigate about "contrecord", it means that record crosses page boundary.
I think it is not irregular page, and should be try to read next page in this case.
But in archive recovery mode, PG misjudged archive recovery is end. And PITR ends on the way...
In standby mode, PG cannot finish standby loops ...

What do you think ?


My investigation about this point in source code (PG9.2.4) is here.

xlog_internal.h
> 105 /* When record crosses page boundary, set this flag in new page's header */
> 106 #define XLP_FIRST_IS_CONTRECORD         0x0001

xlog.c @ ReadRecord()
> 4045         if ((((XLogPageHeader) readBuf)->xlp_info & XLP_FIRST_IS_CONTRECORD) &&
> 4046                 targetRecOff == pageHeaderSize)
> 4047         {
> 4048                 ereport(emode_for_corrupt_record(emode, *RecPtr),
> 4049                                 (errmsg("contrecord is requested by %X/%X",
> 4050                                                 RecPtr->xlogid, RecPtr->xrecoff)));
> 4051                 goto next_record_is_invalid;

xlog.c @ XLogInsert()
I think that "> 1116                 Insert->currpage->xlp_info |= XLP_FIRST_IS_CONTRECORD;" is normal path, not
irregular.
> 1085          * Append the data, including backup blocks if any
> 1086          */
> 1087         while (write_len)
> 1088         {
> 1089                 while (rdata->data == NULL)
> 1090                         rdata = rdata->next;
> 1091
> 1092                 if (freespace > 0)
> 1093                 {
> 1094                         if (rdata->len > freespace)
> 1095                         {
> 1096                                 memcpy(Insert->currpos, rdata->data, freespace);
> 1097                                 rdata->data += freespace;
> 1098                                 rdata->len -= freespace;
> 1099                                 write_len -= freespace;
> 1100                         }
> 1101                         else
> 1102                         {
> 1103                                 memcpy(Insert->currpos, rdata->data, rdata->len);
> 1104                                 freespace -= rdata->len;
> 1105                                 write_len -= rdata->len;
> 1106                                 Insert->currpos += rdata->len;
> 1107                                 rdata = rdata->next;
> 1108                                 continue;
> 1109                         }
> 1110                 }
> 1111
> 1112                 /* Use next buffer */
> 1113                 updrqst = AdvanceXLInsertBuffer(false);
> 1114                 curridx = Insert->curridx;
> 1115                 /* Insert cont-record header */
> 1116                 Insert->currpage->xlp_info |= XLP_FIRST_IS_CONTRECORD;
> 1117                 contrecord = (XLogContRecord *) Insert->currpos;
> 1118                 contrecord->xl_rem_len = write_len;
> 1119                 Insert->currpos += SizeOfXLogContRecord;
> 1120                 freespace = INSERT_FREESPACE(Insert);
> 1121         }


Best regards,
--
NTT Open Sorce Software Center
Mitsumasa KONDO

Attachment

pgsql-hackers by date:

Previous
From: Atri Sharma
Date:
Subject: Re: Graph datatype addition
Next
From: Peter Eisentraut
Date:
Subject: Re: Documentation epub format