91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

PostgreSQL啟動恢復讀取checkpoint記錄失敗的條件

發布時間:2020-07-21 04:53:56 來源:網絡 閱讀:7474 作者:yzs的專欄 欄目:數據庫
1、首先讀取ControlFile->checkPoint指向的checkpoint
2、如果讀取失敗,slave直接abort退出,master再次讀取ControlFile->prevCheckPoint指向的checkpoint
StartupXLOG->
    |--checkPointLoc = ControlFile->checkPoint;
    |--record = ReadCheckpointRecord(xlogreader, checkPointLoc, 1, true):
    |-- if (record != NULL){
           ...
        }else if (StandbyMode){
            ereport(PANIC,(errmsg("could not locate a valid checkpoint record")));
        }else{
            checkPointLoc = ControlFile->prevCheckPoint;
            record = ReadCheckpointRecord(xlogreader, checkPointLoc, 2, true);
            if (record != NULL){
                InRecovery = true;//標記下面進入recovery
            }else{
                ereport(PANIC,(errmsg("could not locate a valid checkpoint record")));
            }
        }

一、那么什么條件下讀取的checkpoint記錄record==NULL?

1、ControlFile->checkPoint % XLOG_BLCKSZ < SizeOfXLogShortPHD
2、ReadRecord(xlogreader, ControlFile->checkPoint, LOG, true)返回NULL
3、ReadRecord讀到的record!=NULL && record->xl_rmid != RM_XLOG_ID
4、ReadRecord讀到的record!=NULL && info != XLOG_CHECKPOINT_SHUTDOWN && info != XLOG_CHECKPOINT_ONLINE
5、ReadRecord讀到的record!=NULL && record->xl_tot_len != SizeOfXLogRecord + SizeOfXLogRecordDataHeaderShort + sizeof(CheckPoint)

二、ReadRecord函數返回NULL的條件

ReadRecord(xlogreader, ControlFile->checkPoint, LOG, true)
    |--record = XLogReadRecord(xlogreader, ControlFile->checkPoint, &errormsg);
    |-- 2.1 record==NULL && !StandbyMode
    |-- 2.2 record!=NULL && !tliInHistory(xlogreader->latestPageTLI, expectedTLEs)
    /*-----
    note:只要讀取了一頁xlog,就會賦值為該頁第一個記錄的時間線
    XLogReaderValidatePageHeader
        -->xlogreader->latestPageTLI=hdr->xlp_tli;
    ------*/

三、XlogReadRecord讀取checkpoint返回NULL的條件?

XLogReadRecord(xlogreader, ControlFile->checkPoint, &errormsg)
    targetPagePtr = ControlFile->checkPoint - (ControlFile->checkPoint % XLOG_BLCKSZ);
    targetRecOff = ControlFile->checkPoint % XLOG_BLCKSZ;
    readOff = ReadPageInternal(state,targetPagePtr, Min(targetRecOff + SizeOfXLogRecord, XLOG_BLCKSZ));
    pageHeaderSize = XLogPageHeaderSize((XLogPageHeader) state->readBuf);
    record = (XLogRecord *) (state->readBuf + RecPtr % XLOG_BLCKSZ);
    total_len = record->xl_tot_len;
    -------------
    1、readOff < 0
    2、0< targetRecOff < pageHeaderSize
    3、(((XLogPageHeader) state->readBuf)->xlp_info & XLP_FIRST_IS_CONTRECORD) && targetRecOff == pageHeaderSize
       page頭有跨頁的record并且checkpoint定位的偏移正好在頁頭尾部
    4、targetRecOff <= XLOG_BLCKSZ - SizeOfXLogRecord && 
       !ValidXLogRecordHeader(state, ControlFile->checkPoint, state->ReadRecPtr, record,randAccess)
       ---(record->xl_tot_len < SizeOfXLogRecord || record->xl_rmid > RM_MAX_ID || record->xl_prev != state->ReadRecPtr)
    5、targetRecOff > XLOG_BLCKSZ - SizeOfXLogRecord && total_len < SizeOfXLogRecord
    6、total_len > state->readRecordBufSize && !allocate_recordbuf(state, total_len)
       一旦該記錄損壞,total_len的長度非常大的話,就需要allocate_recordbuf擴展state->readbuf,可能因此分配失敗abort
       記錄的checksum需要等待全部讀取完整記錄后才校驗
    -------------

三、ReadPageInternal返回的readOff返回小于0的條件

ReadPageInternal(state,targetPagePtr, Min(targetRecOff + SizeOfXLogRecord, XLOG_BLCKSZ))
    1、第一次read wal文件,readLen = state->read_page:讀取第一頁。readLen < 0
    2、readLen>0 && !XLogReaderValidatePageHeader(state, targetSegmentPtr, state->readBuf)
    --
    3、讀取checkpoint所在頁readLen = state->read_page: readLen < 0
    4、readLen > 0 && readLen <= SizeOfXLogShortPHD
    5、!XLogReaderValidatePageHeader(state, pageptr, (char *) hdr)

四、XLogPageRead何時返回值<0 ?

/*
    1、WaitForWALToBecomeAvailable open失敗
    2、lseek 失敗 && !StandbyMode
    3、read失敗 && !StandbyMode
    4、校驗page頭失敗 && !StandbyMode
    如果是StandbyMode,則會重新retry->WaitForWALToBecomeAvailable,切換日志源進行open
    */
    !WaitForWALToBecomeAvailable(targetPagePtr + reqLen,private->randAccess,1,targetRecPtr)//open
    |-- return -1
    readOff = targetPageOff;
    if (lseek(readFile, (off_t) readOff, SEEK_SET) < 0){
        !StandbyMode:: return -1
    }
    if (read(readFile, readBuf, XLOG_BLCKSZ) != XLOG_BLCKSZ){
        !StandbyMode:: return -1
    }
    XLogReaderValidatePageHeader(xlogreader, targetPagePtr, readBuf)
    !StandbyMode:: return -1

五、WaitForWALToBecomeAvailable何時返回false?

--XLOG_FROM_ARCHIVE | XLOG_FROM_PG_WAL
    1、先XLogFileReadAnyTLI open日志:
        1、遍歷時間線列表里的每一個時間線,從最新的開始
        2、當讀取checkpoint的時候,source是XLOG_FROM_ANY
        3、先找歸檔的日志進行open;如果open失敗再找WAL日志進行open
        4、如果都沒有open成功,則向前找時間線,open前一個時間線segno和文件號相同的文件進行open
        5、open成功后expectedTLEs被賦值為當前時間線列表的所有值
    2、如果open失敗,則切換日志源:XLOG_FROM_ARCHIVE | XLOG_FROM_PG_WAL -> XLOG_FROM_STREAM
    3、切換日志源后,XLOG_FROM_ARCHIVE | XLOG_FROM_PG_WAL 則:
       slave && promote :return false
       !StandbyMode:return false
    --XLOG_FROM_STREAM
    1、!WalRcvStreaming()即receiver進程掛了,切換日志源
    2、CheckForStandbyTrigger()切換日志源
    3、XLOG_FROM_STREAM->XLOG_FROM_ARCHIVE
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

大姚县| 墨竹工卡县| 石阡县| 南皮县| 屯门区| 林芝县| 绍兴市| 方山县| 宁乡县| 潢川县| 会泽县| 巨鹿县| 湘乡市| 平山县| 淅川县| 炉霍县| 五峰| 洞头县| 潮州市| 湾仔区| 中阳县| 抚顺县| 奈曼旗| 镇安县| 察隅县| 临武县| 青岛市| 虹口区| 固安县| 南木林县| 从江县| 全南县| 诸暨市| 河津市| 万山特区| 济南市| 共和县| 奉新县| 屯门区| 黑山县| 湘乡市|