1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

Fix assertion in pg_get_shmem_pagesize() in single-user mode

Remove assertion that was too strict, and tripped if you queried the
pg_shmem_allocations_numa or the pg_buffercache_os_pages view in
single-user mode.

The point of the assertion was that the function should only be called
after "the server has started", but it would be OK to call it from the
postmaster, too, as long as it's after startup, specifically after
huge_pages_status has been set.  We already have a direct assertion
for that.

Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAJTYsWV-=w5_oFgCnfAixWGc=gMa2pkDinLyGLsb4sKcDaf2FA@mail.gmail.com
Backpatch-through: 18
This commit is contained in:
Heikki Linnakangas
2026-09-24 14:38:17 +03:00
parent 5aeb36f327
commit dae3463fa9

View File

@@ -1379,7 +1379,7 @@ pg_get_shmem_allocations_numa(PG_FUNCTION_ARGS)
* If the shared segment was allocated using huge pages, returns the size of
* a huge page. Otherwise returns the size of regular memory page.
*
* This should be used only after the server is started.
* This should be used only after shared memory has been initialized.
*/
Size
pg_get_shmem_pagesize(void)
@@ -1394,7 +1394,6 @@ pg_get_shmem_pagesize(void)
os_page_size = sysconf(_SC_PAGESIZE);
#endif
Assert(IsUnderPostmaster);
Assert(huge_pages_status != HUGE_PAGES_UNKNOWN);
if (huge_pages_status == HUGE_PAGES_ON)