Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ndB5E-00038m-26 for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Apr 2022 13:24:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ndB5C-0005pG-L2 for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Apr 2022 13:24:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ndB5C-0005oV-95 for pgsql-hackers@lists.postgresql.org; Sat, 09 Apr 2022 13:24:54 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ndB59-0004zw-OV for pgsql-hackers@lists.postgresql.org; Sat, 09 Apr 2022 13:24:53 +0000 Received: by mail-pf1-x42d.google.com with SMTP id x16so10718875pfa.10 for ; Sat, 09 Apr 2022 06:24:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ld/6wQyMK6j4XDfyVPaRV2svMMh4vCmOng3P4MtQ3e0=; b=Q8KZto81+84r2Ve8Ex4XbIJZl3EBSyWWlaOhUYHWU3/SAKhx+9AVuWEnevE0OCW7Bo N68WDcwGHf8/lhITe9MM2JI/lbMXTl1terlsnzWR/OrgxlAGHs3y647MKunC8JvbzuQ8 B8R3O6HDTV7daE4mLYT/+lmbeS+hcPXPZhIVSpWs85Zk6tBfE9ncLEhlubViIqGTv4wS JMfneOUqWJN9PCyKJsRAI5iU/eUFmyP5MdNVXpGjJ59xZCQYrO/3KEHJBkSGCTrC6La/ z+zwEXndapxLNgNZdzdmPlyTwUoC/sDyCuko6M5EvBz8gRMBM4AfloMQKVFLWREf0M40 TXcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ld/6wQyMK6j4XDfyVPaRV2svMMh4vCmOng3P4MtQ3e0=; b=Py7HGN0M3ZqVxKj/HpfWJVz1RhSVCBQlmOfVLVWzqiOERhcVkJ7y2hDw8VfX4TXDwu 1hk2YW8eYPPAhdO4VYDjMspp7PBcglGzlz3asKR6wuHWVV+t6SOyPOY+DVN83MCVYwlk LeIAG0kE+Syl1XW54imDYaUrCCaHbgDdFX+wn2jjHpNVG5VrcqeOLrPByNmXK2EeG0b6 tXRgjIrwG4NlpfslzWA+w53dnqr03hnZ+Pr6DldvPqVCh0WNnIsYwLBMkp0FSn7YZoUJ pHCMR8f5SZPfS93+AGt+n6UCxL8k6ARkx6UgQZDO3MJ4HqKFUYuhokcE4ARQuY2/8iQU x4Ng== X-Gm-Message-State: AOAM530x/yRUquKq/UC4zUJ8R9UVpP1YoecpnXLWQKVFy1B8llIvY1tP EZy6IBeAht1R52iLzG1ue58= X-Google-Smtp-Source: ABdhPJyu1qvKaupOWF+smulmWkEeD61aKc/zOE9YVIt9m/MCkkIguUKqGIsgjUVJncq1fKNgqBd07Q== X-Received: by 2002:a63:6c04:0:b0:398:54fb:5632 with SMTP id h4-20020a636c04000000b0039854fb5632mr19113385pgc.78.1649510690648; Sat, 09 Apr 2022 06:24:50 -0700 (PDT) Received: from jrouhaud (2001-b011-1005-38bf-f9a9-ed33-cd40-67a7.dynamic-ip6.hinet.net. [2001:b011:1005:38bf:f9a9:ed33:cd40:67a7]) by smtp.gmail.com with ESMTPSA id s10-20020a63a30a000000b003987eaef296sm24724770pge.44.2022.04.09.06.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Apr 2022 06:24:50 -0700 (PDT) Date: Sat, 9 Apr 2022 21:24:42 +0800 From: Julien Rouhaud To: Nathan Bossart Cc: Robert Haas , Andres Freund , Michael Paquier , "Bossart, Nathan" , Fujii Masao , "wangsh.fnst@fujitsu.com" , Bharath Rupireddy , Greg Sabino Mullane , Tom Lane , "pgsql-hackers@lists.postgresql.org" Subject: Re: make MaxBackends available in _PG_init Message-ID: References: <20220325023951.purgu4gb5jyrtc7w@jrouhaud> <20220325031146.cd23gaak5qlzdy6l@jrouhaud> <20220325063542.n6die7fmawluqkfp@jrouhaud> <20220325222317.dftrmzuyrb3iv62o@alap3.anarazel.de> <20220326072203.asge6bua7dxczf7m@jrouhaud> <20220326172316.obspcdmjqerislri@alap3.anarazel.de> <20220330163051.GA784643@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220330163051.GA784643@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Mar 30, 2022 at 09:30:51AM -0700, Nathan Bossart wrote: > On Tue, Mar 29, 2022 at 12:22:21PM -0400, Robert Haas wrote: > > It's not, though, because the original proposal was to change things > > around so that the value of MaxBackends would have been reliable in > > _PG_init(). If we'd done that, then extensions that are using it in > > _PG_init() would have gone from being buggy to being not-buggy. But > > since you advocated against that change, we instead committed > > something that caused them to go from being buggy to failing outright. > > That's pretty painful for people with such extensions. And IMHO, it's > > *much* more legitimate to want to size a data structure based on the > > value of MaxBackends than it is for extensions to override GUC values. > > If we can make the latter use case work in a sane way, OK, although I > > have my doubts about how sane it really is, but it can't be at the > > expense of telling extensions that have been (incorrectly) using > > MaxBackends in _PG_init() that we're throwing them under the bus. > > > > IMHO, the proper thing to do if certain GUC values are required for an > > extension to work is to put that information in the documentation and > > error out at an appropriate point if the user does not follow the > > directions. Then this issue does not arise. But there's no reasonable > > workaround for being unable to size data structures based on > > MaxBackends. > > FWIW I would be on board with reverting all the GetMaxBackends() stuff if > we made the value available in _PG_init() and stopped supporting GUC > overrides by extensions (e.g., ERROR-ing in SetConfigOption() when > process_shared_preload_libraries_in_progress is true). Yeah I would prefer this approach too, although it couldn't prevent extension from directly modifying the underlying variables so I don't know how effective it would be. On the bright side, I see that citus is using SetConfigOption() to increase max_prepared_transactions [1]. That's the only extension mentioned in that thread that does modify some GUC, and this GUC was already marked as PGDLLIMPORT since 2017 so it probably wasn't done that way for Windows compatibility reason. In the meantime, should we add an open item? [1] https://github.com/citusdata/citus/blob/master/src/backend/distributed/transaction/transaction_management.c#L656-L657