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 1ngkUF-00026n-5X for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Apr 2022 09:49:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ngkUD-0001SN-QE for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Apr 2022 09:49:29 +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 1ngkUD-0001SE-HH for pgsql-hackers@lists.postgresql.org; Tue, 19 Apr 2022 09:49:29 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ngkU7-0003vH-2A for pgsql-hackers@lists.postgresql.org; Tue, 19 Apr 2022 09:49:28 +0000 Received: by mail-pl1-x62d.google.com with SMTP id q3so15163100plg.3 for ; Tue, 19 Apr 2022 02:49:23 -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=IWRKFMj0SfvmucGxAKbsOlzQM1v8VWIscYNPUhxLfJY=; b=iFU1eJ8JXEKYTZjmFuG+2JWb3OlHVQ0JNrqUjIJFeFAXhxXqMcSPo/ts6Q3VIr5LKH SHg2c4f9spPHSp8xkxxkKF8ofJ6WaIWvn8wzAl9zGEQ6kvpcF9NeS6WMCEsYrxcJrnQY vMJdSUOQl541d7KKy6747zBTnHJTnY63hithM0xzXgYREFwU2sG7dC1+GVe9PIhQjB4t aJCBp1TjPCUOQq2CQkK/5BjAO7SeMuCyvl84pU+sY6iJU/1WXaCjKjrGZgr/3wLMKAve /lAa4coHDvFT9O3oz1QdbNohBgdAzeXcZ6AeuYAIpgsUYEct1cgaPCjsm2aRtqEjb0Fe LPZA== 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=IWRKFMj0SfvmucGxAKbsOlzQM1v8VWIscYNPUhxLfJY=; b=cimA/QGMV06GK5hda+wqwWvDHTewu6Di0750+Plp+SkHfLAwUrF2jP6JP/jK2VRoXk dSXz1a/pVdN2/Jl03lV1FRSGiJRC0xX0/VH+l8hJHLpD4cB7tedotx9T6lXw1U0FiTX1 LDqg5+OxBQY4DEglc7KQBH6ZH1FAPjCoE/UMKLHlyLmgUs1TeLLuzkO/CGY0taoa8qfQ QKqxUqE9kDJYU5mIt40TLMRCVrSMQ9z41R427hIaazeHf7bLZDx12UhjCiXN66/vxisk fQk/0BAhNCB6txfNnQAl6Ja53mBlHJgAwZ4f60CATf2ChsOgY26fgnAx77naDF7OXdJm CIXQ== X-Gm-Message-State: AOAM532Hq58p+E3wn3XtEdJqvwhnky7uA9MzndP+FzwRMI/SngyBwytp 7bi8sbCd7m1N4ShC319W39A= X-Google-Smtp-Source: ABdhPJz+YJqq2JzCPoWdyYZ9YBzDQGMZbSulWD+g7ClRrsATv6T/HySSXVjdbtZLqES4VFwTYQcnDQ== X-Received: by 2002:a17:902:aa06:b0:158:f13b:4859 with SMTP id be6-20020a170902aa0600b00158f13b4859mr12721685plb.141.1650361761015; Tue, 19 Apr 2022 02:49:21 -0700 (PDT) Received: from jrouhaud (2001-b011-1005-fd0b-6d68-0208-e235-7ce3.dynamic-ip6.hinet.net. [2001:b011:1005:fd0b:6d68:208:e235:7ce3]) by smtp.gmail.com with ESMTPSA id k9-20020a635a49000000b0039cc5dc237fsm15825294pgm.8.2022.04.19.02.49.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 02:49:20 -0700 (PDT) Date: Tue, 19 Apr 2022 17:49:13 +0800 From: Julien Rouhaud To: Tom Lane Cc: Nathan Bossart , Robert Haas , Andres Freund , Michael Paquier , "Bossart, Nathan" , Fujii Masao , "wangsh.fnst@fujitsu.com" , Bharath Rupireddy , Greg Sabino Mullane , "pgsql-hackers@lists.postgresql.org" Subject: Re: make MaxBackends available in _PG_init Message-ID: References: <1102589.1649865908@sss.pgh.pa.us> <20220413183040.GA2116671@nathanxps13> <20220414162215.GB2163833@nathanxps13> <1522578.1649954386@sss.pgh.pa.us> <20220418225244.GA2387491@nathanxps13> <2395586.1650324834@sss.pgh.pa.us> <20220419001220.GA2389330@nathanxps13> <2470289.1650327424@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2470289.1650327424@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Mon, Apr 18, 2022 at 08:17:04PM -0400, Tom Lane wrote: > Nathan Bossart writes: > > I'm looking for a clean way to ERROR if someone attempts to call > > RequestAddinShmemSpace() or RequestNamedLWLockTranche() outside of the > > hook. Currently, we are using static variables in ipci.c and lwlock.c to > > silently ignore invalid requests. I could add a new 'extern bool' called > > 'process_shmem_requests_in_progress', but extensions could easily hack > > around that to allow requests in _PG_init(). Maybe I am overthinking all > > this and that is good enough. > > If they do that and it breaks something, that's their fault not ours. > (It's not like there's not $BIGNUM ways for a C-language module to > break the backend, anyway.) Agreed. Similarly the process_shared_preload_libraries_in_progress flag could be modified by extension, and that wouldn't be any better. > BTW, I'd make such errors FATAL, as it's unlikely that we can recover > cleanly from an error during initialization of a loadable module. > The module's likely to be only partially initialized/hooked in. While at it, should we make process_shmem_requests_in_progress true when the new hook is called? The hook should only be called when that's the case, and extension authors may feel like asserting it.