Christopher Browne cbbrowne at ca.afilias.info
Thu Aug 28 08:53:32 PDT 2008
Ow Mun Heng <Ow.Mun.Heng at wdc.com> writes:
> On Mon, 2008-08-25 at 10:09 -0400, Brad Nicholson wrote:
>> On Mon, 2008-08-25 at 12:25 +0800, Ow Mun Heng wrote:
>> > Just wondering if it's possible to do a cluster on a slony replicated DB
>> > in either master/slave??
>> 
>> You can, with a couple of caveats.
>> 
>> 1: Cluster will take an access exclusive lock the table in question and
>> replication will fall behind for the duration of the cluster if anything
>> tries to write to the table be being clustered.
>
> That's understandable.
>> 
>> 2: Prior to 8.3, cluster is not MVCC safe, so it is very possible to
>> break things by clustering.
>
> Break as in break the replication or break PG?

It *shouldn't* break replication, but there could be some odd caveats...  

CLUSTER, prior to 8.3, has the habit of dropping tuples that are dead,
irrespective of them still being visible to some sessions.

There are two *directly* relevant bits for Slony-I purposes, which
don't look to break replication:

 - If you CLUSTER any of Slony-I's tables (e.g. - such as sl_log_1/2),
   deleted tuples would go away Right Away.

   Fortunately, tuples don't get deleted from sl_log_* until they are
   known to have been replicated *everywhere*, so CLUSTER won't
   adversely affect deletions from sl_log_*.

 - The other side to this is in how data gets *into* sl_log_*.

   If you CLUSTER a replicated table, deleted data could go away
   despite there being transactions still pointing to it.

   Fortunately, that won't adversely affect Slony-I, either, as there
   are two possibilities:

   1.  The transaction deleting data from the replicated table may not
   have committed yet, but in that case CLUSTER won't be able to run
   (since it needs an exclusive lock).  So we can't lose data here.

   2.  The transaction deleting data from the replicated table may
   have committed; if so, then entries are committed to sl_log_*, and
   consistency of replication data remains.

In effect, I don't expect "cruel and unusual" use of CLUSTER to break
replication.

It may break your *application*; if you have old queries that might
look at data that has been deleted, then CLUSTER can cause those
queries to get inconsistent data.  Slony-I doesn't have patterns where
it would look for data in that sort of pattern, so replication
oughtn't break down.

> Hmm..
>
> But, all in all, I can still do the cluster individually right? And not
> through slonik

Right...  Indeed, I'd prefer NOT to use Slonik to do this.
-- 
output = ("cbbrowne" "@" "linuxfinances.info")
http://linuxdatabases.info/info/unix.html
"Well, I wish  you'd just  tell me rather   than trying to engage   my
enthusiasm, because I haven't got one." -- Marvin the Paranoid Android


More information about the Slony1-general mailing list