Re: "38.10.10. Shared Memory and LWLocks" may require a clarification

From: Aleksander Alekseev <aleksander(at)timescale(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: "38.10.10. Shared Memory and LWLocks" may require a clarification
Date: 2023-05-22 14:04:06
Message-ID: CAJ7c6TNyZiqWv4We76FjNPQkwtna65yKwaVErwWjv+JyLEnbpA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
v2-0001-Clarify-the-usage-of-shmem_startup_hook.patch application/octet-stream 15.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tristan Partin 2023-05-22 15:02:02 Make pgbench exit on SIGINT more reliably
Previous Message Aleksander Alekseev 2023-05-22 13:47:12 Re: RFI: Extending the TOAST Pointer