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 1mxbZV-0004My-Ua for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Dec 2021 21:12:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mxbZU-0004rm-Qt for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Dec 2021 21:12:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxbZU-0004rc-DR for pgsql-hackers@lists.postgresql.org; Wed, 15 Dec 2021 21:12:20 +0000 Received: from mail-io1-xd33.google.com ([2607:f8b0:4864:20::d33]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mxbZP-0002wo-U9 for pgsql-hackers@lists.postgresql.org; Wed, 15 Dec 2021 21:12:17 +0000 Received: by mail-io1-xd33.google.com with SMTP id k21so32191575ioh.4 for ; Wed, 15 Dec 2021 13:12:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PFEdF2mRZrKqPMyus/eqMFSwrP6a+JZiHauMkEIdLIs=; b=entGcgvExpoH8Mk13YJWARFNM6lBFJPRZSLMvqdwWWQFrRZ61gMQHnrTm3P0GaeOHG Ni/lraofi6mid4egG8p2KT97tjr18kINdnyLNNeCRrABepqgm+CrzSuUKCKFJV1ov+2G J9QdEy2D37o/7VbCahEfH1DWRM97fyO36rJYpo2bILcQCwRTPtdtLCuXGohWZQbxPNek gCy0ZjKrn6PJdOZRuqfFvE5oTOc9LhbqghVhF1+fURZFKWIAz5VdMlAiiYwBv8KfNeXQ 2R5lCJu86gJ5zEUsFtZCktcKG3owOGUSuxUar0FSsBf7lC+UROe4HOlMnO773jYx0BbJ qS0A== 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:user-agent; bh=PFEdF2mRZrKqPMyus/eqMFSwrP6a+JZiHauMkEIdLIs=; b=V4RtwWXcdZnAaCKbP+Q2PNX7RXdBmUewda+lC8+ruE8PPEmuW5R7F/ckMG7Xj+hWoj dDlVtK2hy+fbE5tgrvWrngE+NVubRQFkPwwtT4tlDDL96cltCcefe8/MMHgO+jmKHOHl HinXfOwriSmX3Q3CZJMq5siTmxGzUJxUHEH9mUU+LExmb0mx1qOoRkgVJnHZUAcVo/9C ycF+rFhm0w6Ma8vrbZkyxmh8jrgdZL1I11RnyNXqnEdQC0DnD68IjXhUgoEyEm9okVrw rd21kciRDpAmXNMKBf13e23eMn3JSCAf1nlpunNaTFje9M1BoFP4/BbL51W8bmdPj9uV 3Ssw== X-Gm-Message-State: AOAM5319gkLQcNxMc8fyH9/hQsi844YNqJTT9qD66LYwplbycxSoTe82 mVDgTseDZA8tjgCmGgHxKCSmpbS5AT4jsg== X-Google-Smtp-Source: ABdhPJwPfh4neT006dtoeYV8gch1jrvSp+SoOXMuGtk+o9HkbvB2Pgq3lI5sUMaLsiRJVgjbHWmG0g== X-Received: by 2002:a05:6638:40ac:: with SMTP id m44mr7474158jam.168.1639602733777; Wed, 15 Dec 2021 13:12:13 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id c19sm1591236ioa.30.2021.12.15.13.12.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Dec 2021 13:12:13 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id A26A68006D0; Wed, 15 Dec 2021 15:12:12 -0600 (CST) Date: Wed, 15 Dec 2021 15:12:12 -0600 From: Justin Pryzby To: Bruce Momjian Cc: pgsql-hackers@lists.postgresql.org Subject: Re: pg_upgrade should truncate/remove its logs before running Message-ID: <20211215211212.GT17618@telsasoft.com> References: <20211212025017.GN17618@telsasoft.com> <20211215210916.GC4440@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211215210916.GC4440@momjian.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Dec 15, 2021 at 04:09:16PM -0500, Bruce Momjian wrote: > On Sat, Dec 11, 2021 at 08:50:17PM -0600, Justin Pryzby wrote: > > I have seen this numerous times but had not dug into it, until now. > > > > If pg_upgrade fails and is re-run, it appends to its logfiles, which is > > confusing since, if it fails again, it then looks like the original error > > recurred and wasn't fixed. The "append" behavior dates back to 717f6d608. > > > > I think it should either truncate the logfiles, or error early if any of the > > files exist. Or it could put all its output files into a newly-created > > subdirectory. Or this message could be output to the per-db logfiles, and not > > just the static ones: > > | "pg_upgrade run on %s". > > > > For the per-db logfiels with OIDs in their name, changing open() from "append" > > mode to truncate mode doesn't work, since they're written to in parallel. > > They have to be removed/truncated in advance. > > > > This is one possible fix. You can test its effect by deliberately breaking one > > of the calls to exec_progs(), like this. > > > > - "\"%s/pg_restore\" %s %s --exit-on-error --verbose " > > + "\"%s/pg_restore\" %s %s --exit-on-error --verboose " > > Uh, the database server doesn't erase its logs on crash/failure, so why > should pg_upgrade do that? To avoid the presence of irrelevant errors from the previous invocation of pg_upgrade. Maybe you would prefer one of my other ideas , like "put all its output files into a newly-created subdirectory" ? -- Justin