Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rLtEX-001AYS-KT for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jan 2024 23:04:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rLtEU-0051Eh-LQ for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jan 2024 23:04:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rLtEU-0051EZ-3H for pgsql-hackers@lists.postgresql.org; Fri, 05 Jan 2024 23:04:06 +0000 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rLtER-0004yf-Es for pgsql-hackers@lists.postgresql.org; Fri, 05 Jan 2024 23:04:04 +0000 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-7bb87ff6144so1180639f.2 for ; Fri, 05 Jan 2024 15:04:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704495843; x=1705100643; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=PixiJzJ6UD0WEr6icUET3p9O9MVZtJIz6V6fgy3W0PI=; b=mYdJ0E3cj68V95GLJWZMRgdpXfxdVA3fLkCSB9mHLf4vIiki2LeCQzPhDWO9rr1+8/ KvVNrzHsz4vEkAWHHcnObJqXVVsx/Rc2OEHTfv7Te6kjhJ3PIySxf9vFGAfrHbEqAloP Iy0KP/WqOtrBe2CjqhDlF4JxhrX1pWet12vnh8n0HdPeWCOjvkv+lCOeLkU2d3BXWlih ycVh8/uiEs5tixuCW1fzAc+/FVMKvXAMdJ75UEUSEp4KOGb5OtV5rdGmpaSd2UDCdwTT PsgLQ0uhcOkaIN8720ZgIxCMvrN3S9pShhphoK7aPK9fwOQAQxn000wB6w1Fen3XsWtL ft8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704495843; x=1705100643; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PixiJzJ6UD0WEr6icUET3p9O9MVZtJIz6V6fgy3W0PI=; b=YT7jbdFKNhZdm09oGOHUx9B9BdxWT2DmQG3fefLjPzLeEpGJ2xn714cwOq7BNA9jDE M/KPwGPHC3qnm5W2ZNA+qt/LxDKImggyi9jgS2BmpOsqDufy9n1ki21s4o5X+ulXgJY8 3KLAJ4XTEIwPqvG58qrDENvzm5OHM4TmlruVnFKJMi2EHGJ3Gx4hK8NP7RGNZjtE6eV+ 5kTVvYlaeAT4tlnWHSWDANYo40sklw8soOzlEfR3BDUZVkwKcLF06V2IoEnG0TGg8xhA 8ywNKAgurMfsFZPM+14fIst2jUsP/UZlqQa2wMgVh2nrzi8qpaTpwXRuiihaFJXxATnJ hCRA== X-Gm-Message-State: AOJu0YyLeecdsepcVGbEyzrSvH2YSXnjX3R9HHZsvNzTjJcSlu+fGh6x GLI5WqZI+et5kkAv/95DmD4GmZ6i6h4= X-Google-Smtp-Source: AGHT+IGcA9A4uDXRNhcaPz0xlWJXlk4BDgLgeuXVL6dJIyyYPJovJA3sGgXowlr0W4aYVkHSIwzXZw== X-Received: by 2002:a5e:9910:0:b0:7bb:e6e0:fa06 with SMTP id t16-20020a5e9910000000b007bbe6e0fa06mr220438ioj.23.1704495842734; Fri, 05 Jan 2024 15:04:02 -0800 (PST) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id dm25-20020a0566023b9900b007baf1948186sm625629iob.42.2024.01.05.15.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 15:04:01 -0800 (PST) Date: Fri, 5 Jan 2024 17:03:57 -0600 From: Nathan Bossart To: Daniel Gustafsson Cc: bt23nguyent , Alvaro Herrera , pgsql-hackers@lists.postgresql.org Subject: Re: Improve the log message output of basic_archive when basic_archive.archive_directory parameter is not set Message-ID: <20240105230357.GA2425960@nathanxps13> References: <202309151049.dmfsxc5b3wyf@alvherre.pgsql> <7035FAFE-7E91-4B31-AA72-75EE82DB3F7B@yesql.se> <20230915143827.GA1912920@nathanxps13> <85b9e69997bbd5d8302a3a99a2de246d@oss.nttdata.com> <18cbd8ca6f5390cda2920644f891a419@oss.nttdata.com> <20230925222047.GA3173226@nathanxps13> <482056B1-D930-417C-9473-CB1A045E42AE@yesql.se> <20231013022559.GA1266364@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="45Z9DzgjV8m4Oswq" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --45Z9DzgjV8m4Oswq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Oct 13, 2023 at 11:02:39AM +0200, Daniel Gustafsson wrote: > That's a more compelling reason IMO. I'm not sure if I prefer the > GUC_check_errdetail-like approach better, I would for sure not be opposed to > reviewing a version of the patch doing it that way. > > Tung Nguyen: are you interested in updating the patch along these lines > suggested by Nathan? I gave it a try. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --45Z9DzgjV8m4Oswq Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0001-add-support-for-emitting-errdetail-from-archive-m.patch" From 7183005bb6786b63a5fd96ba5101849eb6f203e5 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Fri, 5 Jan 2024 17:01:10 -0600 Subject: [PATCH v4 1/1] add support for emitting errdetail from archive module check-configured callback --- contrib/basic_archive/basic_archive.c | 8 +++++++- src/backend/postmaster/pgarch.c | 8 +++++++- src/include/archive/archive_module.h | 8 ++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/contrib/basic_archive/basic_archive.c b/contrib/basic_archive/basic_archive.c index 804567e919..2c8721ebf6 100644 --- a/contrib/basic_archive/basic_archive.c +++ b/contrib/basic_archive/basic_archive.c @@ -161,7 +161,13 @@ check_archive_directory(char **newval, void **extra, GucSource source) static bool basic_archive_configured(ArchiveModuleState *state) { - return archive_directory != NULL && archive_directory[0] != '\0'; + if (archive_directory == NULL || archive_directory[0] == '\0') + { + arch_module_check_errdetail("basic_archive.archive_directory is not set."); + return false; + } + + return true; } /* diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c index 67693b0580..f663965d89 100644 --- a/src/backend/postmaster/pgarch.c +++ b/src/backend/postmaster/pgarch.c @@ -91,6 +91,7 @@ typedef struct PgArchData } PgArchData; char *XLogArchiveLibrary = ""; +char *arch_module_check_errdetail_string; /* ---------- @@ -408,12 +409,17 @@ pgarch_ArchiverCopyLoop(void) */ HandlePgArchInterrupts(); + /* Reset variables that might be set by the callback */ + arch_module_check_errdetail_string = NULL; + /* can't do anything if not configured ... */ if (ArchiveCallbacks->check_configured_cb != NULL && !ArchiveCallbacks->check_configured_cb(archive_module_state)) { ereport(WARNING, - (errmsg("archive_mode enabled, yet archiving is not configured"))); + (errmsg("archive_mode enabled, yet archiving is not configured"), + arch_module_check_errdetail_string ? + errdetail_internal("%s", arch_module_check_errdetail_string) : 0)); return; } diff --git a/src/include/archive/archive_module.h b/src/include/archive/archive_module.h index fd59b9faf4..763af76e54 100644 --- a/src/include/archive/archive_module.h +++ b/src/include/archive/archive_module.h @@ -56,4 +56,12 @@ typedef const ArchiveModuleCallbacks *(*ArchiveModuleInit) (void); extern PGDLLEXPORT const ArchiveModuleCallbacks *_PG_archive_module_init(void); +/* Support for messages reported from archive module callbacks. */ + +extern PGDLLIMPORT char *arch_module_check_errdetail_string; + +#define arch_module_check_errdetail \ + pre_format_elog_string(errno, TEXTDOMAIN), \ + arch_module_check_errdetail_string = format_elog_string + #endif /* _ARCHIVE_MODULE_H */ -- 2.25.1 --45Z9DzgjV8m4Oswq--