From e73ed90730354e2f714cad1e4c226178b1361fb1 Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Mon, 21 Oct 2019 10:41:23 +1300 Subject: [PATCH 1/2] Adjust the constants used to reserve DSM segment slots. In some scenarios (probably only artifical tests), it is possible to run out of DSM segment slots by running a lot of parallel queries concurrently. Adjust the constants so that it's more difficult to hit the hard coded limit. Previously, a DSA area would create up to four segments at each size before doubling the size. After this commit, it will create only two at each size, before switching to larger segment sizes. Previously, the total limit on DSM slots allowed for 2 per connection. Switch to 5 per connection. Remove an obsolete nearby comment. Author: Thomas Munro (based on an idea from Andres Freund to introduce a GUC) Reviewed-by: Robert Haas (who suggested simply adjusting the numbers for now) Discussion: https://postre.es/m/CA%2BhUKGL6H2BpGbiF7Lj6QiTjTGyTLW_vLR%3DSn2tEBeTcYXiMKw%40mail.gmail.com --- src/backend/storage/ipc/dsm.c | 7 +------ src/backend/utils/mmgr/dsa.c | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/backend/storage/ipc/dsm.c b/src/backend/storage/ipc/dsm.c index 142293fd2c..641086cc04 100644 --- a/src/backend/storage/ipc/dsm.c +++ b/src/backend/storage/ipc/dsm.c @@ -45,13 +45,8 @@ #define PG_DYNSHMEM_CONTROL_MAGIC 0x9a503d32 -/* - * There's no point in getting too cheap here, because the minimum allocation - * is one OS page, which is probably at least 4KB and could easily be as high - * as 64KB. Each currently sizeof(dsm_control_item), currently 8 bytes. - */ #define PG_DYNSHMEM_FIXED_SLOTS 64 -#define PG_DYNSHMEM_SLOTS_PER_BACKEND 2 +#define PG_DYNSHMEM_SLOTS_PER_BACKEND 5 #define INVALID_CONTROL_SLOT ((uint32) -1) diff --git a/src/backend/utils/mmgr/dsa.c b/src/backend/utils/mmgr/dsa.c index 6590e55a24..8225e56e82 100644 --- a/src/backend/utils/mmgr/dsa.c +++ b/src/backend/utils/mmgr/dsa.c @@ -74,7 +74,7 @@ * dsm.c's limits on total number of segments), or limiting the total size * an area can manage when using small pointers. */ -#define DSA_NUM_SEGMENTS_AT_EACH_SIZE 4 +#define DSA_NUM_SEGMENTS_AT_EACH_SIZE 2 /* * The number of bits used to represent the offset part of a dsa_pointer. -- 2.20.1