Re: "38.10.10. Shared Memory and LWLocks" may require a clarification - Mailing list pgsql-hackers

From Aleksander Alekseev
Subject Re: "38.10.10. Shared Memory and LWLocks" may require a clarification
Date
Msg-id CAJ7c6TNyZiqWv4We76FjNPQkwtna65yKwaVErwWjv+JyLEnbpA@mail.gmail.com
Whole thread Raw
In response to Re: "38.10.10. Shared Memory and LWLocks" may require a clarification  (Aleksander Alekseev <aleksander@timescale.com>)
Responses Re: "38.10.10. Shared Memory and LWLocks" may require a clarification
List pgsql-hackers
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

pgsql-hackers by date:

Previous
From: Aleksander Alekseev
Date:
Subject: Re: RFI: Extending the TOAST Pointer
Next
From: "Tristan Partin"
Date:
Subject: Make pgbench exit on SIGINT more reliably