mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Fix background workers for EXEC_BACKEND
Commit da07a1e8
was broken for EXEC_BACKEND because I failed to realize
that the MaxBackends recomputation needed to be duplicated by
subprocesses in SubPostmasterMain. However, instead of having the value
be recomputed at all, it's better to assign the correct value at
postmaster initialization time, and have it be propagated to exec'ed
backends via BackendParameters.
MaxBackends stays as zero until after modules in
shared_preload_libraries have had a chance to register bgworkers, since
the value is going to be untrustworthy till that's finished.
Heikki Linnakangas and Álvaro Herrera
This commit is contained in:
@@ -61,4 +61,13 @@ extern Size ShmemBackendArraySize(void);
|
||||
extern void ShmemBackendArrayAllocation(void);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Note: MAX_BACKENDS is limited to 2^23-1 because inval.c stores the
|
||||
* backend ID as a 3-byte signed integer. Even if that limitation were
|
||||
* removed, we still could not exceed INT_MAX/4 because some places compute
|
||||
* 4*MaxBackends without any overflow check. This is rechecked in the relevant
|
||||
* GUC check hooks and in RegisterBackgroundWorker().
|
||||
*/
|
||||
#define MAX_BACKENDS 0x7fffff
|
||||
|
||||
#endif /* _POSTMASTER_H */
|
||||
|
Reference in New Issue
Block a user