ERROR: "Database 'products', OID nnn, has disappeared from pg_database"
ERROR: "Database 'products', OID nnn, has disappeared from pg_database"
От:
"Barnes, Sandy (Sandra)" <Sandy.Barnes@Honeywell.com>
Дата:
> Currently, we have been having a problem with some kind of corruption of
> the pg_database file. We are using the database on a limited number of
> writes storage medium. (Compact Flash Card) So that we don't always
> write to the flash, and because we don't care about some of the data, part
> of the database is kept in RAM on a ram file system. We have two
> databases on disk. One database called config, the other the standard
> template1. These are kept in /var/lib/pgsql_base_slave. We have a
> properly init'ed database in /var/lib/pgsql/. When postgresql starts up
> via the init scripts, we create a RAM file system on /var/lib/pgsql/base/,
> and then we create symlinks to the config and template1 databases.
>
> The next set of steps is where we sometimes run into trouble. At
> this point in the init script, we start up the postmaster. Next we do a
> createdb products, where products is the actual name of the database.
> This works fine. Next, we attempt to access the database using psql to
> create a set of tables. This is where sometimes we run into a problem.
> Normally, this works fine, but sometimes we get the error
>
> "Database 'products', OID nnn, has disappeared from pg_database"
>
> where nnn is some number, and forever afterwards we can't access a
> database with that name. Removing and recreating the database doesn't
> help. Neither does vacuuming it. If we delete the whole pgsql directory,
> and recreate it, then use initdb on it, everything is fresh and working
> again, but obviously this isn't a good solution, since we have to recreate
> all the databases, tables, and data.
>
> On the shutdown side, we do a deletedb to remove the products
> database before we shutdown the postmaster. Once that is complete, we do
> a shutdown.
>
> If you need a short list of the startup procedure that is above, here it
> is in a psuedocode fashion.
>
> mount ram drive.
> make symlinks to config and template1 databases
> startup postmaster
> createdb products
> create some tables in products
>
> ... normal operation ...
>
> ... shutdown process
> dropdb products
> shutdown postmaster.
>
>
> I am assuming that some kind of corruption has occured within
> pg_database file, but I don't have the expertise to find where the problem
> is occuring. Any help you can provide would be greatly appreciated.
>
> I am including the init script used.
> <>
>
> Sandy Barnes
> Honeywell
> Business & General Aviation Engineering
> One Technology Center
> 23500 West 105th Street
> Olathe, KS. 66061
> tel 913.712.2027
> fax 913.712.1347
> email sandy.barnes@honeywell.com
>
begin 600 postgresql
M(R$@+V)I;B]S:`HC('!O&ES=',L('=H971H97(@:70@:7,@8W5R
M&ET(#`*"B,@5&AI7-T96T@*'!O&ET(#$*
M"0EE;'-E"@D)"65C:&\@(FQO;VMS(&=O;V0A(@H)"69I"@H)(R!.;R!E>&ES
M=&EN9R!01T1!5$$A($EN:71D8B!I="X*"@EE;'-E"@D)96-H;R`B;F\@9&%T
M86)A2!R
M=6YN:6YG+BXN"@EP:60]8'!I9&]F('!O2!R=6YN:6YG+B(*
M"65L2!S=&%L92!L
M;V-K(&9I;&5S"@D)2!I;G0T*3LB)PH*"0H)%]T:6UE(&EN=#0L($-/
M3E-44D%)3E0@8V]N,2!&3U)%24=.($M%62`H<')O9'5C=%]I9"D@4D5&15)%
M3D-%4R!P7,O<&]S=&=R97-Q;`H)96-H;PH*"@D[.PH@
M('-T871UW-T87)T?'-T;W!\Re: ERROR: "Database 'products', OID nnn, has disappeared from pg_database"
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Barnes, Sandy (Sandra)" writes: >> Normally, this works fine, but sometimes we get the error >> >> "Database 'products', OID nnn, has disappeared from pg_database" >> >> where nnn is some number, and forever afterwards we can't access a >> database with that name. Removing and recreating the database doesn't >> help. Neither does vacuuming it. Try vacuuming pg_database (after connecting to template1 or the other always-there db). 7.1 will be a little smarter about this, but the setup you describe is still pretty risky IMHO. You have a nonvolatile reference in pg_database to a volatile database in the RAM filesystem, so a system crash will leave you with a dangling reference... regards, tom lane