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 1hdSeu-0004j3-Dy for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Jun 2019 04:57:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hdSet-0005Rn-7J for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Jun 2019 04:57:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdSes-0005RV-Uk for pgsql-hackers@lists.postgresql.org; Wed, 19 Jun 2019 04:57:18 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdSep-0008GT-T1 for pgsql-hackers@postgresql.org; Wed, 19 Jun 2019 04:57:18 +0000 Received: by mail-pf1-x434.google.com with SMTP id 19so8985219pfa.4 for ; Tue, 18 Jun 2019 21:57:15 -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=mlEYl9sMirh/z0LqXRuJLQlplYNd4EdoWvWmRWV2I2k=; b=nJS1UtgaQxdthD3zR9VDrF3++p2yUfgwYEKw6zpG3EBLkQGL2UEf0ekVLuOfeLnH+2 Xl7k4ddu0U3oT+wFEVyGWsREP6rzadlwppq6knnQz/1TzQcPNusnbBsYJDpJS8++89wT Qzphwi2vIn/7bcjVwjtYQvOIK/YkQuPX7Oi25N69k4WphoTsaZp6gW4/UNvYLnPeOE8U CAI2H8KLOXPQunE1LMZbfmL8+v3rY0dKWMTnF7z3kdMSg1ESEFJ6w2d8tP87DwWEcjTi K810Bp6dPD30UBnOdxCutcd0YQW+i6ZsrgmGnNBUG50io5fq6KpFvbeTERus8JSVWZfR 3CwA== 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=mlEYl9sMirh/z0LqXRuJLQlplYNd4EdoWvWmRWV2I2k=; b=BjC5flxDafv56Pvx/vhZl3wIEbLbiVw4f3msVUuYqBFlCwDEARlGIaqZbQTzmffXIb yLxIK/1hDBW1Pkfr7a4IDJGX7XFb/EhXvIPRSGDMWYS9DjlskuSSjmX4ZXRfDkaiE+HX Q2fMzIfX7PnRllVXjYQVrxzMxf9GyXlhe3EkqLEiF9wIzaPN6GZGfKjGNzIc9L1rjdxz LKAVPtFZmVs8l6Okr9PgQG11VfwUhdTDnts41XaCnQp72OU55ZpUHAmHMMYNxeT7jsAJ qhMYbxKBFGkphvA4Em7V/WuyVfGeDvZTEkwsUpy+egbjiyABwNBDeUhq4qD+YKnhPYhD T1mQ== X-Gm-Message-State: APjAAAV/1URCtdzboISpoTjyiNAboN64t+91j71xZYXRoOEZCrpJ8oHp bYqyigtnOZKM2qxwqj6aj09bKwrTXb4RfCGBDVWdwTQsE4Xi2Kh5c67dc/5D29XAeg2xlZHiWE4 QRqogQJZwMO6vE0dVrm/u//7b4eYZHuiPFFFrv6jWuHq+JcnpAlMKTNDxw+0sQag36eY6f2vcY/ qbmGZEJz9W9zrS X-Google-Smtp-Source: APXvYqwCm7GBReOM4+Q/JXaCzrFn0k+vfxQW4P1gCoUSIM4zGTr6hyCqq/yCwkJuWJUMCBc0tTGmKw== X-Received: by 2002:a17:90a:de02:: with SMTP id m2mr9151963pjv.18.1560920233007; Tue, 18 Jun 2019 21:57:13 -0700 (PDT) Received: from osaka.octopusnet (p14091-ipngn9701marunouchi.tokyo.ocn.ne.jp. [153.219.173.91]) by smtp.gmail.com with ESMTPSA id o13sm340627pje.28.2019.06.18.21.57.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Jun 2019 21:57:12 -0700 (PDT) Subject: Re: [PATCH] Stop ALTER SYSTEM from making bad assumptions To: Stephen Frost Cc: Amit Kapila , "pgsql-hackers@postgresql.org" References: <20190614160835.GF2480@tamriel.snowman.net> <20190616171610.GO2480@tamriel.snowman.net> <27dc9f8d-8d8f-9dd1-0494-5d8bd2f49a45@2ndquadrant.com> <20190617154133.GF2480@tamriel.snowman.net> From: Ian Barwick Message-ID: <2e9f82a8-27e8-60cf-7df3-616d6707eede@2ndquadrant.com> Date: Wed, 19 Jun 2019 13:57:08 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190617154133.GF2480@tamriel.snowman.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk n 6/18/19 12:41 AM, Stephen Frost wrote: > Greetings, > > * Ian Barwick (ian.barwick@2ndquadrant.com) wrote (...) >> I suggest explicitly documenting postgresql.auto.conf behaviour (and the circumstances >> where it's acceptable to modify it outside of ALTER SYSTEM calls) in the documentation >> (and possibly in the code), so anyone writing utilities which need to >> append to postgresql.auto.conf knows what the situation is. > > Yeah, I would think that, ideally, we'd have some code in the common > library that other utilities could leverage and which the backend would > also use. So maybe something along the lines of creating a stripped-down variant of AlterSystemSetConfigFile() (from "src/backend/utils/misc/guc.c") which can be called from front-end code to safely modify .auto.conf while the server is *not* running. I'm not terribly familiar with the GUC code, but that would presumably mean making parts of the GUC parsing/handling code linkable externally (ParseConfigFp() etc.) as you'd need to parse the file before rewriting it. Something like (minimal pseudo-code): void alter_system_set(char *name, char *value) { /* * check here that the server is *not* running */ ... ParseConfigFp(infile, AutoConfFileName, 0, LOG, &head, &tail) ... /* * some robust portable way of ensuring another process can't * modify the file(s) until we're done */ lock_file(AutoConfFileName); replace_auto_config_value(&head, &tail, name, value); write_auto_conf_file(AutoConfTmpFileName, head) durable_rename(AutoConfTmpFileName, AutoConfFileName, ERROR); FreeConfigVariables(head); unlock_file(AutoConfFileName); } I'm not sure how feasible it is to validate the provided parameter without the server running, but if not possible, that's not any worse than the status quo, i.e. the utility has to be trusted to write the correct parameters to the file anyway. The question is though - is this a change which is practical to make at this point in the release cycle for Pg12? Regards Ian Barwick -- Ian Barwick https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services