Thread: Restart after power outage: createdb

Restart after power outage: createdb

From
Jon Lapham
Date:
While trying to reproduce power outage restart problem I reported
earlier, I have found something odd when pulling the plug on a VM during
a createdb operation.

If I run...
sleep 3; echo starting; createdb bar
...and power off the VM while the "createdb bar" is running.

Upon restart, about 50% of the time I can reproduce the following error
message:

[lapham@localhost ~]$ psql bar
psql: FATAL:  database "bar" does not exist
[lapham@localhost ~]$ createdb bar
createdb: database creation failed: ERROR: could not create directory
"base/65536": File exists
[lapham@localhost ~]$ createdb bar
CREATE DATABASE

So, running "createdb bar" a second time works.  This is probably not a
bug, but I thought I'd mention it anyway as it could potentially cause
problems for people running scripts.

--
-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---
  Jon Lapham  <lapham@jandr.org>                Rio de Janeiro, Brasil
  Personal: http://www.jandr.org/
***-*--*----*-------*------------*--------------------*---------------


Re: Restart after power outage: createdb

From
Jim Nasby
Date:
On Sep 26, 2006, at 7:06 AM, Jon Lapham wrote:
> While trying to reproduce power outage restart problem I reported
> earlier, I have found something odd when pulling the plug on a VM
> during a createdb operation.
>
> If I run...
> sleep 3; echo starting; createdb bar
> ...and power off the VM while the "createdb bar" is running.
>
> Upon restart, about 50% of the time I can reproduce the following
> error message:
>
> [lapham@localhost ~]$ psql bar
> psql: FATAL:  database "bar" does not exist
> [lapham@localhost ~]$ createdb bar
> createdb: database creation failed: ERROR: could not create
> directory "base/65536": File exists
> [lapham@localhost ~]$ createdb bar
> CREATE DATABASE
>
> So, running "createdb bar" a second time works.  This is probably
> not a bug, but I thought I'd mention it anyway as it could
> potentially cause problems for people running scripts.

Could this be a timing issue? IE: are you just issuing the first
createdb bar too soon after the database has started?

I suspect this is a bug...
--
Jim Nasby                                            jim@nasby.net
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)



Re: Restart after power outage: createdb

From
Jon Lapham
Date:
Jim Nasby wrote:
>> [lapham@localhost ~]$ psql bar
>> psql: FATAL:  database "bar" does not exist
>> [lapham@localhost ~]$ createdb bar
>> createdb: database creation failed: ERROR: could not create directory
>> "base/65536": File exists
>> [lapham@localhost ~]$ createdb bar
>
> Could this be a timing issue? IE: are you just issuing the first
> createdb bar too soon after the database has started?
>
> I suspect this is a bug...

Probably not too soon, since postgresql is started by init.d during boot
and it is probably a minute or so after that before I can get logged in,
open a shell, issue the commands, etc.

--
-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---
  Jon Lapham  <lapham@jandr.org>                Rio de Janeiro, Brasil
  Personal: http://www.jandr.org/
***-*--*----*-------*------------*--------------------*---------------


Re: Restart after power outage: createdb

From
Jim Nasby
Date:
On Sep 27, 2006, at 6:24 AM, Jon Lapham wrote:
> Jim Nasby wrote:
>>> [lapham@localhost ~]$ psql bar
>>> psql: FATAL:  database "bar" does not exist
>>> [lapham@localhost ~]$ createdb bar
>>> createdb: database creation failed: ERROR: could not create
>>> directory "base/65536": File exists
>>> [lapham@localhost ~]$ createdb bar
>> Could this be a timing issue? IE: are you just issuing the first
>> createdb bar too soon after the database has started?
>> I suspect this is a bug...
>
> Probably not too soon, since postgresql is started by init.d during
> boot and it is probably a minute or so after that before I can get
> logged in, open a shell, issue the commands, etc.

My brain is foggy on exactly what rules are used to clean $PGDATA up
after a crash, but I'm pretty sure it's not supposed to work like
that. If you can re-test with 8.2RC1 and still reproduce it (please
watch the logs to make sure crash recovery is complete before you try
the createdb), I'd ask on pgsql-bugs.
--
Jim Nasby                                            jim@nasby.net
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)