pg_database corrupted(?) If so, what do I do????

Started by Jonny Hinojosaalmost 27 years ago6 messagesgeneral
Jump to latest
#1Jonny Hinojosa
Jonny@TCA.net

Solaris 7 : snapshot dated 0506

The system has been running fine for several months. Yesterday it crashed
and I have not been able to get it back.

This is the message I get when I try to access the db from psql :

bash-2.02$ psql
Connection to database 'cdmwhere' failed.
FATAL 1: Database 'cdmwhere' does not exist.
We know this because the directory '/data/base/cdmw�H' does not
exist.
You can create a database with the SQL command CREATE DATABASE.
To see what databases exist, look at the subdirectories of
'/data/base/'
.

bash-2.02$

Why does it think the directory '/data/base/cdmw H' should exist? Shouldn't
that be '/data/base/cdmwhere'?

Any ideas on how I can recover?
Jonny

#2Jonny Hinojosa
Jonny@TCA.net
In reply to: Jonny Hinojosa (#1)
RE: [GENERAL] pg_database corrupted(?) If so, what do I do????

More info:

bash-2.02$ psql -l
datname |datdba|encoding|datpath
---------+------+--------+---------
template1| 1002| 0|template1
jonny | 1001| 0|jonny
hom | 1003| 0|H
cdmwhere | 1005| 0|cdmw�H
(4 rows)

bash-2.02$

The last 2 entries have been corrupted. How do I (can I) correct these
entries ??????

Jonny

-----Original Message-----
From: owner-pgsql-general@postgreSQL.org
[mailto:owner-pgsql-general@postgreSQL.org]On Behalf Of Jonny Hinojosa
Sent: Monday, May 10, 1999 9:48 AM
To: PostgreSQL General
Subject: [GENERAL] pg_database corrupted(?) If so, what do I do????

Solaris 7 : snapshot dated 0506

The system has been running fine for several months. Yesterday it crashed
and I have not been able to get it back.

This is the message I get when I try to access the db from psql :

bash-2.02$ psql
Connection to database 'cdmwhere' failed.
FATAL 1: Database 'cdmwhere' does not exist.
We know this because the directory '/data/base/cdmw�H' does not
exist.
You can create a database with the SQL command CREATE DATABASE.
To see what databases exist, look at the subdirectories of
'/data/base/'
.

bash-2.02$

Why does it think the directory '/data/base/cdmw H' should exist? Shouldn't
that be '/data/base/cdmwhere'?

Any ideas on how I can recover?
Jonny

#3Herouth Maoz
herouth@oumail.openu.ac.il
In reply to: Jonny Hinojosa (#2)
RE: [GENERAL] pg_database corrupted(?) If so, what do I do????

At 22:26 +0300 on 10/05/1999, Jonny Hinojosa wrote:

The last 2 entries have been corrupted. How do I (can I) correct these
entries ??????

Have you tried logging into psql (template1) as postgres and updating the
pg_database table?

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma

#4Jonny Hinojosa
Jonny@TCA.net
In reply to: Herouth Maoz (#3)
Re: [GENERAL] pg_database corrupted(?) If so, what do I do????

No, but I have tried to figure out how to do just that. I have found no way
to effect these updates. So which part of the docs did I sleep through???

All help is GREATLY appreciated.

Jonny

-----Original Message-----
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Jonny Hinojosa <Jonny@TCA.net>; PostgreSQL General
<pgsql-general@postgreSQL.org>
Date: Tuesday, May 11, 1999 4:30 AM
Subject: RE: [GENERAL] pg_database corrupted(?) If so, what do I do????

At 22:26 +0300 on 10/05/1999, Jonny Hinojosa wrote:

The last 2 entries have been corrupted. How do I (can I) correct these
entries ??????

Have you tried logging into psql (template1) as postgres and updating the
pg_database table?

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma

#5Herouth Maoz
herouth@oumail.openu.ac.il
In reply to: Jonny Hinojosa (#4)
Re: [GENERAL] pg_database corrupted(?) If so, what do I do????

At 18:03 +0300 on 11/05/1999, Jonny Hinojosa wrote:

No, but I have tried to figure out how to do just that. I have found no way
to effect these updates. So which part of the docs did I sleep through???

All help is GREATLY appreciated.

I can't test any advice I give on my own system, as it is used for
production. But let's see if we can do something.

If you tried to update the pg_database with UPDATE pg_database SET
datpath=datname WHERE datpath <> datname; and it didn't work, you may try
the following:

make a copy of the hom and cdmwhere directories in the data directory, for
backup.

Try to DROP DATABASE on the above databases. See if they have disappeared
from the database list (you can use select * from pg_database instead of
psql -l if you are already in psql). If they did, remove or rename the hom
and cdmwhere directories, and re-create them, using the user.

You are now supposed to have two new empty databases with the old names.
Remove the newly created directories and rename the old ones back. Check to
see if you can connect.

It may be advisable to shut down the postmaster when you are changing
things in the data directory, and restart it for the next psql session.

Now, supposed the DROP DATABASE didn't work, and complains that it doesn't
find the directories. Then, if it were me, I would create copies of the
original hom and cdmwhere directories, but give them the names that appear
in the pg_database table (check to see if there are extra spaces there,
though). You can give names that contain spaces in unix, it's no problem.
And then I'd try the drop again.

I hope any of these suggestions helps. Just make sure you have a backup
copy of the directories somewhere safe.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma

#6Jonny Hinojosa
Jonny@TCA.net
In reply to: Herouth Maoz (#5)
Re: [GENERAL] pg_database corrupted(?) If so, what do I do????

I was about to say:

I tried to SIMPLY update the pg_database and it worked!. I have a
tendency to overlook the simple solutions.

Thanks for ALL your help. Maybe someday I'll be smart enough to help you.

Jonny

-----Original Message-----
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Jonny Hinojosa <Jonny@TCA.net>; PostgreSQL General
<pgsql-general@postgreSQL.org>
Date: Tuesday, May 11, 1999 10:52 AM
Subject: Re: [GENERAL] pg_database corrupted(?) If so, what do I do????

At 18:03 +0300 on 11/05/1999, Jonny Hinojosa wrote:

No, but I have tried to figure out how to do just that. I have found no

way

to effect these updates. So which part of the docs did I sleep through???

All help is GREATLY appreciated.

I can't test any advice I give on my own system, as it is used for
production. But let's see if we can do something.

If you tried to update the pg_database with UPDATE pg_database SET
datpath=datname WHERE datpath <> datname; and it didn't work, you may try
the following:

make a copy of the hom and cdmwhere directories in the data directory, for
backup.

Try to DROP DATABASE on the above databases. See if they have disappeared
from the database list (you can use select * from pg_database instead of
psql -l if you are already in psql). If they did, remove or rename the hom
and cdmwhere directories, and re-create them, using the user.

You are now supposed to have two new empty databases with the old names.
Remove the newly created directories and rename the old ones back. Check to
see if you can connect.

It may be advisable to shut down the postmaster when you are changing
things in the data directory, and restart it for the next psql session.

Now, supposed the DROP DATABASE didn't work, and complains that it doesn't
find the directories. Then, if it were me, I would create copies of the
original hom and cdmwhere directories, but give them the names that appear
in the pg_database table (check to see if there are extra spaces there,
though). You can give names that contain spaces in unix, it's no problem.
And then I'd try the drop again.

I hope any of these suggestions helps. Just make sure you have a backup
copy of the directories somewhere safe.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma