Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hfaiu-0002tX-Bi for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Jun 2019 01:58:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hfais-0004TB-5D for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Jun 2019 01:58:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hfair-0004RE-Go for pgsql-hackers@lists.postgresql.org; Tue, 25 Jun 2019 01:58:13 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hfaij-0008ED-Ce for pgsql-hackers@postgresql.org; Tue, 25 Jun 2019 01:58:11 +0000 Received: by mail-pg1-x543.google.com with SMTP id s27so8090795pgl.2 for ; Mon, 24 Jun 2019 18:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=DjGqwkdConhEctSVWKq3spAZC3AwXipPig/YN61sqSs=; b=I9KETWjJ6ZXgJtodO+vK7NHVMg/jauOVTOztaAF6DEBvig9Qjkn+ueL8JP8Za+XY1Y vCd1bTI5nlPVj4Zoy5PvY+kz7a/3ysTkCFVW4vB1SsZOljngGFO3ASl6QE5R4ZO6Cc3b oRinzZSIxhZigf45rs8Eop8Fc2D2b+d900c6bl1fSVrQslUEPolkHK0c/uY7nJIGQ+ru LbEsmRhxCnDIwnCWVkZd2GFnLYrvDgplyiAkYRKm+sfD92CkflnVosWxTA+DaWdxgbga 8XsoMfdzxJN9aWhi7uhZ2qk9nHy+LY1tyiU8cpIqAMx4jJquYgdBYmsIx3KjPgbyum+L E/Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=DjGqwkdConhEctSVWKq3spAZC3AwXipPig/YN61sqSs=; b=TGJTbtEoarib639sBFrf8p//jmqXKGPkSQuI2zWuEz04sacK1VKTf8zxPh7ACpTuz8 AKwsiERihR5t9PuK7JWCrDid/d7ID0Euispc92JH8bGs4j1yZ+FSLEaxu8evSBQ3aUwX mphXnpXCQJavG+LpMlaMr8cx2ZJfX+UwECMkEXuS2zFL+JvBpnOpAThAs3aaHmV/J4zR dbSR1tYhWBF8OeNz8pxz2L4mp1UU/c9d3qTS/F9DU+cBZwgdi2A8KNLxtv6kdq+mbPHO Us5k/T8FBBm27F7gCdqavLm1dL1qmBv7sjb8MYx8eLmDUYiMuOPLctmAlKzDuJ0GX4NJ +QlQ== X-Gm-Message-State: APjAAAWhfJN6SxiBv7Jh6h6aQx/Vv4SxaIrRK4A/SbvFIIVMVecmpwiV QST7INjJQzV+vWHELFR77CApd9Wt6Q2Ana0PJpVZRQ4HgApGei4hWltOm4sRWkOLh96ah2XpVFH P/gmMx/fUcFGGF6nOZqKf4UY6OseIhi6GfTm9JuCjD3Vxp23QSy1u/x8+blJTCB8hV85pkRhx50 4IlLNjcIVgmGS+ X-Google-Smtp-Source: APXvYqzqxTJ080+eMnEVp3C+cm4hWpe+MZOe/YtSFgn3jK12ci2gFWYHaKTvRMWHLE7JqO6/m3DofQ== X-Received: by 2002:a65:654f:: with SMTP id a15mr18219010pgw.73.1561427883620; Mon, 24 Jun 2019 18:58:03 -0700 (PDT) Received: from osaka.octopusnet (p14091-ipngn9701marunouchi.tokyo.ocn.ne.jp. [153.219.173.91]) by smtp.gmail.com with ESMTPSA id v9sm16735574pgj.69.2019.06.24.18.58.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jun 2019 18:58:02 -0700 (PDT) Subject: Re: [PATCH] Stop ALTER SYSTEM from making bad assumptions To: Alvaro Herrera , Robert Haas , Stephen Frost Cc: Amit Kapila , "pgsql-hackers@postgresql.org" References: <20190624190625.GA10524@alvherre.pgsql> From: Ian Barwick Message-ID: <2be33909-bb7f-7ff9-d6e7-2484fd484df6@2ndquadrant.com> Date: Tue, 25 Jun 2019 10:57:58 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190624190625.GA10524@alvherre.pgsql> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 6/25/19 4:06 AM, Alvaro Herrera wrote: > On 2019-Jun-24, Robert Haas wrote: > >> On Sat, Jun 22, 2019 at 5:13 PM Stephen Frost wrote: >>> All that said, whatever code it is that we write for pg_basebackup to >>> do this properly should go into our client side library, so other tools >>> can leverage that and avoid having to write it themselves. >> >> That is probably only going to help people who are writing in C (or >> maybe some close family member) and a lot of tools for managing >> PostgreSQL will be written in scripting languages. > > But we already have ALTER SYSTEM, so why do we need to write it again? > You just need to check whether the system is running: if it is, connect > and do "ALTER SYSTEM". If it isn't, do `echo ALTER SYSTEM | postgres > --single`. Maybe we can embed smarts to do that in, say, pg_ctl; then > everybody has access to it. Unfortunately, to quote the emitted log message, "standby mode is not supported by single-user servers", which as-is renders this approach useless for setting up replication configuration on a standby server (unless I'm missing something). I've looked in to what might be involved into creating a client-side function for modifying .auto.conf while the system is not running, and basically it seems to involve maintaining a stripped down version of ParseConfigFp() which doesn't recurse (because we don't allow "include" directives in .auto.conf, right? Right? I'll send in a different patch for that later...) and somehow exposing write_auto_conf_file(). And for all those scripts which can't call the putative frontend C function, we could provide a utility called "pg_alter_system" or similar which accepts a name and a value and (provided the system is not running) "safely" writes it to .auto.conf (though of course it won't be able to validate the provided parameter(s)). Alternatively (waves hand vaguely in air) there might be some way of creating a single user startup mode for the express purpose of leveraging the backend code to modify .auto.conf. Bur that seems like a lot of effort and complexity to replace what, in Pg11 and earlier, was just a case of writing to recovery.conf. Which brings me to another thought which AFAIK hasn't been discussed - what use-cases are there for modifying .auto.conf when the system isn't running? The only one I can think of is the case at hand, i.e. configuring replication after cloning a standby in a manner which *guarantees* that the replication configuration will be read at startup, which was the case with recovery.conf in Pg11 and earlier. For anything else, it seems reasonable to me to expect any customised settings to be written (e.g. by a provisioning system) to the normal configuration file(s). Having pg_basebackup write the replication configuration to a normal file is icky because there's no guarantee the configuration will be written last, or even included at all, which is a regression against earlier versions as there you could clone a standby and (assuming there are no issues with any cloned configuration files) have the standby start up reliably. Regards Ian Barwick -- Ian Barwick https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services