Bug 993532 - Upgrade from 9.1 to 9.2 (F17 to F19 directly) fails with "wrong number of index expressions"
Summary: Upgrade from 9.1 to 9.2 (F17 to F19 directly) fails with "wrong number of ind...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: postgresql
Version: 19
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Pavel Raiskup
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-08-06 06:49 UTC by Robin Powell
Modified: 2013-08-18 00:38 UTC (History)
7 users (show)

Fixed In Version: postgresql-9.2.4-7.fc19
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-08-18 00:38:20 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Robin Powell 2013-08-06 06:49:12 UTC
After a double upgrade with yum (from F17 to F19 in two steps):

rlpowell@morji> /usr/lib64/pgsql/postgresql-9.1/bin/postgres
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
rlpowell@morji>
rlpowell@morji> sudo /bin/postgresql-setup upgrade
Redirecting to /bin/systemctl stop  postgresql.service
Upgrading database: failed

See /var/lib/pgsql/pgupgrade.log for details.
rlpowell@morji> sudo cat /var/lib/pgsql/pgupgrade.log
Performing Consistency Checks
-----------------------------
Checking current, bin, and data directories                 ok
Checking cluster versions                                   ok
SQL command failed
SELECT c.relname, c.relfilenode FROM    pg_catalog.pg_class c,          pg_catalog.pg_namespace n WHERE c.relnamespace = n.oid AND              n.nspname = 'pg_catalog' AND           c.relname = 'pg_database' ORDER BY c.relname
ERROR:  wrong number of index expressions

Failure, exiting

- -----------

I would be happy to fix this by dumping and reloading the database, but since the database won't start because it's an old version, I have no idea how to do that.

Not at all certain this is a Fedora issue, but not sure where else to turn.

-Robin

Comment 1 Pavel Raiskup 2013-08-06 07:31:54 UTC
> After a double upgrade with yum (from F17 to F19 in two steps):

Hi, thanks for your report.  Could you please describe more deeply the "two
steps" you've done?  Just to look where the problem happened?

> I would be happy to fix this by dumping and reloading the database, but since
> the database won't start because it's an old version, I have no idea how to
> do that.

This is just advice on your own response.  Always make backups please.

I'm not really 100% sure I'm able to give you the easiest way how to do the
dump, but basically you need to run the data directory against correct server
(if you haven't been successful with f17~>f18 pg_upgrade).

So (e.g.) I would install F17 with postgresql and copy the /var/lib/postgresql
directory to that machine (then run postgre & dump data).

You can also compile postgresql on your box.  This should work (if you are
aware of packaging a little bit):

    $ fedpkg clone -a postgresql && cd postgresql
    $ fedpkg switch-branch f17
    $ sudo yum-builddep *.spec
    $ fedpkg local
    $ # and install compiled rpms & start server && dump

Pavel

Comment 2 Pavel Raiskup 2013-08-06 07:33:49 UTC
> This is just advice on your own response.

Please replace with:  This is just advice, do it on your own risk (you should
know what you are doing).

Comment 3 Robin Powell 2013-08-06 07:44:47 UTC
(written before your comments):

Discussion in #postgres leads us to believe that the issue is:

http://www.postgresql.org/message-id/14242.1365200084@sss.pgh.pa.us

I ran postmaster like so:

sudo -u postgres /usr/lib64/pgsql/postgresql-9.1/bin/postmaster -D /var/lib/pgsql/data 

and:

jbovlaste=# select version();
                                                   version
-------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.1.9 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 4.8.0 20130322 (Red Hat 4.8.0-1), 64-bit
(1 row)

So it *was* compiled with 4.8.0

What it looks like is happening is that 9.2 is fine with gcc 4.8.0, so things mostly work, but the 9.1 stuff that was shipped along with the 9.2 package for upgrade purposes is *also* compiled with 4.8.0, and that causes explosions.

I'm going to save a copy of my /var/lib/pgsql so we can debug this further, but in the meantime I'm going to copy it over to a machine with working 9.1 (i.e. another F17 box) to try to fix this issue.

Comment 4 Robin Powell 2013-08-06 07:47:59 UTC
(1)  I have backups daily, I just don't want to revert if I can help it.

(2)  The two steps: https://fedoraproject.org/wiki/Upgrading_Fedora_using_yum#Fedora_17_-.3E_Fedora_18 and https://fedoraproject.org/wiki/Upgrading_Fedora_using_yum#Fedora_18_-.3E_Fedora_19 , followed pretty much to the letter.

(3)  It seems like there is an *actual problem* here: the 9.1 stuff shipped with F19's 9.2 postgres (for upgrade purposes) was compiled with the wrong gcc

(4)  Yeah, copy to F17 and do the thing; got it.

Comment 5 Pavel Raiskup 2013-08-06 08:01:12 UTC
Thanks for the info.  There should have been done the 'postgresql-setup
upgrade' once you finished the upgrade to F18.  The postgresql-upgrade is (in
general) prepared for upgrade just from previous version of Fedora.  The truth
is that the F18 ~> F19 postgresql-upgrade is not needed (thus it could be
prepared for upgrade from F17 rather which was not tested imo).

It could be worth to fix.  If you provide more info later on, it will be
appreciated.

Comment 6 Robin Powell 2013-08-06 08:05:51 UTC
All you need to do to fix it is to compile the 9.1 bits with gcc 4.7.x

I fixed my own issues by copying around my pgsql data dir and dumping it on an F17 host where postgres was compiled with gcc 4.7.2:

 PostgreSQL 9.1.9 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 4.7.2 20120921 (Red Hat 4.7.2-2), 64-bit

I suppose I should have upgraded after I got to F18, but there was like 2 minutes where I was on F18, and then I did the F19 upgrade; it would have been nice if the package itself had done the upgrade.

Comment 7 Pavel Raiskup 2013-08-06 08:28:28 UTC
(In reply to Robin Powell from comment #6)
> All you need to do to fix it is to compile the 9.1 bits with gcc 4.7.x

AFAIK, this is not (easily) doable in koji build system, when I consider
that ...

> I fixed my own issues by copying around my pgsql data dir and dumping it on
> an F17 host where postgres was compiled with gcc 4.7.2:
> 
>  PostgreSQL 9.1.9 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 4.7.2
> 20120921 (Red Hat 4.7.2-2), 64-bit

... this is a really the reason it failed.  If there was possible to use
some patch, it would be better.

> I suppose I should have upgraded after I got to F18, but there was like 2
> minutes where I was on F18, and then I did the F19 upgrade; it would have
> been nice if the package itself had done the upgrade.

No, it is not possible.  The user interaction here is important as this is too
complicated to be scripted (I can guess that somebody will say it is possible
but I don't want to be responsible for that magic).

I will left this open until I check if the GCC version is really the problem
here (it is weird but if that was told to you on #postgresql ..).  Possibly,
some warning that the pg_upgrade is run against F17 data would be useful, or
better documentation change, or .. something like that.

For me: when the postgresql-upgrade is redundant for upgrade between two
consecutive versions of fedora, we should either make the postgresql-upgrade
package empty package or make it usable for older fedora version upgrade.

Comment 8 Tom Lane 2013-08-06 12:08:51 UTC
What you really need to do here is force the 9.1 code to be built with -fno-aggressive-loop-optimizations in F19 and later.  I haven't quite persuaded upstream to go with that solution (as opposed to something more invasive), but it's clearly the best answer for a packager-initiated fix.

I don't agree with the idea that the postgresql-upgrade package is only meant to handle migration from the immediately preceding Fedora version.  People skip Fedora releases all the time, so the complainant's scenario is perfectly valid and needs to be supported.

Comment 9 Pavel Raiskup 2013-08-12 11:37:28 UTC
(In reply to Tom Lane from comment #8)
> What you really need to do here is force the 9.1 code to be built with
> -fno-aggressive-loop-optimizations in F19 and later.  I haven't quite
> persuaded upstream to go with that solution (as opposed to something more
> invasive), but it's clearly the best answer for a packager-initiated fix.

Thanks, that fix really helps.  I'll try to issue update together with fix for
bug #896161.  The change is committed in dist-git.

> I don't agree with the idea that the postgresql-upgrade package is only
> meant to handle migration from the immediately preceding Fedora version. 
> People skip Fedora releases all the time, so the complainant's scenario is
> perfectly valid and needs to be supported.

I see now.  As the major release cycle of postgresql should be slower than
Fedora's, skipping one Fedora release (more is not needed anyway) should be OK
without adding another upgrade-like subpackage.

Comment 10 Nils Philippsen 2013-08-14 22:22:22 UTC
Pavel, do you plan to submit an update for this? Because it fixes the described issue with using postgresql-upgrade for me.

Comment 11 Pavel Raiskup 2013-08-14 22:32:54 UTC
(In reply to Nils Philippsen from comment #10)
> Pavel, do you plan to submit an update for this? Because it fixes the
> described issue with using postgresql-upgrade for me.

I'll submit update tomorrow.  Also with fix for #896161.

Comment 12 Fedora Update System 2013-08-15 06:37:38 UTC
postgresql-9.2.4-7.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/postgresql-9.2.4-7.fc19

Comment 13 Fedora Update System 2013-08-15 23:30:34 UTC
Package postgresql-9.2.4-7.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing postgresql-9.2.4-7.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-14841/postgresql-9.2.4-7.fc19
then log in and leave karma (feedback).

Comment 14 Fedora Update System 2013-08-18 00:38:20 UTC
postgresql-9.2.4-7.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.