初步学习pg_control文件之十五

接前文  初步学习pg_control文件之十四

再看如下这个:

int            MaxConnections;

应该说,它是一个参考值,在global.c中有如下定义

初步学习pg_control文件之十五
            
/*            
 * Primary determinants of sizes of shared-memory structures.  MaxBackends is            
 * MaxConnections + autovacuum_max_workers + 1 (it is computed by the GUC            
 * assign hooks for those variables):            
 */            
int            NBuffers = 1000;
int            MaxBackends = 100;
int            MaxConnections = 90;
初步学习pg_control文件之十五
初步学习pg_control文件之十五
/*                                
 * This must be called ONCE during postmaster or standalone-backend startup                                
 */                                
void                                
StartupXLOG(void)                                
{                                
    …                            
    /*                            
     * If any of the critical GUCs have changed, log them before we allow                            
     * backends to write WAL.                            
     */                            
    LocalSetXLogInsertAllowed();                            
    XLogReportParameters();                            
                                
    …                            
}                                
初步学习pg_control文件之十五
初步学习pg_control文件之十五
/*                                
 * Check if any of the GUC parameters that are critical for hot standby                                
 * have changed, and update the value in pg_control file if necessary.                                
 */                                
static void                                
XLogReportParameters(void)                                
{                                
    if (wal_level != ControlFile->wal_level ||                            
        MaxConnections != ControlFile->MaxConnections ||                        
        max_prepared_xacts != ControlFile->max_prepared_xacts ||                        
        max_locks_per_xact != ControlFile->max_locks_per_xact)                        
    {                            
        …                        
                                
        ControlFile->MaxConnections = MaxConnections;                        
        ControlFile->max_prepared_xacts = max_prepared_xacts;                        
        ControlFile->max_locks_per_xact = max_locks_per_xact;                        
        ControlFile->wal_level = wal_level;                        
        UpdateControlFile();                        
    }                            
}                                
初步学习pg_control文件之十五

它就是一个参考值:

初步学习pg_control文件之十五
/*                                            
 * This must be called ONCE during postmaster or standalone-backend startup                                            
 */                                            
void                                            
StartupXLOG(void)                                            
{                                            
    …                                        
                                            
    /* REDO */                                        
    if (InRecovery)                                        
    {                                        
        …                                    
        /* Check that the GUCs used to generate the WAL allow recovery */                                    
        CheckRequiredParameterValues();                                    
                                            
        …                                    
        if (record != NULL)                                    
        {                                    
            …                                
            /*                                
             * main redo apply loop                                
             */                                
            do                                
            {                                
                …                            
                /*                            
                 * If we are attempting to enter Hot Standby mode, process                            
                 * XIDs we see                            
                 */                            
                if (standbyState >= STANDBY_INITIALIZED &&                            
                    TransactionIdIsValid(record->xl_xid))                        
                    RecordKnownAssignedTransactionIds(record->xl_xid);                        
                                            
                RmgrTable[record->xl_rmid].rm_redo(EndRecPtr, record);                            
                …                            
                                            
            } while (record != NULL && recoveryContinue);                                
            …                                
        }                                    
        …                                    
    }                                        
    …                                        
}                                            
初步学习pg_control文件之十五
初步学习pg_control文件之十五
/*                                
 * XLOG resource manager's routines                                
 *                                
 * Definitions of info values are in include/catalog/pg_control.h, though                                
 * not all record types are related to control file updates.                                
 */                                
void                                
xlog_redo(XLogRecPtr lsn, XLogRecord *record)                                
{                                
    …                            
    if (info == XLOG_NEXTOID)                            
    {                            
        …                        
    }                            
    …                            
    else if (info == XLOG_PARAMETER_CHANGE)                            
    {                            
        …                        
        /* Check to see if any changes to max_connections give problems */                        
        CheckRequiredParameterValues();                        
    }                            
} 
初步学习pg_control文件之十五

再看下面:

初步学习pg_control文件之十五
/*                                                
 * Check to see if required parameters are set high enough on this server                                                
 * for various aspects of recovery operation.                                                
 */                                                
static void                                                
CheckRequiredParameterValues(void)                                                
{                                                
    ...                                      
                         
    if (InArchiveRecovery && EnableHotStandby)                                            
    {                                            
        .../* We ignore autovacuum_max_workers when we make this test. */  
        RecoveryRequiresIntParameter("max_connections",                                        
                             MaxConnections,                    
                             ControlFile->MaxConnections);
...
} }
初步学习pg_control文件之十五





上一篇:《vSphere性能设计:性能密集场景下CPU、内存、存储及网络的最佳设计实践》一1.2.1 CPU基础设施基准


下一篇:controller 配置总结 | 学习笔记