v5-0003-Reflect-the-value-of-max_safe_fds-in-max_files_pe.patch
text/x-patch
Filename: v5-0003-Reflect-the-value-of-max_safe_fds-in-max_files_pe.patch
Type: text/x-patch
Part: 2
Patch
Format: format-patch
Series: patch v5-0003
Subject: Reflect the value of max_safe_fds in max_files_per_process
| File | + | − |
|---|---|---|
| src/backend/storage/file/fd.c | 7 | 0 |
From ff352f09fa72d6e359be6bf20a215c3724be2303 Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <github-tech@jeltef.nl>
Date: Wed, 12 Feb 2025 01:08:07 +0100
Subject: [PATCH v5 3/3] Reflect the value of max_safe_fds in
max_files_per_process
It is currently hard to figure out if max_safe_fds is significantly
lower than max_files_per_process. This starts reflecting the value of
max_safe_fds in max_files_per_process after our limit detection. We
still want to have two separate variables because for the bootstrap or
standalone-backend cases their values differ on purpose.
---
src/backend/storage/file/fd.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index f665422692d..03a16e8e5b6 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -1200,6 +1200,7 @@ set_max_safe_fds(void)
{
int usable_fds;
int already_open;
+ char *max_safe_fds_string;
/*----------
* We want to set max_safe_fds to
@@ -1214,6 +1215,12 @@ set_max_safe_fds(void)
max_safe_fds = Min(usable_fds - NUM_RESERVED_FDS, max_files_per_process);
+ /* Update GUC variable to allow users to see the result */
+ max_safe_fds_string = psprintf("%d", max_safe_fds);
+ SetConfigOption("max_files_per_process", max_safe_fds_string,
+ PGC_POSTMASTER, PGC_S_OVERRIDE);
+ pfree(max_safe_fds_string);
+
/*
* Make sure we still have enough to get by.
*/
--
2.43.0