Thread: Re: [GENERAL] Forgot to dump old data before re-installing machine

Re: [GENERAL] Forgot to dump old data before re-installing machine

From
Peter Eisentraut
Date:
Tom Lane wrote:
> What would work better is to add some code that checks whether
> pg_control_version looks like the byte-swap of a small number,
> and prints a suitably modified error message if so.

Here is a possible patch.  Example output:

$ pg-install/bin/postgres -D pg-install/var/data
FATAL:  database files are incompatible with server
DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 1090715648 (0x41030000), but the server was
compiledwith PG_CONTROL_VERSION 833 (0x00000341). 
HINT:  This could be a mismatched byte order.  It looks like you need to initdb.

I didn't follow how the user got into this mess, so I don't know whether the
suggestion "you need to initdb" is appropriate.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Attachment

Re: [GENERAL] Forgot to dump old data before re-installing machine

From
"Dave Page"
Date:
On 18/01/2008, Peter Eisentraut <peter_e@gmx.net> wrote:
> Tom Lane wrote:
> > What would work better is to add some code that checks whether
> > pg_control_version looks like the byte-swap of a small number,
> > and prints a suitably modified error message if so.
>
> Here is a possible patch.  Example output:
>
> $ pg-install/bin/postgres -D pg-install/var/data
> FATAL:  database files are incompatible with server
> DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 1090715648 (0x41030000), but the server was
compiledwith PG_CONTROL_VERSION 833 (0x00000341). 
> HINT:  This could be a mismatched byte order.  It looks like you need to initdb.
>
> I didn't follow how the user got into this mess, so I don't know whether the
> suggestion "you need to initdb" is appropriate.

I would think not, as you almost certainly must be doing a file level
restore of the data directory to get into this state and therefore
probably want to keep your data.

/D

Re: [GENERAL] Forgot to dump old data before re-installing machine

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> Here is a possible patch.  Example output:

> $ pg-install/bin/postgres -D pg-install/var/data
> FATAL:  database files are incompatible with server
> DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 1090715648 (0x41030000), but the server was
compiledwith PG_CONTROL_VERSION 833 (0x00000341). 
> HINT:  This could be a mismatched byte order.  It looks like you need to initdb.

> I didn't follow how the user got into this mess, so I don't know whether the
> suggestion "you need to initdb" is appropriate.

I think it still is, at least as much as it is in other situations where
we say that.  I didn't like the wording of the other part of the hint
though.  Maybe "This could be a problem of mismatched byte ordering"?

Other than that quibble, +1.

            regards, tom lane

Re: [GENERAL] Forgot to dump old data before re-installing machine

From
Tom Lane
Date:
"Dave Page" <dpage@postgresql.org> writes:
> On 18/01/2008, Peter Eisentraut <peter_e@gmx.net> wrote:
>> I didn't follow how the user got into this mess, so I don't know whether the
>> suggestion "you need to initdb" is appropriate.

> I would think not, as you almost certainly must be doing a file level
> restore of the data directory to get into this state and therefore
> probably want to keep your data.

You could argue that that's true if there's an incompatible pg_control
file there at all; I'm not sure why wrong-endianness is different from
wrong-version or wrong-datetime-option or anything else.

IIRC the HINT to initdb was originally kind of pointed at developers
who'd just downloaded a new CVS update with a new catversion number.
It might not be so appropriate for the field.  The worst case scenario
would be someone blindly following the hint and blowing away their old
data ...

            regards, tom lane