pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Multiple backends on a single physical database
13+ messages / 9 participants
[nested] [flat]

* Multiple backends on a single physical database
@ 2002-10-10 06:09  Anuradha Ratnaweera <anuradha@gnu.org>
  0 siblings, 2 replies; 13+ messages in thread

From: Anuradha Ratnaweera @ 2002-10-10 06:09 UTC (permalink / raw)
  To: pgsql-admin


I am wondering if it is sane to mount PGDATA over NFS on many
machines and run posmaster backends on them, so that all the
postmasters are using the same database.

Obviously performance is going to suffer because network traffic
is going to be high, but later we may use a distributed filesystem
with replications instead of NFS.

Thanks in advance.

	Anuradha

-- 

Debian GNU/Linux (kernel 2.4.18-xfs-1.1)

There is more simplicity in the man who eats caviar on impulse than in the
man who eats Grape-Nuts on principle.
		-- G.K. Chesterton




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Multiple backends on a single physical database
@ 2002-10-10 06:40  Vincent Janelle <random@goblinstudios.com>
  parent: Anuradha Ratnaweera <anuradha@gnu.org>
  1 sibling, 1 reply; 13+ messages in thread

From: Vincent Janelle @ 2002-10-10 06:40 UTC (permalink / raw)
  To: Anuradha Ratnaweera <anuradha@gnu.org>; +Cc: pgsql-admin

No.  Only one postmaster can access the PGDATA dir at one time. 
 Attempting to run multiple copies will result in data corruption.

http://gborg.postgresql.org/project/pgreplication/projdisplay.php 
contains the gborg project for replication.

Anuradha Ratnaweera wrote:

>I am wondering if it is sane to mount PGDATA over NFS on many
>machines and run posmaster backends on them, so that all the
>postmasters are using the same database.
>
>Obviously performance is going to suffer because network traffic
>is going to be high, but later we may use a distributed filesystem
>with replications instead of NFS.
>
>Thanks in advance.
>
>	Anuradha
>
>  
>






^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Multiple backends on a single physical database
@ 2002-10-10 14:09  Bruce Momjian <pgman@candle.pha.pa.us>
  parent: Vincent Janelle <random@goblinstudios.com>
  0 siblings, 1 reply; 13+ messages in thread

From: Bruce Momjian @ 2002-10-10 14:09 UTC (permalink / raw)
  To: Vincent Janelle <random@goblinstudios.com>; +Cc: Anuradha Ratnaweera <anuradha@gnu.org>; pgsql-admin

Vincent Janelle wrote:
> No.  Only one postmaster can access the PGDATA dir at one time. 
>  Attempting to run multiple copies will result in data corruption.

We also don't recommend NFS directories because the NFS file behavior is
not 100% the same as a local file system.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Multiple backends on a single physical database
@ 2002-10-11 18:13  Josh Goldberg <josh@4dmatrix.com>
  parent: Anuradha Ratnaweera <anuradha@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread

From: Josh Goldberg @ 2002-10-11 18:13 UTC (permalink / raw)
  To: Anuradha Ratnaweera <anuradha@gnu.org>; pgsql-admin

I have just done this.  There are three things I have found necessary:
1.  Only one backend can use the postmaster.pid file.  You must edit the
sourcecode for the other backends before you compile it.
2.  If you have backends A,B,C and A makes a modification to the data, B and
C need to be restarted before they can see the changes.
3.  Startup scripts for backends B and C that do not use the postmaster.pid
file need to be changed, specifically the method of stopping them.  I do a
`ps` and awk out the pid to kill it.  This is necessary to prevent removing
the lockfile from backend A.

I plan to use a high speed network storage device to accomplish this setup
effectively.

----- Original Message -----
From: "Anuradha Ratnaweera" <anuradha@gnu.org>
To: <pgsql-admin@postgresql.org>
Sent: Wednesday, October 09, 2002 11:09 PM
Subject: [ADMIN] Multiple backends on a single physical database


>
> I am wondering if it is sane to mount PGDATA over NFS on many
> machines and run posmaster backends on them, so that all the
> postmasters are using the same database.
>
> Obviously performance is going to suffer because network traffic
> is going to be high, but later we may use a distributed filesystem
> with replications instead of NFS.
>
> Thanks in advance.
>
> Anuradha
>
> --
>
> Debian GNU/Linux (kernel 2.4.18-xfs-1.1)
>
> There is more simplicity in the man who eats caviar on impulse than in the
> man who eats Grape-Nuts on principle.
> -- G.K. Chesterton
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Multiple backends on a single physical database
@ 2002-10-12 15:06  Chris Miles <chris_pg002@psychofx.com>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 13+ messages in thread

From: Chris Miles @ 2002-10-12 15:06 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: pgsql-admin

On Thu, Oct 10, 2002 at 10:09:55AM -0400, Bruce Momjian wrote:
> We also don't recommend NFS directories because the NFS file behavior is
> not 100% the same as a local file system.

Can you comment on what the incompatabities are?  (related to PostgreSQL
only).

We currently run PostgreSQL on Linux servers with the data on dedicated
Netapp filers over NFS.  We have had no problems so far and performance
is very acceptable.

If there is something I need to watch out for, I would like to know.

Cheers,
Chris.




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Multiple backends on a single physical database
@ 2002-10-12 15:11  Bruce Momjian <pgman@candle.pha.pa.us>
  parent: Chris Miles <chris_pg002@psychofx.com>
  0 siblings, 3 replies; 13+ messages in thread

From: Bruce Momjian @ 2002-10-12 15:11 UTC (permalink / raw)
  To: Chris Miles <chris_pg002@psychofx.com>; +Cc: pgsql-admin

Chris Miles wrote:
> On Thu, Oct 10, 2002 at 10:09:55AM -0400, Bruce Momjian wrote:
> > We also don't recommend NFS directories because the NFS file behavior is
> > not 100% the same as a local file system.
> 
> Can you comment on what the incompatabities are?  (related to PostgreSQL
> only).
> 
> We currently run PostgreSQL on Linux servers with the data on dedicated
> Netapp filers over NFS.  We have had no problems so far and performance
> is very acceptable.
> 
> If there is something I need to watch out for, I would like to know.

Good question.  It is my understanding that fsync, locking, and the
order of writes is not guaranteed in NFS like it is for local file
systems.  I question how well it would handle any of the failure modes
that local file systems can withstand.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Multiple backends on a single physical database
@ 2002-10-12 15:19  Chris Miles <chris_pg002@psychofx.com>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  2 siblings, 1 reply; 13+ messages in thread

From: Chris Miles @ 2002-10-12 15:19 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: pgsql-admin

On Sat, Oct 12, 2002 at 11:11:53AM -0400, Bruce Momjian wrote:
> Good question.  It is my understanding that fsync, locking, and the
> order of writes is not guaranteed in NFS like it is for local file
> systems.  I question how well it would handle any of the failure modes
> that local file systems can withstand.

Good point.  Perhaps that depends on the NFS client and server combination
also?  I know that Netapp worked with Oracle and both companies guarantee
and recommend a Sun/Netapp Oracle over NFS solution (which I have setup
in a previous life) and such a solution works very well.

Nobody is going to make such a guarantee with postgresql (are they?)
so consider us a case study for such a setup.  So far, so good, even
under heavy load testing.

If anybody has any horror stories with postgresql over NFS, please share
them.

Cheers,
Chris.




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Multiple backends on a single physical database
@ 2002-10-12 16:26  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Chris Miles <chris_pg002@psychofx.com>
  0 siblings, 1 reply; 13+ messages in thread

From: Tom Lane @ 2002-10-12 16:26 UTC (permalink / raw)
  To: Chris Miles <chris_pg002@psychofx.com>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; pgsql-admin

Chris Miles <chris_pg002@psychofx.com> writes:
> On Sat, Oct 12, 2002 at 11:11:53AM -0400, Bruce Momjian wrote:
>> Good question.  It is my understanding that fsync, locking, and the
>> order of writes is not guaranteed in NFS like it is for local file
>> systems.  I question how well it would handle any of the failure modes
>> that local file systems can withstand.

AFAIR, we do not use file locking, so the unreliability of NFS locks
doesn't hurt us.  What I'd be concerned about is fsync() and sync()
semantics, namely whether data is down to disk when we think it is.

> Nobody is going to make such a guarantee with postgresql (are they?)
> so consider us a case study for such a setup.  So far, so good, even
> under heavy load testing.

Load testing is not the issue here; crash testing is.  Try pulling the
power plug on your NFS box while the database is under load.  If you
can do that repeatedly and not suffer database corruption, then maybe
you have a safe setup.  Be sure to try the case of NFS crash immediately
after a CHECKPOINT.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Multiple backends on a single physical database
@ 2002-10-12 16:31  Ragnar Kjørstad <postgres@ragnark.vestdata.no>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  2 siblings, 0 replies; 13+ messages in thread

From: Ragnar Kjørstad @ 2002-10-12 16:31 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Chris Miles <chris_pg002@psychofx.com>; pgsql-admin

On Sat, Oct 12, 2002 at 11:11:53AM -0400, Bruce Momjian wrote:
> Chris Miles wrote:
> > On Thu, Oct 10, 2002 at 10:09:55AM -0400, Bruce Momjian wrote:
> > > We also don't recommend NFS directories because the NFS file behavior is
> > > not 100% the same as a local file system.
> > 
> > Can you comment on what the incompatabities are?  (related to PostgreSQL
> > only).
> > 
> > We currently run PostgreSQL on Linux servers with the data on dedicated
> > Netapp filers over NFS.  We have had no problems so far and performance
> > is very acceptable.
> > 
> > If there is something I need to watch out for, I would like to know.
> 
> Good question.  It is my understanding that fsync, locking, and the
> order of writes is not guaranteed in NFS like it is for local file
> systems.  I question how well it would handle any of the failure modes
> that local file systems can withstand.

1. fsync will work over nfs if it's configured properly.
   Use nfs version 3. Don't use "async" mount option; be awere
   that async used to be default at least on linux.
   I'm not sure about fdatasync or O_SYNC methods.

2. I don't know what locking, if any, postgresql uses. Flock does not
   work over NFS at all. Fcntl works, if both the server and the client
   runs the lock-deamon.

3. order of writes is not guaranteed either locally or over NFS; that's
   why fsync is used to enforce it when postgresql requires a specific
   write-order.


So; postgresql over NFS should be safe if you are aware of the pitfalls,
either with NetApp or other NFS-servers (but make sure the nfs-server as
well as the client follows the "rules").

That's not to say it's a good idea - running postgresql over NFS is
slower and more expensive than running it on local storage.



-- 
Ragnar Kjørstad
Big Storage



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Multiple backends on a single physical database
@ 2002-10-12 16:34  Ragnar Kjørstad <postgres@ragnark.vestdata.no>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 13+ messages in thread

From: Ragnar Kjørstad @ 2002-10-12 16:34 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Chris Miles <chris_pg002@psychofx.com>; Bruce Momjian <pgman@candle.pha.pa.us>; pgsql-admin

On Sat, Oct 12, 2002 at 12:26:51PM -0400, Tom Lane wrote:
> Load testing is not the issue here; crash testing is.  Try pulling the
> power plug on your NFS box while the database is under load.  If you
> can do that repeatedly and not suffer database corruption, then maybe
> you have a safe setup.  Be sure to try the case of NFS crash immediately
> after a CHECKPOINT.


If pulling the plug causes database-corruption that proves that there is
something wrong with NFS-setup, but if it _doesn't_ cause
database-corruption that doesn't prove that it's safe - it could be that
you're just lucky.

This should be obvious, but I've seen too many people argument like
"I've tested it twice and it didn't break so it must be safe".



-- 
Ragnar Kjørstad
Big Storage



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Multiple backends on a single physical database
@ 2002-10-14 06:15  Chad R. Larson <chad@eldocomp.com>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  2 siblings, 1 reply; 13+ messages in thread

From: Chad R. Larson @ 2002-10-14 06:15 UTC (permalink / raw)
  To: Chris Miles <chris_pg002@psychofx.com>; Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: pgsql-admin

At 04:19 PM 10/12/02 +0100, Chris Miles wrote:
>If anybody has any horror stories with postgresql over NFS, please share
>them.

I have no horror stories, as we aren't doing such a thing.  But it might be 
in our future.

I think the version of the NFS protocol you can use is =very= 
important.  For example, regarding file locking:  V1 didn't do it at all 
(every transaction was supposed to be stateless, which means persistent 
requests were just an error.  In V2, support for locking was defined, but 
many implementations always returned successful and didn't actually do 
anything.  I believe that V3 gets locking right, but I don't know about fsync.

You're gonna have to test your environment...


         -crl
--
Chad R. Larson (CRL22)    chad@eldocomp.com
   Eldorado Computing, Inc.   602-604-3100
      5353 North 16th Street, Suite 400
        Phoenix, Arizona   85016-3228




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Multiple backends on a single physical database
@ 2002-10-14 12:17  Chris Miles <chris_pg002@psychofx.com>
  parent: Chad R. Larson <chad@eldocomp.com>
  0 siblings, 0 replies; 13+ messages in thread

From: Chris Miles @ 2002-10-14 12:17 UTC (permalink / raw)
  To: Chad R. Larson <chad@eldocomp.com>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; pgsql-admin

We use V3 over TCP for our NFS mounts from Netapp.  Mount options are
actually: hard,intr,vers=3,proto=tcp,suid,rsize=32768,wsize=32768

Cheers,
CM


On Sun, Oct 13, 2002 at 11:15:15PM -0700, Chad R. Larson wrote:
> I think the version of the NFS protocol you can use is =very= 
> important.  For example, regarding file locking:  V1 didn't do it at all 
> (every transaction was supposed to be stateless, which means persistent 
> requests were just an error.  In V2, support for locking was defined, but 
> many implementations always returned successful and didn't actually do 
> anything.  I believe that V3 gets locking right, but I don't know about fsync.

-- 
Chris Miles
chris@psychofx.com
http://www.psychofx.com/chris/



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Multiple backends on a single physical database
@ 2002-10-14 15:47  Jeff <threshar@torgo.978.org>
  parent: Ragnar Kjørstad <postgres@ragnark.vestdata.no>
  0 siblings, 0 replies; 13+ messages in thread

From: Jeff @ 2002-10-14 15:47 UTC (permalink / raw)
  To: pgsql-admin

On Sat, 12 Oct 2002, [iso-8859-1] Ragnar Kjørstad wrote:

>
> If pulling the plug causes database-corruption that proves that there is
> something wrong with NFS-setup, but if it _doesn't_ cause
> database-corruption that doesn't prove that it's safe - it could be that
> you're just lucky.
>
> This should be obvious, but I've seen too many people argument like
> "I've tested it twice and it didn't break so it must be safe".
>

Also keep in mind if the Postgres box is running on linux the joys that is
what linux does when an nfs mount "goes away" (unpingable).  On our
machines linux simply blocks in the kernel so you cannot even kill -9 the
applications (or unmount the mount!) granted things will resume once nfs
comes back.. but by that time your machine may be in Big Trouble(tm)

------------------------------------------------------------------------------
Jeff Trout <jeff@jefftrout.com>                  http://www.jefftrout.com/
   Ronald McDonald, with the help of cheese soup,
       controls America from a secret volkswagon hidden in the past
-------------------------------------------------------------------------------





^ permalink  raw  reply  [nested|flat] 13+ messages in thread


end of thread, other threads:[~2002-10-14 15:47 UTC | newest]

Thread overview: 13+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-10-10 06:09 Multiple backends on a single physical database Anuradha Ratnaweera <anuradha@gnu.org>
2002-10-10 06:40 ` Vincent Janelle <random@goblinstudios.com>
2002-10-10 14:09   ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-10-12 15:06     ` Chris Miles <chris_pg002@psychofx.com>
2002-10-12 15:11       ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-10-12 15:19         ` Chris Miles <chris_pg002@psychofx.com>
2002-10-12 16:26           ` Tom Lane <tgl@sss.pgh.pa.us>
2002-10-12 16:34             ` Ragnar Kjørstad <postgres@ragnark.vestdata.no>
2002-10-14 15:47               ` Jeff <threshar@torgo.978.org>
2002-10-12 16:31         ` Ragnar Kjørstad <postgres@ragnark.vestdata.no>
2002-10-14 06:15         ` Chad R. Larson <chad@eldocomp.com>
2002-10-14 12:17           ` Chris Miles <chris_pg002@psychofx.com>
2002-10-11 18:13 ` Josh Goldberg <josh@4dmatrix.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox