Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-18 Thread Fujii Masao
On 2024/07/19 1:27, Robert Haas wrote: On Thu, Jul 18, 2024 at 9:47 AM Fujii Masao wrote: "WAL not generated under wal_level=minimal" sounds a bit confusing?? How about "WAL generated while wal_level is replica or higher" instead? Committed and back-patched to 17 with approximately that ch

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-18 Thread Robert Haas
On Thu, Jul 18, 2024 at 9:47 AM Fujii Masao wrote: > "WAL not generated under wal_level=minimal" sounds a bit confusing?? > How about "WAL generated while wal_level is replica or higher" instead? Committed and back-patched to 17 with approximately that change, but reworded slightly to make the te

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-18 Thread Fujii Masao
On 2024/07/17 22:44, Robert Haas wrote: On Tue, Jul 16, 2024 at 1:16 PM Fujii Masao wrote: I don't have another solution that can be pushed into v17. I understand the risks raised so far, so I'm okay with just pushing the "fast_forward" patch. It might be helpful to add a note to the summari

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-17 Thread Robert Haas
On Tue, Jul 16, 2024 at 1:16 PM Fujii Masao wrote: > I don't have another solution that can be pushed into v17. I understand > the risks raised so far, so I'm okay with just pushing the "fast_forward" > patch. > It might be helpful to add a note to the summarize_wal documentation, > for example,

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-16 Thread Fujii Masao
On 2024/07/17 1:30, Nathan Bossart wrote: On Tue, Jul 16, 2024 at 12:23:19PM -0400, Robert Haas wrote: TBH, I don't want to do that. I think it's too fragile. It's the sort of thing that just barely works given the exact behavior of these particular GUCs, but it relies on a bunch of subtle as

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-16 Thread Nathan Bossart
On Tue, Jul 16, 2024 at 12:23:19PM -0400, Robert Haas wrote: > TBH, I don't want to do that. I think it's too fragile. It's the sort > of thing that just barely works given the exact behavior of these > particular GUCs, but it relies on a bunch of subtle assumptions which > won't be evident to futu

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-16 Thread Robert Haas
On Mon, Jul 15, 2024 at 4:10 PM Nathan Bossart wrote: > You don't, but the GUC check hook should always return true when > summarize_wal is processed first. We'd rely on the PostmasterMain() check > to fail in that case. OK, I see. So at startup time, the check hook might or might not catch a co

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-15 Thread Nathan Bossart
On Mon, Jul 15, 2024 at 04:03:13PM -0400, Robert Haas wrote: > On Mon, Jul 15, 2024 at 2:47 PM Nathan Bossart > wrote: >> My understanding is that the correctness of this GUC check hook depends on >> wal_level being a PGC_POSTMASTER GUC. The check hook would always return >> true during startup,

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-15 Thread Robert Haas
On Mon, Jul 15, 2024 at 2:47 PM Nathan Bossart wrote: > My understanding is that the correctness of this GUC check hook depends on > wal_level being a PGC_POSTMASTER GUC. The check hook would always return > true during startup, and there'd be an additional cross-check in > PostmasterMain() that

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-15 Thread Nathan Bossart
On Mon, Jul 15, 2024 at 01:47:14PM -0500, Nathan Bossart wrote: > On Mon, Jul 15, 2024 at 02:30:42PM -0400, Robert Haas wrote: >> I guess I'm in the group of people who doesn't understand how this can >> possibly work. There's no guarantee about the order in which GUC check >> hooks are called, so

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-15 Thread Nathan Bossart
On Mon, Jul 15, 2024 at 02:30:42PM -0400, Robert Haas wrote: > On Sun, Jul 14, 2024 at 10:56 PM Fujii Masao > wrote: >> I don't think it's a rare scenario since summarize_wal can be enabled >> after starting the server with wal_level=minimal. Therefore, I believe >> such a configuration should be

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-15 Thread Robert Haas
On Sun, Jul 14, 2024 at 10:56 PM Fujii Masao wrote: > I don't think it's a rare scenario since summarize_wal can be enabled > after starting the server with wal_level=minimal. Therefore, I believe > such a configuration should be prohibited using a GUC check hook, > as my patch does. I guess I'm

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-14 Thread Fujii Masao
On 2024/07/12 1:16, Robert Haas wrote: On Thu, Jul 11, 2024 at 6:51 AM Fujii Masao wrote: It looks like the fast_forward field in WalSummarizerData is no longer necessary. So far, I haven't found any other issues with the patch. Thanks for reviewing. Regarding fast_forward, I think I had

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-11 Thread Tom Lane
Nathan Bossart writes: > On Wed, Jul 10, 2024 at 01:41:41PM -0500, Nathan Bossart wrote: >> On Wed, Jul 10, 2024 at 11:11:13AM -0400, Tom Lane wrote: >>> We went through a ton of permutations of that kind of >>> idea years ago, when it first became totally clear that cross-checks >>> between GUCs

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-11 Thread Nathan Bossart
On Wed, Jul 10, 2024 at 01:41:41PM -0500, Nathan Bossart wrote: > On Wed, Jul 10, 2024 at 11:11:13AM -0400, Tom Lane wrote: >> We went through a ton of permutations of that kind of >> idea years ago, when it first became totally clear that cross-checks >> between GUCs do not work nicely if implemen

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-11 Thread Robert Haas
On Thu, Jul 11, 2024 at 6:51 AM Fujii Masao wrote: > So far, I haven't found any other issues with the patch. Here is a new version that removes the hunks you highlighted and also adds a test case. -- Robert Haas EDB: http://www.enterprisedb.com v4-0001-Do-not-summarize-WAL-if-generated-with-

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-11 Thread Robert Haas
On Thu, Jul 11, 2024 at 6:51 AM Fujii Masao wrote: > It looks like the fast_forward field in WalSummarizerData is no longer > necessary. > > So far, I haven't found any other issues with the patch. Thanks for reviewing. Regarding fast_forward, I think I had the idea in mind that perhaps it shoul

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-11 Thread Fujii Masao
On 2024/07/11 1:35, Robert Haas wrote: On Wed, Jul 10, 2024 at 10:10 AM Robert Haas wrote: On Wed, Jul 10, 2024 at 1:56 AM Fujii Masao wrote: I believe this issue occurs when the server is shut down cleanly. The shutdown-checkpoint record retains the wal_level value used before the shutdow

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Nathan Bossart
On Wed, Jul 10, 2024 at 11:11:13AM -0400, Tom Lane wrote: > We went through a ton of permutations of that kind of > idea years ago, when it first became totally clear that cross-checks > between GUCs do not work nicely if implemented in check_hooks. > (You can find all the things we tried in the co

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Robert Haas
On Wed, Jul 10, 2024 at 10:10 AM Robert Haas wrote: > On Wed, Jul 10, 2024 at 1:56 AM Fujii Masao > wrote: > > I believe this issue occurs when the server is shut down cleanly. > > The shutdown-checkpoint record retains the wal_level value used > > before the shutdown. If wal_level is changed af

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Nathan Bossart
On Thu, Jul 11, 2024 at 01:02:25AM +0900, Fujii Masao wrote: > On 2024/07/10 23:18, Nathan Bossart wrote: >> Yeah. I initially thought this patch might be okay, at least as a stopgap, >> but Jelte pointed out a case where it doesn't work, namely when you have >> something like the following in the

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Nathan Bossart
On Wed, Jul 10, 2024 at 11:54:38AM -0400, Tom Lane wrote: > Nathan Bossart writes: >> I haven't tested it, but from skimming around the code, it looks like >> ProcessConfigFileInternal() would deduplicate any previous entries in the >> file prior to applying the values and running the check hooks.

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Fujii Masao
On 2024/07/11 0:44, Nathan Bossart wrote: On Wed, Jul 10, 2024 at 11:11:13AM -0400, Tom Lane wrote: Please, no. We went through a ton of permutations of that kind of idea years ago, when it first became totally clear that cross-checks between GUCs do not work nicely if implemented in check_h

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Fujii Masao
On 2024/07/10 23:18, Nathan Bossart wrote: On Wed, Jul 10, 2024 at 10:10:30AM -0400, Robert Haas wrote: On Wed, Jul 10, 2024 at 1:56 AM Fujii Masao wrote: I'm sure this patch is necessary as a safeguard for WAL summarization. OTOH, I also think we should apply the patch I proposed earlier i

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Tom Lane
Nathan Bossart writes: > I haven't tested it, but from skimming around the code, it looks like > ProcessConfigFileInternal() would deduplicate any previous entries in the > file prior to applying the values and running the check hooks. Else, > reloading a configuration file with multiple startup-

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Nathan Bossart
On Wed, Jul 10, 2024 at 11:11:13AM -0400, Tom Lane wrote: > Please, no. We went through a ton of permutations of that kind of > idea years ago, when it first became totally clear that cross-checks > between GUCs do not work nicely if implemented in check_hooks. > (You can find all the things we tr

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Tom Lane
Jelte Fennema-Nio writes: > On Wed, 10 Jul 2024 at 16:18, Nathan Bossart wrote: >> Yeah. I initially thought this patch might be okay, at least as a stopgap, >> but Jelte pointed out a case where it doesn't work, namely when you have >> something like the following in the config file: >> >> wal

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Jelte Fennema-Nio
On Wed, 10 Jul 2024 at 16:46, Nathan Bossart wrote: > Do we actually need to look at pmState? Or could we just skip > it if the context is <= PGC_S_ARGV? I'm not 100% sure, but I think PGC_S_FILE would still be used when postgresql.conf changes and on SIGHUP is sent. And we would want the check_

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Nathan Bossart
On Wed, Jul 10, 2024 at 04:29:14PM +0200, Jelte Fennema-Nio wrote: > On Wed, 10 Jul 2024 at 16:18, Nathan Bossart wrote: >> Yeah. I initially thought this patch might be okay, at least as a stopgap, >> but Jelte pointed out a case where it doesn't work, namely when you have >> something like the

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Jelte Fennema-Nio
On Wed, 10 Jul 2024 at 16:18, Nathan Bossart wrote: > Yeah. I initially thought this patch might be okay, at least as a stopgap, > but Jelte pointed out a case where it doesn't work, namely when you have > something like the following in the config file: > > wal_level = 'minimal' >

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Nathan Bossart
On Wed, Jul 10, 2024 at 10:10:30AM -0400, Robert Haas wrote: > On Wed, Jul 10, 2024 at 1:56 AM Fujii Masao > wrote: >> I'm sure this patch is necessary as a safeguard for WAL summarization. >> OTOH, I also think we should apply the patch I proposed earlier >> in this thread, which prevents summar

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-10 Thread Robert Haas
On Wed, Jul 10, 2024 at 1:56 AM Fujii Masao wrote: > I believe this issue occurs when the server is shut down cleanly. > The shutdown-checkpoint record retains the wal_level value used > before the shutdown. If wal_level is changed after this, > the wal_level that indicated by the shutdown-checkpo

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-09 Thread Fujii Masao
On 2024/07/10 2:57, Robert Haas wrote: Here's v2. Thanks for the patch! With v2 patch, I found a case where WAL data generated with wal_level = minimal is summarized. In the steps below, the hoge2_minimal table is created under wal_level = minimal, but its block modification information is

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-09 Thread Robert Haas
Here's v2. Jakub Wartak pointed out to me off-list that this broke the case where a chain of incrementals crosses a timeline switch. That made me realize that I also need to add the WAL level to XLOG_END_OF_RECOVERY, so this version does that. I also forgot to mention that this patch changes beha

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-08 Thread Robert Haas
On Thu, Jul 4, 2024 at 10:35 AM Fujii Masao wrote: > +1 for v18 or later. However, since the reported issue is in v17, > it needs to be addressed without such a improved check mechanism. Here is a draft patch for that. This is only lightly tested at this point, so further testing would be greatly

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-04 Thread Fujii Masao
On 2024/07/03 23:29, Nathan Bossart wrote: On Wed, Jul 03, 2024 at 11:08:48PM +0900, Fujii Masao wrote: +/* + * GUC check_hook for summarize_wal + */ +bool +check_summarize_wal(bool *newval, void **extra, GucSource source) +{ + if (*newval && wal_level == WAL_LEVEL_MINIMAL) + { +

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-03 Thread Robert Haas
On Wed, Jul 3, 2024 at 10:09 AM Fujii Masao wrote: > The documentation states that "WAL summarization cannot be enabled when > wal_level is set to minimal." Therefore, at startup, the postmaster checks > these settings and exits with an error if they are not configured properly. > > However, I f

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-03 Thread Tom Lane
Nathan Bossart writes: > This sort of thing comes up enough that perhaps we should add a > better-supported way to deal with GUCs that depend on each other... Yeah, a GUC check hook that tries to inspect the value of some other GUC is generally going to create more problems than it solves; we've

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-03 Thread Jelte Fennema-Nio
On Wed, 3 Jul 2024 at 16:46, Jelte Fennema-Nio wrote: > > Ugh copy paste mistake, this is what I meant > > On Wed, 3 Jul 2024 at 16:45, Jelte Fennema-Nio wrote: > > This hits the already existing check: > > summarize_wal = 'true' > > wal_level = 'minimal' > > > > This hits the new check: > > wal_

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-03 Thread Jelte Fennema-Nio
Ugh copy paste mistake, this is what I meant On Wed, 3 Jul 2024 at 16:45, Jelte Fennema-Nio wrote: > This hits the already existing check: > summarize_wal = 'true' > wal_level = 'minimal' > > This hits the new check: > summarize_wal = 'true' > wal_level = 'minimal' > > And actually this would thr

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-03 Thread Jelte Fennema-Nio
On Wed, 3 Jul 2024 at 16:30, Nathan Bossart wrote: > IME these sorts of GUC hooks that depend on the value of other GUCs tend to > be quite fragile. This one might be okay because wal_level defaults to > 'replica' and because there is an additional check in postmaster.c, but > that at least deser

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-03 Thread Daniel Gustafsson
> On 3 Jul 2024, at 16:29, Nathan Bossart wrote: > This sort of thing comes up enough that perhaps we should add a > better-supported way to deal with GUCs that depend on each other... +1 -- Daniel Gustafsson

Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-03 Thread Nathan Bossart
On Wed, Jul 03, 2024 at 11:08:48PM +0900, Fujii Masao wrote: > +/* > + * GUC check_hook for summarize_wal > + */ > +bool > +check_summarize_wal(bool *newval, void **extra, GucSource source) > +{ > + if (*newval && wal_level == WAL_LEVEL_MINIMAL) > + { > + GUC_check_errmsg("WAL c

Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal

2024-07-03 Thread Fujii Masao
Hi, The documentation states that "WAL summarization cannot be enabled when wal_level is set to minimal." Therefore, at startup, the postmaster checks these settings and exits with an error if they are not configured properly. However, I found that summarize_wal can still be enabled while the