|
53 | 53 | #include "postmaster/walwriter.h"
|
54 | 54 | #include "replication/slotsync.h"
|
55 | 55 | #include "replication/walreceiver.h"
|
| 56 | +#include "storage/dsm.h" |
56 | 57 | #include "storage/fd.h"
|
57 | 58 | #include "storage/ipc.h"
|
58 | 59 | #include "storage/pg_shmem.h"
|
@@ -219,9 +220,9 @@ PostmasterChildName(BackendType child_type)
|
219 | 220 | * Start a new postmaster child process.
|
220 | 221 | *
|
221 | 222 | * The child process will be restored to roughly the same state whether
|
222 |
| - * EXEC_BACKEND is used or not: it will be attached to shared memory, and fds |
223 |
| - * and other resources that we've inherited from postmaster that are not |
224 |
| - * needed in a child process have been closed. |
| 223 | + * EXEC_BACKEND is used or not: it will be attached to shared memory if |
| 224 | + * appropriate, and fds and other resources that we've inherited from |
| 225 | + * postmaster that are not needed in a child process have been closed. |
225 | 226 | *
|
226 | 227 | * 'startup_data' is an optional contiguous chunk of data that is passed to
|
227 | 228 | * the child process.
|
@@ -249,6 +250,13 @@ postmaster_child_launch(BackendType child_type,
|
249 | 250 | /* Detangle from postmaster */
|
250 | 251 | InitPostmasterChild();
|
251 | 252 |
|
| 253 | + /* Detach shared memory if not needed. */ |
| 254 | + if (!child_process_kinds[child_type].shmem_attach) |
| 255 | + { |
| 256 | + dsm_detach_all(); |
| 257 | + PGSharedMemoryDetach(); |
| 258 | + } |
| 259 | + |
252 | 260 | /*
|
253 | 261 | * Enter the Main function with TopMemoryContext. The startup data is
|
254 | 262 | * allocated in PostmasterContext, so we cannot release it here yet.
|
|
0 commit comments