Hi Hackers: I find the value in function _PG_init, the value of MaxBackends is 0. In source, I find that the postmaster will first load library, and then calculate the value of MaxBackends.
In the old version, the MaxBackends was calculated by: MaxBackends = MaxConnections + autovacuum_max_workers + 1 + GetNumShmemAttachedBgworkers(); Because any extension can register workers which will affect the return value of GetNumShmemAttachedBgworkers. InitializeMaxBackends must be called after shared_preload_libraries. This is also mentioned in comments. Now, function GetNumShmemAttachedBgworkers was deleted and replaced by guc max_worker_processes, so if we changed the calling order like: Step1: calling InitializeMaxBackends. Step2: calling process_shared_preload_libraries In this order extension can get the correct value of MaxBackends in _PG_init. Any thoughts? Regards
0001-Make-MaxBackends-available-in-_PG_init.patch
Description: 0001-Make-MaxBackends-available-in-_PG_init.patch