Re: Using PGSQL to help coordinate many servers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Alvin Hung" <alvin_hung(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Using PGSQL to help coordinate many servers
Date: 2003-02-26 15:46:02
Message-ID: 29797.1046274362@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Alvin Hung" <alvin_hung(at)hotmail(dot)com> writes:
> We have a need to coordinate multiple app-servers that are using the same
> database. Basically, we are thinking about using a table row as the
> coordination mechanism. When an app-server needs to perform an action that
> must be exclusive, it will try to lock that table row first. It will wait on
> that lock if someone else has it.

If there aren't very many distinct locks that you need to have, it'd be
better to dedicate a dummy table for each lock you need, and obtain the
lock with LOCK TABLE commands. This has both speed and flexibility
advantages --- there's only one kind of row lock, but there are multiple
kinds of table locks, so you could have e.g. both shared and exclusive
locking.

The LOCK TABLE mechanism doesn't scale real well to thousands of
different locks, however, so there are cases where you'd want to do it
with row locks.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2003-02-26 15:49:57 Re: index usage (and foreign keys/triggers)
Previous Message Tom Lane 2003-02-26 15:41:43 Re: how to recover after harddisk error