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 1lKd4Y-0004vQ-MY for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Mar 2021 08:23:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lKd4X-0001Tj-BI for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Mar 2021 08:23:01 +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 1lKd4X-0001Tc-4d for pgsql-hackers@lists.postgresql.org; Fri, 12 Mar 2021 08:23:01 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lKd4V-0006Af-4m for pgsql-hackers@lists.postgresql.org; Fri, 12 Mar 2021 08:23:00 +0000 Received: by mail-pl1-x62e.google.com with SMTP id a8so5062654plp.13 for ; Fri, 12 Mar 2021 00:22:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=UxQhzoOVSdJYQtZOMkqMZwlxHFn6255ISUXU+a8mhYk=; b=DX7fXJdinQfyPIpIdaGE7g4LbzW0c0RTahYOkC95ONtGS8ueIcCHYgNAu7+L+OeQTs OazIHO1q1aWPFJE0g/5MKTxUmGhLsUd2E8L+IiZlfsy5Kuey4nuCSgFfs4Mhy2+4zZND otSWq/budwSp5Zk2uktUC4t0ZPML+tPr05bSEfU/kajw2z4HHMsjyyuoZXPm6BHU8HLn K0Uitffo4ZMnXwn16NihUDBC9fG8+/tbatv1LV+SVMJyYdIQRCZj+pfccSMU5jRLVlFM Ety6OAaoptGUul3/8Bg5qp6GPEKTSfVJNOVdExHjWXy8sWgvACaCEKxCD1ur+BudtWzQ cG1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=UxQhzoOVSdJYQtZOMkqMZwlxHFn6255ISUXU+a8mhYk=; b=n+q/b/H4yDQDAabH6J+Ybd73rlM8V/FduQMCnvSheuLSMb+U3btHh5/dBL57gcx8P5 8DNuMYPngkKB3tWZ0DMwaRIB2Ycz2McDhEe2J6/dqM3zVuMPhsBMbjD5eBqy2Ix4E2RV WFY0ZDZirq1Hn0DD2ALEhISpmU1C69AGU0Ja2kIbEf2OlKQjLloL1/fuds977ZWkjVLZ 4hGjfoWW8I2evaEqYqZg3UC2+1JWnUC0+doYrafwHyzbUBRyPSwg73NJZ0hN5r2atVzd 61VzDO+hCTL1rLkj3EeqK7c6pKcBcNp2OxcxyOvyb3MjyLsrf8eQgcfHNRuTG6oROzIO rQDg== X-Gm-Message-State: AOAM530z4ltxwEaZQXvGBZCFa4JXKR9/Po5+1RdFoXE9pFbZ0p7jlScO IltacDkcS/vf+rq7gmPk7Rw= X-Google-Smtp-Source: ABdhPJz9qR3W50OxnHK5Vqi+pgCY8C4sBUxaAQyEg4or8jLlQvlYJWtIvVT2XRVnq4+JeDd2TdA+WQ== X-Received: by 2002:a17:902:8ec9:b029:e6:f8c:c3d1 with SMTP id x9-20020a1709028ec9b02900e60f8cc3d1mr13018622plo.42.1615537378028; Fri, 12 Mar 2021 00:22:58 -0800 (PST) Received: from nol (2001-b011-0008-97ef-7556-9f0a-3bbb-1260.dynamic-ip6.hinet.net. [2001:b011:8:97ef:7556:9f0a:3bbb:1260]) by smtp.gmail.com with ESMTPSA id a15sm1497794pju.34.2021.03.12.00.22.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 00:22:56 -0800 (PST) Date: Fri, 12 Mar 2021 16:23:25 +0800 From: Julien Rouhaud To: Jehan-Guillaume de Rorthais Cc: Andres Freund , Denis Laxalde , pgsql-hackers@lists.postgresql.org Subject: Re: [PATCH] Disable bgworkers during servers start in pg_upgrade Message-ID: <20210312082325.weltivlokfpc3gt2@nol> References: <20210121152357.s6eflhqyh4g5e6dv@dalibo.com> <20210124003611.lkyxhd2mpdmv5xzh@alap3.anarazel.de> <20210127102511.tvhu2wmrxoz3tle4@dalibo.com> <20210127144132.215fe4bb@firost> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210127144132.215fe4bb@firost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jan 27, 2021 at 02:41:32PM +0100, Jehan-Guillaume de Rorthais wrote: > > On Wed, 27 Jan 2021 11:25:11 +0100 > Denis Laxalde wrote: > > > Andres Freund a écrit : > > > > I wonder if we could > > > > > > a) set default_transaction_read_only to true, and explicitly change it > > > in the sessions that need that. > > According to Denis' tests discussed off-list, it works fine in regard with the > powa bgworker, albeit some complaints in logs. However, I wonder how fragile it > could be as bgworker could easily manipulate either the GUC or "BEGIN READ > WRITE". I realize this is really uncommon practices, but bgworker code from > third parties might be surprising. Given that having any writes happening at the wrong moment on the old cluster can end up corrupting the new cluster, and that the corruption might not be immediately visible we should try to put as many safeguards as possible. so +1 for the default_transaction_read_only as done in Denis' patch at minimum, but not only. AFAICT it should be easy to prevent all background worker from being launched by adding a check on IsBinaryUpgrade at the beginning of bgworker_should_start_now(). It won't prevent modules from being loaded, so this approach should be problematic. > > > b) when in binary upgrade mode / -b, error out on all wal writes in > > > sessions that don't explicitly set a session-level GUC to allow > > > writes. > > It feels safer because more specific to the subject. But I wonder if the > benefice worth adding some (limited?) complexity and a small/quick conditional > block in a very hot code path for a very limited use case. I don't think that it would add that much complexity or overhead as there's already all the infrastructure to prevent WAL writes in certain condition. It should be enough to add an additional test in XLogInsertAllowed() with some new variable that is set when starting in binary upgrade mode, and a new function to disable it that will be emitted by pg_dump / pg_dumpall in binary upgrade mode. > What about c) where the bgworker are not loaded by default during binary upgrade > mode / -b unless they explicitly set a bgw_flags (BGWORKER_BINARY_UPGRADE ?) > when they are required during pg_upgrade? As mentioned above +1 for not launching the bgworkers. Does anyone can think of a reason why some bgworker would really be needed during pg_upgrade, either on the source or the target cluster?