X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D2832D705A for ; Fri, 26 Aug 2005 09:55:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 75526-06 for ; Fri, 26 Aug 2005 12:55:37 +0000 (GMT) Received: from web53214.mail.yahoo.com (web53214.mail.yahoo.com [206.190.49.84]) by svr1.postgresql.org (Postfix) with SMTP id 11864D6FEF for ; Fri, 26 Aug 2005 09:55:35 -0300 (ADT) Received: (qmail 5241 invoked by uid 60001); 26 Aug 2005 12:55:39 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.br; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=3YQIya+Rh69leXfNBMedsbU16DrxMAGW6eHz9fgMVSSkzM8xo6qENf1wp1KdXwjLb7ImKSTutzKyMA8JpXBauPHdl1wO0sk7CU4vKf481scXcUXhT+Sdr2dQnGHUZSzedcjRtrcm1iKrYIKazuSEoIn7OUqgV7t1NVSPfhO42Q8= ; Message-ID: <20050826125539.5239.qmail@web53214.mail.yahoo.com> Received: from [200.193.41.129] by web53214.mail.yahoo.com via HTTP; Fri, 26 Aug 2005 12:55:38 GMT Date: Fri, 26 Aug 2005 12:55:38 +0000 (GMT) From: Carlos Henrique Reimer Subject: Re: Postgresql replication To: Jeff Davis , pgsql-general@postgresql.org In-Reply-To: <430CD03E.3070107@empires.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1282286866-1125060938=:5232" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.67 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374, HTML_10_20=0.295, HTML_MESSAGE=0.001] X-Spam-Level: X-Archive-Number: 200508/1330 X-Sequence-Number: 82738 --0-1282286866-1125060938=:5232 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi, Iīm thinking to test your suggestion, basically because there are only few sites to connect, but there are some points that arenīt very clear to me. My doubts: 1. How to make a view updatable? Using the rule system? 1. Why are inserts handled differently from updates? 2. Can not I use the rule system to make updates go to the base table too (the master piece) like the inserts? 3. Is there not some peformance issues related with the fact of using a table that is an union instead a normal table? Thanks in advance! Reimer Jeff Davis escreveu: Chris Browne wrote: > > Slony-I is a master/slave asynchronous replication system; if you > already considered it unsuitable, then I see little likelihood of > other systems with the same sorts of properties being suitable. > > What could conceivably be of use to you would be a *multimaster* > asynchronous replication system. Unfortunately, multimaster > *anything* is a really tough nut to crack. > In general that's a difficult problem, but in practice there may be a solution. For instance, perhaps the following configuration would be helpful: Make a database for each physical server, called db1 ... dbN. Let your logical tables in each database be table1 ... tableM. Now, for each logical tableX (where 1 <= X <= M), make N physical tables, tableX_1 ... tableX_N. Now, make a view called tableX that is the UNION of tableX_1 ... tableX_N (tableX is not a real table, it's just a logical table). Now, use Slony-I. For each dbY (where 1 <= Y <= N), make dbY a master for tableX_Y (for all X where 1 <= X <= M) and a slave for tableX_Z (for all X,Z where 1 <= X <= M, Z != Y). Now, use a rule that replaces all INSERTs to tableX (where 1 <= X <= M) on dbY (where 1 <= Y <= N) with INSERTs to tableX_Y. That was my attempt at being unambiguous. In general what I mean is that each database is master of one piece of a table, and slave to all the other pieces of that table, and then you have a view which is the union of those pieces. That view is the logical table. Then have a RULE which makes INSERTs go to the physical table for which that database is master. The advantages: if one machine goes down, the rest keep going, and merely miss the updates from that one site to that table. If one machine makes an insert to the table, it quickly propogates to the other machines and transparently becomes a part of the logical tables on those machines. The disadvantages: UPDATEs are difficult, and might end up with a complicated set of rules/procedures/triggers. You may have to program the application defensively in case the database is unable to update a remote database for various reasons (if the record to be updated is a part of a table for which another database is master). Also, since the solution is asynchronous, the databases may provide different results to the same query. In general, this solution does not account for all kinds of data constraints. The conflict resolution is very simplified because it's basically just the union of data. If that union could cause a constraint violation itself, this solution might not be right for you. For instance, let's say you're tracking video rentals, and store policy says that you only rent one video per person. However, maybe they go to store 1 and rent a video, and run to store 2 and rent a video before store 1 sends the INSERT record over to store 2. Now, when they finally do attempt to UNION the data for the view, you have an inconsistant state. Many applications can get by just fine by UNIONing the data like that, and if not, perhaps work around it. I hope this is helpful. Let me know if there's some reason my plan won't work. Regards, Jeff Davis ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match __________________________________________________ Converse com seus amigos em tempo real com o Yahoo! Messenger http://br.download.yahoo.com/messenger/ --0-1282286866-1125060938=:5232 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit
Hi,
 
Iīm thinking to test your suggestion, basically because there are only few sites to connect, but there are some points that arenīt very clear to me.
 
My doubts:
 
1. How to make a view updatable? Using the rule system?
1. Why are inserts handled differently from updates?
2. Can not I use the rule system to make updates go to the base table too (the master piece) like the inserts?
3. Is there not some peformance issues related with the fact of using a table that is an union instead a normal table?
Thanks in advance!
 
Reimer

Jeff Davis <jdavis-pgsql@empires.org> escreveu:
Chris Browne wrote:
>
> Slony-I is a master/slave asynchronous replication system; if you
> already considered it unsuitable, then I see little likelihood of
> other systems with the same sorts of properties being suitable.
>
> What could conceivably be of use to you would be a *multimaster*
> asynchronous replication system. Unfortunately, multimaster
> *anything* is a really tough nut to crack.
>

In general that's a difficult problem, but in practice there may be a
solution.

For instance, perhaps the following configuration would be helpful:

Make a database for each physical server, called db1 ... dbN. Let your
logical tables in each database be table1 ... tableM. Now, for each
logical tableX (where 1 <= X <= M), make N physical tables, tableX_1 ...
tableX_N. Now, make a view call ed tableX that is the UNION of tableX_1
... tableX_N (tableX is not a real table, it's just a logical table).

Now, use Slony-I. For each dbY (where 1 <= Y <= N), make dbY a master
for tableX_Y (for all X where 1 <= X <= M) and a slave for tableX_Z (for
all X,Z where 1 <= X <= M, Z != Y).

Now, use a rule that replaces all INSERTs to tableX (where 1 <= X <= M)
on dbY (where 1 <= Y <= N) with INSERTs to tableX_Y.

That was my attempt at being unambiguous. In general what I mean is that
each database is master of one piece of a table, and slave to all the
other pieces of that table, and then you have a view which is the union
of those pieces. That view is the logical table. Then have a RULE which
makes INSERTs go to the physical table for which that database is master.

The advantages: if one machine goes down, the rest keep going, and
merely miss the updates from that one site to that table. If one machine
makes an insert to the table, it quickly propogates to the other
machines and transparently becomes a part of the logical tables on those
machines.

The disadvantages: UPDATEs are difficult, and might end up with a
complicated set of rules/procedures/triggers. You may have to program
the application defensively in case the database is unable to update a
remote database for various reasons (if the record to be updated is a
part of a table for which another database is master). Also, since the
solution is asynchronous, the databases may provide different results to
the same query.

In general, this solution does not account for all kinds of data
constraints. The conflict resolution is very simplified because it's
basically just the union of data. If that union could cause a constraint
violation itself, this solution might not be right for you. For
instance, let's say you're tracking video rentals, and store policy says
that you only rent one video per person. However, maybe they go to store
1 and rent a video, and run to store 2 and rent a video before store 1
sends the INSERT record over to store 2. Now, when they finally do
attempt to UNION the data for the view, you have an inconsistant state.

Many applications can get by just fine by UNIONing the data like that,
and if not, perhaps work around it.

I hope this is helpful. Let me know if there's some reason my plan won't
work.

Regards,
Jeff Davis




---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger
http://br.download.yahoo.com/messenger/ --0-1282286866-1125060938=:5232--