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 1iAuib-0001kq-3R for pgsql-admin@arkaria.postgresql.org; Thu, 19 Sep 2019 11:35:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iAuiZ-0000Ul-B2 for pgsql-admin@arkaria.postgresql.org; Thu, 19 Sep 2019 11:35:23 +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 1iAuiY-0000UX-QI for pgsql-admin@lists.postgresql.org; Thu, 19 Sep 2019 11:35:23 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iAuiV-0008Pe-Ay for pgsql-admin@lists.postgresql.org; Thu, 19 Sep 2019 11:35:22 +0000 Received: by mail-wr1-x441.google.com with SMTP id n14so2698817wrw.9 for ; Thu, 19 Sep 2019 04:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zunibal-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=ETRvQfZKaA1Sy/FZ6Uvl2Ys7CJ8CFkbYom2AP+f7hmg=; b=WdSVi3gylRBCFA9w/PEdnsy8XRfRDsf+/gQpGfXyt+poGmZL3XA2qvoEJLyL7+64PE coOhbsB5LKUNdFQkJE10RcfLlOTgkI9phN+tmSLzjFeHLoxllqRRzPiYfyCEU0Krd1Zg sqY6mj5aIsM+pRmDTiXj39c2Utve/9p5acYEfKaG6sDqxBPCF/ClIlY3P/oyURlFmlI0 /EpVyDFymX+pY9lsPYniSjinXZAimiaxBSRm1hToek8X4JzfpMrxcwGXGauQydzqpuSi i1lPzCx3J1hIn6+y/lQVEeMAL4XUGEIzo6gWag27nYBlVOZ+dMjT/fbNJ/z8a7/aI+OG IKrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=ETRvQfZKaA1Sy/FZ6Uvl2Ys7CJ8CFkbYom2AP+f7hmg=; b=nc+Z6RHtm1L8ulW4lECRPQldreaD3WUr+rGsMo4uvgHRh7tXdBuDiWFwtTyrj05+9r GpSCTzahRaUKp07nCyg6dFVxplRXLGc1atf+xtkX5cw2XoBTRmSx0O3e5HiXua9z/XRq DoVKy14HuejO9NZ0H6fRDC6j7OJFe4zoPA/7YYiH4ON5gu12JLrSKF2b010sCDawyxoK Q7WsuYvZqo0yzWqI8i27hTPxCqgt5fWJkwoy5GX7Yus4PqmQdboWJU3eGfqZaeyj/h7/ m7SCTmpKLZI0JGULnBHFS+DaGsC9HshfdcOGKveFkOHZShfytxUxOqGnGqHVZMcr0OdI 9EpQ== X-Gm-Message-State: APjAAAXIldM4T8ZOZuQ0SNFxX6r8spyBGLGAIA/jbcKUJbPspDYC7UY0 admm5SCoG9t3+l7vtK61rRgXU1eA340= X-Google-Smtp-Source: APXvYqx7hMhj68awdrgHIu7kdPnKuNO7SGjr29weJSjj0b3OglTHPJW8rjRD7Ix6Rt/y7m+JLz7Uow== X-Received: by 2002:adf:e548:: with SMTP id z8mr6779008wrm.324.1568892913097; Thu, 19 Sep 2019 04:35:13 -0700 (PDT) Received: from [192.168.3.150] ([176.222.91.85]) by smtp.gmail.com with ESMTPSA id 33sm12920968wra.41.2019.09.19.04.35.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Sep 2019 04:35:12 -0700 (PDT) Subject: Re: Pg_upgrade error could not load library from 7.14/8.4 to 10.10 version To: pgsql-admin@lists.postgresql.org References: <4519fdad-d747-cd39-f6a2-33e7db1f3324@matrix.gatewaynet.com> From: Ekaterina Amez Message-ID: Date: Thu, 19 Sep 2019 13:35:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <4519fdad-d747-cd39-f6a2-33e7db1f3324@matrix.gatewaynet.com> Content-Type: multipart/alternative; boundary="------------DFFB1BB9CB544654A1FF4D59" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------DFFB1BB9CB544654A1FF4D59 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit El 19/9/19 a las 10:07, Achilleas Mantzios escribió: > On 19/9/19 10:49 π.μ., Ekaterina Amez wrote: >> >> Hi all, >> >> I've been looking in the archives and googled this problem but not >> found really a solution nor an explanation so finally posting here. >> >> We are finally removing our old postgres 7.14 server and moving to a >> "new" one (better machine) with postgres 8.4 running on it. I've been >> making some tests in my local machine to assure database can be >> restored from one version to the other without problems, and been >> documenting all the process. Now that I have it quite clear, and I >> know the points than can cause problems during restoration process, >> I'm trying to use pg_upgrade to upgrade "new" server to a Postgres >> version that still has support; this is, to upgrade from 8.4 to >> 10.10. But I'm getting an error with plpgsql.so library that I'm not >> sure how to resolve. These are the steps that I made: >> >> postgres@mymachine:/tmp$ cat pg_upgrade_server.log >> >> 2019-09-19 08:53:50.345 CEST [2283] postgres@template1 ERROR: could not load library "/usr/lib/postgresql/8.4/lib/plpgsql.so": /usr/lib/postgresql/8.4/lib/plpgsql.so: undefined symbol: SPI_push >> 2019-09-19 08:53:50.345 CEST [2283] postgres@template1 STATEMENT: LOAD '/usr/lib/postgresql/8.4/lib/plpgsql.so' >> command: "/usr/lib/postgresql/10/bin/pg_ctl" -w -D "/var/lib/postgresql/10/main" -o "-c config_file=/etc/postgresql/10/main/postgresql.conf" -m fast stop >> "pg_upgrade_server.log" 2>&1 >> 2019-09-19 08:53:50.354 CEST [2272] LOG: received fast shutdown request >> waiting for server to shut down....2019-09-19 08:53:50.358 CEST [2272] LOG: aborting any active transactions >> 2019-09-19 08:53:50.363 CEST [2272] LOG: worker process: logical replication launcher (PID 2278) exited with exit code 1 >> 2019-09-19 08:53:50.364 CEST [2274] LOG: shutting down >> 2019-09-19 08:53:50.377 CEST [2272] LOG: database system is shut down >> done >> server stopped >> >> >> postgres@mymachine:/tmp$ cat loadable_libraries.txt >> could not load library "/usr/lib/postgresql/8.4/lib/plpgsql.so": ERROR: could not load library "/usr/lib/postgresql/8.4/lib/plpgsql.so": /usr/lib/postgresql/8.4/lib/plpgsql.so: undefined symbol: SPI_push > > Can you load plpgsql in your 8.4 cluster? Can you run plpgsql in the > same system? I'd say ensure this first. If you can't, then drop it and > try to upgrade. Then in your 10.10 you re-create plpgsql as an extension. I'm not sure about what do you mean when you say to load plpgsql in my cluster. But after your mail, and after discussing it with nearby people I've used a simple function that is included in one of our databases to check the language exists or not in each server. This is the function (is really silly function, nothing but a now() formatted): CREATE OR REPLACE FUNCTION fn_now() RETURNS CHAR(14) AS ' DECLARE     _resultado CHAR(14); BEGIN     SELECT to_char(NOW(), ''YYYYMMDDHH24MISS'') INTO _resultado;     RETURN _resultado; END; ' LANGUAGE plpgsql; I've created it in PG 10.10 and called from a select: no problem. I've created an empty database in PG 8.4 and created this function in this new database. It gives me an error that says (more or less as I get the error in another language different than english) : "ERROR:  «plpgsql» does not exist. SUGGESTION: Use CREATE LANGUAGE to install language in database.". With these results, finally I've:     1- modified template1 in PG 8.4 server to include plpgsql language, so it can be inherited in new databases created from this template.     2- Dropped and recreated my database (let's call it newdb).     3- Modified backup file to remove the part that creates the function plpgsql_call_handler().     4- Restored modified backup. *ekaterina@mymachine*:*~/temp*$ /usr/lib/postgresql/8.4/bin/psql -U postgres psql (8.4.22) postgres=# \c template1 template1=# CREATE LANGUAGE plpgsql; CREATE LANGUAGE template1=# create database newdb with owner=root template=template1; CREATE DATABASE newdb=# \q *ekaterina@mymachine*:*~/temp*$ /usr/lib/postgresql/8.4/bin/psql -U root -d newdb < backup_from_7_14.sql > errors.log Backup is restored without errors, and functions are created correctly. I can call them without errors. And testing pg_upgrade with --check modifier now returns OK. The conclusion is that I can avoid the use of plpgsql.so library. My question now would be related about the creation of the language in version 8.4: is it better to create it at template level or at database level? Of course creating it at template level leads to language being included in new databases without effort. And as it's plpgsql language, which is the only way we use at my place for programming database, it lets me foget about installing it in new databases. Also, since 9.0 version plpgsql language is installed by default in every database and all of this becomes unnecesary. But I'd like to know if I'm missing anything important. Thanks Achilleas for your tips. > -- > Achilleas Mantzios > IT DEV Lead > IT DEPT > Dynacom Tankers Mgmt --------------DFFB1BB9CB544654A1FF4D59 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit


El 19/9/19 a las 10:07, Achilleas Mantzios escribió:
On 19/9/19 10:49 π.μ., Ekaterina Amez wrote:

Hi all,

I've been looking in the archives and googled this problem but not found really a solution nor an explanation so finally posting here.

We are finally removing our old postgres 7.14 server and moving to a "new" one (better machine) with postgres 8.4 running on it. I've been making some tests in my local machine to assure database can be restored from one version to the other without problems, and been documenting all the process. Now that I have it quite clear, and I know the points than can cause problems during restoration process, I'm trying to use pg_upgrade to upgrade "new" server to a Postgres version that still has support; this is, to upgrade from 8.4 to 10.10. But I'm getting an error with plpgsql.so library that I'm not sure how to resolve. These are the steps that I made:

postgres@mymachine:/tmp$ cat pg_upgrade_server.log

2019-09-19 08:53:50.345 CEST [2283] postgres@template1 ERROR:  could not load library "/usr/lib/postgresql/8.4/lib/plpgsql.so": /usr/lib/postgresql/8.4/lib/plpgsql.so: undefined symbol: SPI_push
2019-09-19 08:53:50.345 CEST [2283] postgres@template1 STATEMENT:  LOAD '/usr/lib/postgresql/8.4/lib/plpgsql.so'
command: "/usr/lib/postgresql/10/bin/pg_ctl" -w -D "/var/lib/postgresql/10/main" -o "-c config_file=/etc/postgresql/10/main/postgresql.conf" -m fast stop >> "pg_upgrade_server.log" 2>&1
2019-09-19 08:53:50.354 CEST [2272] LOG:  received fast shutdown request
waiting for server to shut down....2019-09-19 08:53:50.358 CEST [2272] LOG:  aborting any active transactions
2019-09-19 08:53:50.363 CEST [2272] LOG:  worker process: logical replication launcher (PID 2278) exited with exit code 1
2019-09-19 08:53:50.364 CEST [2274] LOG:  shutting down
2019-09-19 08:53:50.377 CEST [2272] LOG:  database system is shut down
 done
server stopped


postgres@mymachine:/tmp$ cat loadable_libraries.txt
could not load library "/usr/lib/postgresql/8.4/lib/plpgsql.so": ERROR:  could not load library "/usr/lib/postgresql/8.4/lib/plpgsql.so": /usr/lib/postgresql/8.4/lib/plpgsql.so: undefined symbol: SPI_push

Can you load plpgsql in your 8.4 cluster? Can you run plpgsql in the same system? I'd say ensure this first. If you can't, then drop it and try to upgrade. Then in your 10.10 you re-create plpgsql as an extension.


I'm not sure about what do you mean when you say to load plpgsql in my cluster. But after your mail, and after discussing it with nearby people I've used a simple function that is included in one of our databases to check the language exists or not in each server. This is the function (is really silly function, nothing but a now() formatted):

CREATE OR REPLACE FUNCTION fn_now()
RETURNS CHAR(14) AS '
DECLARE
    _resultado CHAR(14);
BEGIN
    SELECT to_char(NOW(), ''YYYYMMDDHH24MISS'') INTO _resultado;
    RETURN _resultado;
END;
' LANGUAGE plpgsql;

I've created it in PG 10.10 and called from a select: no problem.

I've created an empty database in PG 8.4 and created this function in this new database. It gives me an error that says (more or less as I get the error in another language different than english) : "ERROR:  «plpgsql» does not exist. SUGGESTION:  Use CREATE LANGUAGE to install language in database.".

With these results, finally I've:

    1- modified template1 in PG 8.4 server to include plpgsql language, so it can be inherited in new databases created from this template.

    2- Dropped and recreated my database (let's call it newdb).

    3- Modified backup file to remove the part that creates the function plpgsql_call_handler().

    4- Restored modified backup.

ekaterina@mymachine:~/temp$ /usr/lib/postgresql/8.4/bin/psql -U postgres
psql (8.4.22)

postgres=# \c template1

template1=# CREATE LANGUAGE plpgsql;
CREATE LANGUAGE
template1=# create database newdb with owner=root template=template1;
CREATE DATABASE
newdb=# \q
ekaterina@mymachine:~/temp$ /usr/lib/postgresql/8.4/bin/psql -U root -d newdb < backup_from_7_14.sql > errors.log

Backup is restored without errors, and functions are created correctly. I can call them without errors. And testing pg_upgrade with --check modifier now returns OK.

The conclusion is that I can avoid the use of plpgsql.so library. My question now would be related about the creation of the language in version 8.4: is it better to create it at template level or at database level? Of course creating it at template level leads to language being included in new databases without effort. And as it's plpgsql language, which is the only way we use at my place for programming database, it lets me foget about installing it in new databases. Also, since 9.0 version plpgsql language is installed by default in every database and all of this becomes unnecesary. But I'd like to know if I'm missing anything important.


Thanks Achilleas for your tips.



--
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt
--------------DFFB1BB9CB544654A1FF4D59--