Re: How to simulate crashes of PostgreSQL?

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Sergey Samokhin <prikrutil(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to simulate crashes of PostgreSQL?
Date: 2009-08-24 06:49:17
Message-ID: 1251096557.13118.48.camel@wallace.localnet
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 2009-08-22 at 13:03 -0700, Sergey Samokhin wrote:
> Hello!
>
> To make my client application tolerant of PostgreSQL failures I first
> need to be able to simulate them in a safe manner (hard reset isn't a
> solution I'm looking for :)
>
> Is there a way to disconnect all the clients as if the server has
> crashed? It should look like a real crash from the client's point of
> view.

If you mean a PostgreSQL server crash: write a C extension function that
de-references a null pointer or calls abort() . Instant crash on demand.
`kill -9' on a backend should have much the same effect, though, and is
easier - it's just not something a client can trigger through an SQL
query.

Remember to keep backups - Pg's designed to be fault tolerant, but it's
still good to be careful just in case.

If, however, you mean a crash of the server machine PostgreSQL is
runnning on, which is MUCH more likely and will have different
effects/behaviour, then Ray Stell's advice to bring the interface down
is probably pretty good. The machine should stop responding to ARP
requests or to any packets directed to its MAC address and will stop
sending packets, so it'll look to the client like it's a hard server
crash.

You should also test your client's response to the Pg server remaining
up but becoming non-responsive (eg: failed disk array causes Pg backends
to remain in uninterruptable disk I/O system calls in the kernel). A
possibly good way to do this is to SIGSTOP the backend(s).

--
Craig Ringer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2009-08-24 06:51:05 Re: Install from Source On Windows - University of Sydney Research
Previous Message Kushal Vaghani 2009-08-24 06:48:08 Re: Install from Source On Windows - University of Sydney Research