Search Postgresql Archives

Replication Using Triggers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Is there any reason why PostgreSQL replication solutions are all add-on 3rd party ones? Is there any reason why replication couldn't be implemented using triggers and a handful of stored procedures? This is what I have in mind:

Have a plperl function that creates connections to all servers in the cluster (replication partners), and issues the supplied write query to them, possibly with a tag of some sort to indicated it is a replicated query (to prevent circular replication).

Have a post execute trigger that calls the above replication function if the query was issued directly (as opposed to replicated), and passes it the query it just executed if it was successful.

If the replication failed on any node, the whole thing gets rolled back.

This would effectively give star topology synchronous replication with very little effort, and no need for any external code. Am I missing something obvious that would prevent this from working? It would give replication capabilities better than MySQL's (which can only handle ring based multi-master replication) for the sake of about 100 lines of code. None of the required functionality required is new to PostgreSQL, either.

Is there an existing implementation of this? Perhaps a perl program that creates the required triggers and stored procedures from looking at a schema?

Thanks.

Gordan

---------------------------(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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux