Re: Follow-up on replication hooks for PostgreSQL

From: "Marko Kreen" <markokr(at)gmail(dot)com>
To: "Robert Hodges" <robert(dot)hodges(at)continuent(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Follow-up on replication hooks for PostgreSQL
Date: 2008-07-10 11:56:31
Message-ID: e51f66da0807100456s5b7b1062o2e7eab098d97cd8d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-advocacy pgsql-hackers

On 7/10/08, Robert Hodges <robert(dot)hodges(at)continuent(dot)com> wrote:
> This is a quick update on a promise I made early in June to suggest
> requirements as well as ways to add replication hooks that would support
> logical replication, as opposed to the physical replication work currently
> underway based on NTT's code.
>
> Well, June was a pretty busy month, so it has taken a while to get back to
> this. However, we are now beginning to examine options for PostgreSQL
> logical replication. To make a long story short we are willing to commit
> resources to this problem or fund other people to do it for us. If you are
> interested please contact me directly. Meanwhile, we are quite serious
> about this problem and intend to work on helpful additions to PostgreSQL in
> this area. I will post more as we make progress.

Well, I'm not exactly sure what you are planning. It's OK to do
draft design privately, but before actually starting coding, the
design should be discussed in -hackers.

And I'm not exactly sure what you mean in "logical replication"?
Way to log DDL statements? Do you want to log DML also?

FWIW, here's very draft design for functionality that could be used
to make current Slony-I/Londiste-like solutions to replicate DDL also.

1. CREATE DDL TRIGGER statement that allows to call function
for all DDL statements.

Only filtering that makes sense here is filtering by area:
tables/functions/views/etc.

It must be possible to do AFTER trigger. Whether BEFORE
trigger for DDL make sense or not, I'm not sure.

2. When function is called, following information is given:

- Object type the event was for (table/view/function)
- Array of object names.
- SQL statement as text.

The trigger function can filter further based on object names
whether it does want to log the event or not.

Trying to make the trigger run on only subset of events is complex,
and parsing the SQL to pieces for trigger to understand it better
is also complex and neither is needed. Unless there are some common
situation where such simple design fails to work, I would not make
the scheme more complex.

Also the design should be based on assumption that the target side
is exactly in sync. Eg. DROP CASCADE should be replicated as DROP CASCADE.
We should not make scheme more complex to survive cases where target
is not in sync. That way madness lies. The effect should be like
same SQL statements are applied to target by hand, no more, no less.

--
marko

In response to

Responses

Browse pgsql-advocacy by date

  From Date Subject
Next Message Robert Hodges 2008-07-10 14:44:20 Re: Follow-up on replication hooks for PostgreSQL
Previous Message Robert Hodges 2008-07-10 00:55:25 Follow-up on replication hooks for PostgreSQL

Browse pgsql-hackers by date

  From Date Subject
Next Message Sushant Sinha 2008-07-10 12:06:27 initdb in current cvs head broken?
Previous Message Gregory Stark 2008-07-10 10:52:43 Re: WITH RECURSIVE updated to CVS TIP