/* * Early initialization of a backend (either standalone or under postmaster). * This happens even before InitPostgres. * * This is separate from InitPostgres because it is also called by auxiliary * processes, such as the background writer process, which may not call * InitPostgres at all. */ void BaseInit(void) { /* * Attach to shared memory and semaphores, and initialize our * input/output/debugging file descriptors. */ InitCommunication(); DebugFileOpen(); /* Do local initialization of file, storage and buffer managers */ InitFileAccess(); smgrinit(); InitBufferPoolAccess(); }
static void FileRepSubProcess_InitProcess(void) { SetProcessingMode(InitProcessing); /* * Create a resource owner to keep track of our resources */ CurrentResourceOwner = ResourceOwnerCreate(NULL, FileRepProcessTypeToString[fileRepProcessType]); InitXLOGAccess(); SetProcessingMode(NormalProcessing); InitBufferPoolAccess(); /* * Don't add Filerep backend subprocesses to the proc array. * * This avoids any deadlock situations during Filerep transition. E.g. If * a normal backend has acquired ProcArrayLock and is waiting for Filerep * transition to finish, the Filerep backend subprocesses will deadlock * forever as they can't acquire the ProcArray lock to remove themselves * from the ProcArray. This directly causes the transition to stall and * thus the whole system. */ /* * Initialize my entry in the shared-invalidation manager's array of * per-backend data. * * Sets up MyBackendId, a unique backend identifier. */ MyBackendId = InvalidBackendId; SharedInvalBackendInit(false); if (MyBackendId > MaxBackends || MyBackendId <= 0) elog(FATAL, "bad backend id: %d", MyBackendId); /* * bufmgr needs another initialization call too */ InitBufferPoolBackend(); }