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 1o1Ffb-0000Xs-B0 for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Jun 2022 23:09:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o1Ffa-0000u3-4P for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Jun 2022 23:09:58 +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 1o1FfZ-0000tt-Mx for pgsql-hackers@lists.postgresql.org; Tue, 14 Jun 2022 23:09:57 +0000 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o1FfV-0002FW-Ez for pgsql-hackers@lists.postgresql.org; Tue, 14 Jun 2022 23:09:57 +0000 Received: by mail-io1-xd2c.google.com with SMTP id p128so11020467iof.1 for ; Tue, 14 Jun 2022 16:09:53 -0700 (PDT) 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=u8TEKZosedzcNoqD3cPson6sQ2Sw1U5bQJ0d649XgYg=; b=mGqN3+L7dh5JqxaorI9IRsAR/lnds829+ZLqvzKiRA5cyTYMM6zXg23xC/PcneKw2X zv8qVzlJYOjmgehDNU9i8JCSRKV63UYccEbFTl0VDsb7e59aXMTH1m7T5c1WWt2CSjbZ 2bU9SGVrVxquXS7afjS9Fuei0+/mcW2JXpHNw/lXXlK9SgEjKQv7/hTeRBATbveCGyr0 op8wTTv+IaCyqdcTiUlBj/flcwlucD01PJR61gvtcbKkKKMk+CaCh4+0S4FfzKsab3Yn ntPr/3tTthHloXcdQ/1PFeb1JYpodmTTL37ub2wNwNjx6WwtZm/F/mrom8faENqP3CNG D1SA== 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=u8TEKZosedzcNoqD3cPson6sQ2Sw1U5bQJ0d649XgYg=; b=QGkotbWBauXtqGEukF5n1BUGQHOcXQSHGGKG8DYTX31cW7xLn6LGJLfZbW4Ch1pf9Q hjgM9Fen5OSmSfCe6zC/86emQ+9Oj0xXeE/ACnR16oXLbISpqXpk3riPwXICGteJ6k4R VlTEzrpcoECuKuCQDil1JJ8jZws4+Mhro5hmns2v0QjRndfIeA7ZL9UJb3Y55beG9+gY zk3DdG7/aAvFM/UbwHdv0kMuYnuGmbuOgFv0xECSHmBOB5R4QsBeE9Eg2ov/C+Z6q1VZ kFBSXjshHg+ih6LIRPWXS+aT7+j142t/66tmsATIx185qWdYYCqcVo5zjkAs+5Hk6TG/ H69Q== X-Gm-Message-State: AOAM5309mEBdmXimAeOVNZhU9sZ7/pG+9eV5pT1QhDvSUF+yy7JHSr29 putmKjqs95aGW0yi20U+N2D/8rH1AswSWw== X-Google-Smtp-Source: ABdhPJwj19LqQ2Vpbv+wm5a1vU8HJeZUoIaeQoDeNMiFIzh2bf3e6TAVYHR/RlNepLN3UZs9JrOpww== X-Received: by 2002:a05:6638:158:b0:332:20b5:5955 with SMTP id y24-20020a056638015800b0033220b55955mr4125111jao.27.1655248191294; Tue, 14 Jun 2022 16:09:51 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id z20-20020a056638001400b003316f4b9b26sm5431155jao.131.2022.06.14.16.09.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jun 2022 16:09:50 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 873738008F8; Tue, 14 Jun 2022 18:09:49 -0500 (CDT) Date: Tue, 14 Jun 2022 18:09:49 -0500 From: Justin Pryzby To: "David G. Johnston" Cc: Petr Vejsada , pgsql-hackers@lists.postgresql.org Subject: Re: pg_upgrade (12->14) fails on aggregate Message-ID: <20220614230949.GX29853@telsasoft.com> References: <3383880.QJadu78ljV@vejsadalnx> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="98e8jtXdkpgskNou" Content-Disposition: inline In-Reply-To: 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 --98e8jtXdkpgskNou Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, May 04, 2022 at 07:34:15AM -0700, David G. Johnston wrote: > On Wed, May 4, 2022 at 7:29 AM Petr Vejsada wrote: > > We solved it (in our case) dropping the aggregate before upgrade and > > re-create in using new syntax in V14: > > > > but pg_upgrade shouldn't fail on this. > > > > I hope it can help to improve pg_upgrade process. > > The release notes say explicitly that one needs to drop and recreate the > affected functions. Thus, we know about the issue and to date our best > solution is to have the user do exactly what you did (i.e., it is not > something pg_upgrade is going to do for you). If you have an alternative > solution to suggest that would help. > > https://www.postgresql.org/docs/current/release-14.html : the first > compatibility note David is right that this is documented as a compatibility issue. But Petr has a point - pg_upgrade should aspire to catch errors in --check, rather than starting and then leaving a mess behind for the user to clean up (remove existing dir, rerun initdb, start old cluster, having first moved the dir back into place if you moved it out of the way as I do). This can take extra minutes, and exacerbates any other problem one encounters. $ ./tmp_install/usr/local/pgsql/bin/pg_upgrade -d pg95.dat -D pg15.dat -b /usr/lib/postgresql/9.5/bin ... Restoring global objects in the new cluster ok Restoring database schemas in the new cluster postgres *failure* Consult the last few lines of "pg15.dat/pg_upgrade_output.d/20220610T104419.303/log/pg_upgrade_dump_12455.log" for the probable cause of the failure. pg_restore: error: could not execute query: ERROR: function array_append(anyarray, anyelement) does not exist Command was: CREATE AGGREGATE "public"."array_accum"("anyelement") ( SFUNC = "array_append", STYPE = "anyarray", INITCOND = '{}' ); This patch catches the issue; the query needs to be reviewed. SELECT pn.nspname, p.proname FROM pg_proc p JOIN pg_aggregate a ON a.aggfnoid=p.oid JOIN pg_proc q ON q.oid=a.aggtransfn JOIN pg_namespace pn ON pn.oid=p.pronamespace JOIN pg_namespace qn ON qn.oid=q.pronamespace WHERE pn.nspname != 'pg_catalog' AND qn.nspname = 'pg_catalog' AND 'anyelement'::regtype = ANY(q.proargtypes) AND q.proname IN ('array_append', 'array_prepend', 'array_cat', 'array_position', 'array_positions', 'array_remove', 'array_replace', 'width_bucket'); --98e8jtXdkpgskNou Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-WIP-pg_upgrade-check-detect-aggregates-for-pre-pg14.patch"