欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

PostgreSQLpg_ctlstart超時(shí)分析

一、問題
pg_ctl start啟動(dòng)時(shí)報(bào)錯(cuò)退出:pg_ctl:server did not start in time。超時(shí)時(shí)間是多少?從什么時(shí)候到哪個(gè)階段算超時(shí)?

成都創(chuàng)新互聯(lián)公司專注于企業(yè)營(yíng)銷型網(wǎng)站、網(wǎng)站重做改版、湛河網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5開發(fā)、商城網(wǎng)站建設(shè)、集團(tuán)公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為湛河等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。

二、分析:該信息打印位置,從后面代碼段do_start函數(shù)中可以看出
1、pg_ctl start調(diào)用start_postmaster啟動(dòng)PG的主進(jìn)程后,每隔0.1ms檢查一次postmaster.pid文件,是否已寫入ready/standby
2、總共會(huì)檢查600次,即從啟動(dòng)主進(jìn)程后,最多等待60s,如果沒有寫入ready/standby則打印上述日志并退出
3、默認(rèn)等待時(shí)間是60s,如果pg_ctl start -t指定等待時(shí)間,則等待時(shí)間為該指定時(shí)間

三、什么時(shí)候postmaster.pid文件寫入ready/standby
1、如果是主機(jī)不管有沒有設(shè)置hot standby
?? ?1)當(dāng)startup進(jìn)程恢復(fù)完成退出時(shí),調(diào)用proc_exit函數(shù)向主進(jìn)程發(fā)送SIGCHLD信號(hào)并退出
?? ?2)主進(jìn)程接收到信號(hào)后,signal處理函數(shù)reaper調(diào)用AddToDataDirLockFile向postmaster.pid文件寫入ready
2、如果是備機(jī)即data目錄下有recovery.cnf文件,且設(shè)置了hot standby,在實(shí)際恢復(fù)前沒有到達(dá)一致性位置
?? ?1)startup進(jìn)程向主進(jìn)程發(fā)送PMSIGNAL_RECOVERY_STARTED信號(hào),主進(jìn)程調(diào)用信號(hào)處理函數(shù)sigusr1_handler,將pmState=PM_RECOVERY
?? ?2)每次讀取下一個(gè)xlog前都會(huì)調(diào)用CheckRecoveryConsistency函數(shù)進(jìn)行一致性檢查:
?? ??? ?2.1 進(jìn)入一致性狀態(tài),starup進(jìn)程向主進(jìn)程發(fā)送PMSIGNAL_BEGIN_HOT_STANDBY信號(hào),主進(jìn)程接收到信號(hào)后調(diào)用sigusr1_handler->AddToDataDirLockFile向postmaster.pid文件寫入ready
3、如果是備機(jī)即data目錄下有recovery.cnf文件,且設(shè)置了hot standby,在實(shí)際恢復(fù)前沒有到達(dá)一致性位置
?? ?1)startup進(jìn)程向主進(jìn)程發(fā)送PMSIGNAL_RECOVERY_STARTED信號(hào),主進(jìn)程調(diào)用信號(hào)處理函數(shù)sigusr1_handler,將pmState=PM_RECOVERY
?? ?2)每次讀取下一個(gè)xlog前都會(huì)調(diào)用CheckRecoveryConsistency函數(shù)進(jìn)行一致性檢查。如果沒有進(jìn)入一致性狀態(tài)
?? ?3)本地日志恢復(fù)完成,切換日志源時(shí)同樣調(diào)用CheckRecoveryConsistency函數(shù)進(jìn)行一致性檢查
?? ??? ?3.1 進(jìn)入一致性狀態(tài),starup進(jìn)程向主進(jìn)程發(fā)送PMSIGNAL_BEGIN_HOT_STANDBY信號(hào),主進(jìn)程接收到信號(hào)后調(diào)用sigusr1_handler->AddToDataDirLockFile向postmaster.pid文件寫入ready
4、如果是備機(jī)即data目錄下有recovery.cnf文件,且設(shè)置了hot standby,在實(shí)際恢復(fù)前到達(dá)一致性位置
?? ?1)startup進(jìn)程向主進(jìn)程發(fā)送PMSIGNAL_RECOVERY_STARTED信號(hào),主進(jìn)程調(diào)用信號(hào)處理函數(shù)sigusr1_handler,將pmState=PM_RECOVERY
?? ?2)CheckRecoveryConsistency函數(shù)進(jìn)行一致性檢查,向主進(jìn)程發(fā)送PMSIGNAL_BEGIN_HOT_STANDBY信號(hào),主進(jìn)程接收到信號(hào)后調(diào)用sigusr1_handler->AddToDataDirLockFile向postmaster.pid文件寫入ready
5、如果是備機(jī)即data目錄下有recovery.cnf文件,沒有設(shè)置hot standby
?? ?1)startup進(jìn)程向主進(jìn)程發(fā)送PMSIGNAL_RECOVERY_STARTED信號(hào)
?? ?2)主進(jìn)程接收到信號(hào)后,向postmaster.將pmState=PM_RECOVERY

四、代碼分析
1、pg_ctl start流程

do_start->
    pm_pid = start_postmaster();
    if (do_wait){
        print_msg(_("waiting for server to start..."));
        switch (wait_for_postmaster(pm_pid, false)){
            case POSTMASTER_READY:
                print_msg(_(" done\n"));
                print_msg(_("server started\n"));
                break;
            case POSTMASTER_STILL_STARTING:
                print_msg(_(" stopped waiting\n"));
                write_stderr(_("%s: server did not start in time\n"), progname);
                exit(1);
                break;
            case POSTMASTER_FAILED:
                print_msg(_(" stopped waiting\n"));
                write_stderr(_("%s: could not start server\n" "Examine the log output.\n"), progname);
                exit(1);
                break;
        }
    }else
        print_msg(_("server starting\n"));
wait_for_postmaster->
    for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++){
        if ((optlines = readfile(pid_file, &numlines)) != NULL && numlines >= LOCK_FILE_LINE_PM_STATUS){
            pmpid = atol(optlines[LOCK_FILE_LINE_PID - 1]);
            pmstart = atol(optlines[LOCK_FILE_LINE_START_TIME - 1]);
            if (pmstart >= start_time - 2 && pmpid == pm_pid){
                char       *pmstatus = optlines[LOCK_FILE_LINE_PM_STATUS - 1];
                if (strcmp(pmstatus, PM_STATUS_READY) == 0 || strcmp(pmstatus, PM_STATUS_STANDBY) == 0){
                    /* postmaster is done starting up */
                    free_readfile(optlines);
                    return POSTMASTER_READY;
                }
            }
        }
        free_readfile(optlines);
        if (waitpid((pid_t) pm_pid, &exitstatus, WNOHANG) == (pid_t) pm_pid)
            return POSTMASTER_FAILED;
        pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
    }
    /* out of patience; report that postmaster is still starting up */
    return POSTMASTER_STILL_STARTING;

2、server主進(jìn)程及信號(hào)處理函數(shù)

PostmasterMain->
    pqsignal_no_restart(SIGUSR1, sigusr1_handler);  /* message from child process */
    pqsignal_no_restart(SIGCHLD, reaper);   /* handle child termination */
    ...
    StartupXLOG();
    ...
    proc_exit(0);//exit函數(shù)向主進(jìn)程發(fā)送SIGCHLD信號(hào)
reaper->//進(jìn)程終止或者停止的信號(hào)
    AddToDataDirLockFile(LOCK_FILE_LINE_PM_STATUS, PM_STATUS_READY);
postmaster進(jìn)程接收信號(hào):
sigusr1_handler->
    if (CheckPostmasterSignal(PMSIGNAL_RECOVERY_STARTED) &&
        pmState == PM_STARTUP && Shutdown == NoShutdown){
        CheckpointerPID = StartCheckpointer();
        BgWriterPID = StartBackgroundWriter();
        if (XLogArchivingAlways())
            PgArchPID = pgarch_start();
        //hot_standby在postgresql.conf文件中配置TRUE
        //表示在恢復(fù)的時(shí)候允許連接
        if (!EnableHotStandby){
            //將standby寫入postmaster.pid文件,表示up但不允許連接
            AddToDataDirLockFile(LOCK_FILE_LINE_PM_STATUS, PM_STATUS_STANDBY);
        }
        pmState = PM_RECOVERY;
    }
    if (CheckPostmasterSignal(PMSIGNAL_BEGIN_HOT_STANDBY) &&
        pmState == PM_RECOVERY && Shutdown == NoShutdown){
        PgStatPID = pgstat_start();
        //將ready寫入postmaster.pid文件,允許連接
        AddToDataDirLockFile(LOCK_FILE_LINE_PM_STATUS, PM_STATUS_READY);
        pmState = PM_HOT_STANDBY;
    }
    ...

3、Startup進(jìn)程

StartupXLOG->
    ReadCheckpointRecord
    if (ArchiveRecoveryRequested && IsUnderPostmaster){//有recovery.conf文件則ArchiveRecoveryRequested為TRUE
        //有recovery.conf文件則ArchiveRecoveryRequested為TRUE
        PublishStartupProcessInformation();
        SetForwardFsyncRequests();
        //向master進(jìn)程發(fā)送PMSIGNAL_RECOVERY_STARTED信號(hào)
        SendPostmasterSignal(PMSIGNAL_RECOVERY_STARTED);
        bgwriterLaunched = true;
    }
    CheckRecoveryConsistency();-->...
    |-- if (standbyState == STANDBY_SNAPSHOT_READY && !LocalHotStandbyActive &&
    |       reachedConsistency && IsUnderPostmaster){
    |       SpinLockAcquire(&XLogCtl->info_lck);
    |       XLogCtl->SharedHotStandbyActive = true;
    |       SpinLockRelease(&XLogCtl->info_lck);
    |       LocalHotStandbyActive = true;
    |       SendPostmasterSignal(PMSIGNAL_BEGIN_HOT_STANDBY);
    |-- }
    ...
    回放一個(gè)record后,每次讀取下一個(gè)record前都會(huì)調(diào)用CheckRecoveryConsistency

當(dāng)前名稱:PostgreSQLpg_ctlstart超時(shí)分析
當(dāng)前地址:http://aaarwkj.com/article4/gipgie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、網(wǎng)站設(shè)計(jì)公司、全網(wǎng)營(yíng)銷推廣、Google、網(wǎng)站維護(hù)、網(wǎng)站收錄

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管
亚洲精品成人久久av| 国产美女直播亚洲一区色| 日本高清加勒比免费在线| 日本黄网色三级三级三级| 欧美丝袜熟女日韩亚洲| 日韩欧美精品一区二区三区四区 | 中文字幕人妻熟女人妻| 欧美另类亚洲综合久青草| 欧美日韩黄片免费在线观看| 亚洲丰满熟女乱一区二区三区 | 黑人精品一区二区三区| 国产91在线一区精品| 亚洲熟女午夜毛片av毛片| 亚洲不卡高清一区二区三区| 少妇高潮试看二十分钟| 朝桐光日韩一区二区三区| 国产日韩欧美高清免费视频| 人妻av在线中文字幕| 青青草国产精品一区二区| 日本精品人妻一区二区三区蜜桃| 亚洲av日韩av一区| 国产亚洲av一区二区三区| 白虎亚洲福利精品一区| 日韩一区二区三级在线| 久久一区二区三区播放| 中文字幕在线精品乱码麻豆| 国产一区二区欧美精品| 2020亚洲欧美日韩在线| 婷婷色爱区综合五月激情| 国产欧美日韩另类视频| av中文在线免费观看 | 日韩三级成人在线视频| 亚洲不卡高清一区二区三区| 国产精品传媒在线视频| 国产精品观看在线亚洲人成网| 久久亚洲精品中文字幕一 | 午夜av一区二区三区| 这里只有精品国产999| 日本高清一区二区不卡视频| 亚洲品质自拍在线观看| 精品亚洲午夜久久久久|