Hi,

> Since no one seems to object so far I prepared the patch.

Turned out patch v1 fails on cfbot on Windows due to extra Assert I added [1]:

```
abort() has been calledTRAP: failed Assert("!IsUnderPostmaster"),
File: "../src/backend/storage/ipc/ipci.c", Line: 320, PID: 4040
abort() has been calledTRAP: failed Assert("!IsUnderPostmaster"),
File: "../src/backend/storage/ipc/ipci.c", Line: 320, PID: 3484
```

Which indicates that currently shmem_startup_hook **can** be called by
child processes on Windows. Not 100% sure if this is a desired
behavior considering the fact that it is inconsistent with the current
behavior on *nix systems.

Here is patch v2. Changes comparing to v1:

```
--- a/src/backend/storage/ipc/ipci.c
+++ b/src/backend/storage/ipc/ipci.c
@@ -311,15 +311,8 @@ CreateSharedMemoryAndSemaphores(void)
        /*
         * Now give loadable modules a chance to set up their shmem allocations
         */
-       if (shmem_startup_hook)
-       {
-               /*
-                * The following assert ensures that
shmem_startup_hook is going to be
-                * called only by the postmaster, as promised in the
documentation.
-                */
-               Assert(!IsUnderPostmaster);
+       if (!IsUnderPostmaster && shmem_startup_hook)
                shmem_startup_hook();
-       }
 }
```

Thoughts?

[1]: 
https://api.cirrus-ci.com/v1/artifact/task/4924036300406784/testrun/build/testrun/pg_stat_statements/regress/log/postmaster.log

-- 
Best regards,
Aleksander Alekseev

Attachment: v2-0001-Clarify-the-usage-of-shmem_startup_hook.patch
Description: Binary data

Reply via email to