Re: standard interfaces for replication providers

Lists: pgsql-hackers
From: alfranio correia junior <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>
To: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: standard interfaces for replication providers
Date: 2006-08-04 08:54:09
Message-ID: 44D30B31.2070403@lsd.di.uminho.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

We have just released an add-on to PostgreSQL supporting the GORDA
Architecture and Programming Interface (GAPI). This opens up support for
DBMS
independent replication middleware, aimed at eager and multi-master
replication in clusters and WANs.

The implementation of the GAPI is achieved in two steps. First, a set of
patches to the PostgreSQL server and a plugin provide the necessary
functionality with minimal intrusion. Then the GAPI is exposed in a
standalone Java process.

Note that this is not yet a complete replication solution. Instead, we seek
feedback on exposed features, their rendering as Java interfaces, and their
implementation on PostgreSQL.

Downloads of source code and documentation are available at:

http://gorda.di.uminho.pt/community

There you will soon find the same interface implemented on Apache Derby and
a replication suite based on group-communication.

We welcome the comments and suggestions of PostgreSQL hackers.

Best regards,

Alfranio Junior.


From: "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>
To: "alfranio correia junior" <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>
Cc: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: standard interfaces for replication providers
Date: 2006-08-04 13:45:44
Message-ID: 36e682920608040645o56ea4bb0l21451c2a73f0e1a3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 8/4/06, alfranio correia junior <alfranio(at)lsd(dot)di(dot)uminho(dot)pt> wrote:
> patches to the PostgreSQL server and a plugin provide the necessary
> functionality with minimal intrusion.

I haven't looked at the patch for this in awhile, but does anyone have
anything against it? I personally like the triggers and think it
would be a nice thing to add.

--
Jonah H. Harris, Software Architect | phone: 732.331.1300
EnterpriseDB Corporation | fax: 732.331.1301
33 Wood Ave S, 2nd Floor | jharris(at)enterprisedb(dot)com
Iselin, New Jersey 08830 | http://www.enterprisedb.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>
Cc: "alfranio correia junior" <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>, Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: standard interfaces for replication providers
Date: 2006-08-04 15:46:52
Message-ID: 29263.1154706412@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Jonah H. Harris" <jonah(dot)harris(at)gmail(dot)com> writes:
> On 8/4/06, alfranio correia junior <alfranio(at)lsd(dot)di(dot)uminho(dot)pt> wrote:
>> patches to the PostgreSQL server and a plugin provide the necessary
>> functionality with minimal intrusion.

> I haven't looked at the patch for this in awhile, but does anyone have
> anything against it?

We haven't been able to build production-grade multi-master replication
without the barrier of a "standard" database-agnostic API, so I kinda
doubt that it will work all that much better with one. See Slony-II.
In short the burden of proof is to show why this should go in, not why not.
(Suitable proof would be a usable replication system built atop it...)

regards, tom lane


From: José Orlando Pereira <jop(at)lsd(dot)di(dot)uminho(dot)pt>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>, "alfranio correia junior" <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>
Subject: Re: standard interfaces for replication providers
Date: 2006-08-04 16:33:23
Message-ID: 200608041733.24228.jop@lsd.di.uminho.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Friday 04 August 2006 16:46, Tom Lane wrote:
> We haven't been able to build production-grade multi-master replication
> without the barrier of a "standard" database-agnostic API, so I kinda
> doubt that it will work all that much better with one. See Slony-II.

I would argue that people haven't been able to build production-grade
multi-master replication, in part, due to the barrier of not having
a "standard" database-agnostic API. :-)

In fact, the problem is not the lack of a "standard" API but the lack of an
API at all. Having to learn the intrincacies of a database server (or build a
full fledged server wrapper) to experiment with simple prototypes is a
serious hurdle for R&D in database replication. This has been the case for
replication based on group communication.

> In short the burden of proof is to show why this should go in, not why not.

Please don't confuse two proposals included in the distributed package:

(1) A PostgreSQL specific patch, which implements a minimal set of required
features with a PostgreSQL-specific interface (e.g. triggers, new statements,
configuration variables). This is by no means a "standard" interface. The
included technical report discusses why these are required for a variety of
replication scenarios.

(2) A DBMS independent "standard" Java interface, which is easily built on
the modified PostgreSQL server using both existing features (e.g. normal
triggers) and those introduced by (1). Included toy applications show how
this would be useful for replication, but we are not (yet) pushing for its
adoption.

> (Suitable proof would be a usable replication system built atop it...)

I agree. ;)

--
Jose Orlando Pereira


From: Markus Schiltknecht <markus(at)bluegap(dot)ch>
To: José Orlando Pereira <jop(at)lsd(dot)di(dot)uminho(dot)pt>
Cc: Josh Berkus <josh(at)postgresql(dot)org>
Subject: Re: standard interfaces for replication providers
Date: 2006-08-07 09:58:50
Message-ID: 44D70EDA.9060602@bluegap.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

José Orlando Pereira wrote:
> I would argue that people haven't been able to build production-grade
> multi-master replication, in part, due to the barrier of not having
> a "standard" database-agnostic API. :-)
>
> In fact, the problem is not the lack of a "standard" API but the lack of an
> API at all. Having to learn the intrincacies of a database server (or build a
> full fledged server wrapper) to experiment with simple prototypes is a
> serious hurdle for R&D in database replication. This has been the case for
> replication based on group communication.

I disagree. There have been a couple of approaches and each has had a
different interface to the database. But for most of them, coding the
database interface was _not_ the hardest part. And a good understanding
of the database system internals is simply required to write a good
replication system.

> Please don't confuse two proposals included in the distributed package:
>
> (1) A PostgreSQL specific patch, which implements a minimal set of required
> features with a PostgreSQL-specific interface (e.g. triggers, new statements,
> configuration variables). This is by no means a "standard" interface. The
> included technical report discusses why these are required for a variety of
> replication scenarios.

Where do I find the included technical report?

I've read the READMEs in PostgreSQL/G toplevel and csrc directory and
did not find convincing reasons why exactly these triggers need to be
added as replication hooks. In fact, Postgres-R (8) would already need
different hooks.

From studying the patch, I understand that these hooks are quite close
to what's needed for a Postgres-R or Slony-II like sync, multi-master
replication system (i.e. hooks for writeset extraction, the addition of
a 'serialization error' for remote transactions).

I can see use for such an API as soon as we have a production-grade
replication system, which performs well enough in most applications
(i.e. when we know exactly where to place the hooks). But up until then,
people will try different algorithms and different hooks.

Concerning my work on Postgres-R I can tell: I'm not going to use these
triggers (hooks) because they are limiting. I know enough about the
database system internals and I _want_ to fiddle with the database
system. Why should I use such an API?

Regards

Markus


From: Jose Orlando Pereira <jop(at)lsd(dot)di(dot)uminho(dot)pt>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Markus Schiltknecht <markus(at)bluegap(dot)ch>, Josh Berkus <josh(at)postgresql(dot)org>, alfranio(at)lsd(dot)di(dot)uminho(dot)pt
Subject: Re: standard interfaces for replication providers
Date: 2006-08-07 18:40:26
Message-ID: 200608071940.26750.jop@lsd.di.uminho.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Monday 07 August 2006 10:58, Markus Schiltknecht wrote:
>
> Where do I find the included technical report?

Sorry, stuff was put twice in the zip file making it somewhat confusing. It is
in postgresql-g-0.1/javasrc/GordaInterfaces/docs/gapi.pdf or directly on the
web site at http://gorda.di.uminho.pt/download/reports/gapi.pdf.

> From studying the patch, I understand that these hooks are quite close
> to what's needed for a Postgres-R or Slony-II like sync, multi-master
> replication system (i.e. hooks for writeset extraction, the addition of
> a 'serialization error' for remote transactions).

Good. Supporting Postgres-R-style protocols was one major goal of our work.

> In fact, Postgres-R (8) would already need different hooks.

> Concerning my work on Postgres-R I can tell: I'm not going to use these
> triggers (hooks) because they are limiting.

Can you point out why is it so, given that it is admittedly quite close?

We'd rather discuss specific issues instead of the general topic of whether to
build APIs around them. We certainly are not married to the proposed
interfaces, although the functionality they capture does reflect our
experience with several algorithms.

--
Jose Orlando Pereira


From: alfranio correia junior <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>
To: Markus Schiltknecht <markus(at)bluegap(dot)ch>
Cc: José Orlando Pereira <jop(at)lsd(dot)di(dot)uminho(dot)pt>, pgsql-hackers(at)postgresql(dot)org, Josh Berkus <josh(at)postgresql(dot)org>
Subject: Re: standard interfaces for replication providers
Date: 2006-08-08 11:54:09
Message-ID: 44D87B61.2030209@lsd.di.uminho.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Markus Schiltknecht wrote:
> Hi,
>
> José Orlando Pereira wrote:
>> I would argue that people haven't been able to build production-grade
>> multi-master replication, in part, due to the barrier of not having a
>> "standard" database-agnostic API. :-)
>>
>> In fact, the problem is not the lack of a "standard" API but the lack
>> of an API at all. Having to learn the intrincacies of a database
>> server (or build a full fledged server wrapper) to experiment with
>> simple prototypes is a serious hurdle for R&D in database
>> replication. This has been the case for replication based on group
>> communication.
>
> I disagree. There have been a couple of approaches and each has had a
> different interface to the database. But for most of them, coding the
> database interface was _not_ the hardest part. And a good
> understanding of the database system internals is simply required to
> write a good replication system.
I agree with you.
But, I would add that the same understanding is required to design and
implement this interface on any database system.
>
>> Please don't confuse two proposals included in the distributed package:
>>
>> (1) A PostgreSQL specific patch, which implements a minimal set of
>> required features with a PostgreSQL-specific interface (e.g.
>> triggers, new statements, configuration variables). This is by no
>> means a "standard" interface. The included technical report discusses
>> why these are required for a variety of replication scenarios.
>
> Where do I find the included technical report?
GordaInterfaces/javasrc/docs/gapi.pdf
>
> I've read the READMEs in PostgreSQL/G toplevel and csrc directory and
> did not find convincing reasons why exactly these triggers need to be
> added as replication hooks. In fact, Postgres-R (8) would already need
> different hooks.
Such triggers are not necessary to develop any kind of replication
protocol... However, indeed any replication protocol requires a set of
hooks that might be enabled by different means, e.g. call back
functions, triggers, etc, etc...
We developed our hooks by means of triggers as their provide a standard
interface (triggers) that might be easily exploited by other projects
besides replication, e.g. materialized views.

>
> From studying the patch, I understand that these hooks are quite close
> to what's needed for a Postgres-R or Slony-II like sync, multi-master
> replication system (i.e. hooks for writeset extraction, the addition
> of a 'serialization error' for remote transactions).
>
> I can see use for such an API as soon as we have a production-grade
> replication system, which performs well enough in most applications
> (i.e. when we know exactly where to place the hooks). But up until
> then, people will try different algorithms and different hooks.
>
> Concerning my work on Postgres-R I can tell: I'm not going to use
> these triggers (hooks) because they are limiting.
Could you tell me why they are limiting ?
> I know enough about the database system internals and I _want_ to
> fiddle with the database system. Why should I use such an API?
The idea is not to impose our API but what we really want is to show
that behind the requirements for replication systems there is place for
a variety of systems that could be leverage by means of a "standard api".

Jose Orlando, any comments on that ?


From: Markus Schiltknecht <markus(at)bluegap(dot)ch>
To: Jose Orlando Pereira <jop(at)lsd(dot)di(dot)uminho(dot)pt>
Cc: pgsql-hackers(at)postgresql(dot)org, alfranio(at)lsd(dot)di(dot)uminho(dot)pt
Subject: Re: standard interfaces for replication providers
Date: 2006-08-08 14:24:37
Message-ID: 44D89EA5.5090703@bluegap.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

Jose Orlando Pereira wrote:
> Sorry, stuff was put twice in the zip file making it somewhat confusing. It is
> in postgresql-g-0.1/javasrc/GordaInterfaces/docs/gapi.pdf or directly on the
> web site at http://gorda.di.uminho.pt/download/reports/gapi.pdf.

Thank you. I've just had a quick glance at it.

> Can you point out why is it [limiting], given that it is admittedly quite close?

An API is always limiting. And if you have to change the API a lot, to
fit your needs, what's the point in using it at all? Good APIs don't
change a lot.

Even if it's quite close, I estimate the effort to port Postgres-R to
use your API to be quite large. I.e. the first missing thing that came
to my mind was the ordering of processes when waking them up after
waiting for a lock. Postgres-R needs the processes to be woken up in the
order of writeset arrival.

Now, I didn't see anything related in the patch, but the gapi.pdf has
'Predictable Deadlock Handling' in it. I need to take another look...

> We'd rather discuss specific issues instead of the general topic of whether to
> build APIs around them. We certainly are not married to the proposed
> interfaces, although the functionality they capture does reflect our
> experience with several algorithms.

I still feel that I would need ways too many hooks. Especially when you
consider advanced replication features such as data partitioning and
remote query execution.

What also worries me is the use of triggers. ISTM that using triggers is
not deep enough in the database. In the above example, do I really want
to fire a trigger every time the database needs to wake up a process? In
PostgreSQL a trigger normally runs within a transaction. How do you work
around that?

I'm operating a level deeper with Postgres-R and really enjoy the
freedom I have with C. Having to write a hook or trigger for every
change in the database systems seems a lot of work, which I tend to
postpone until such a thing is really needed.

Regards

Markus


From: Christopher Browne <cbbrowne(at)acm(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: standard interfaces for replication providers
Date: 2006-08-08 16:44:46
Message-ID: 87irl3uqgx.fsf@wolfe.cbbrowne.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

In the last exciting episode, markus(at)bluegap(dot)ch (Markus Schiltknecht) wrote:
> I'm operating a level deeper with Postgres-R and really enjoy the
> freedom I have with C. Having to write a hook or trigger for every
> change in the database systems seems a lot of work, which I tend to
> postpone until such a thing is really needed.

The fact that GORDA is operating as a Java application seems to me to
throw a big layer of fuzziness in the way, too.

Most databases that are interesting to replicate are implemented in C
or C++, thereby implying that a suitably "deep" API needs to be
implemented in C.

In the case of PostgresQL, at least, operating in Java means that you
need to operate at "arms length" from the database, which means the
replication system is by no means tightly integrated.
--
(reverse (concatenate 'string "moc.liamg" "@" "enworbbc"))
http://linuxdatabases.info/info/postgresql.html
Know the list of "large, chronic problems". If there is any problem
with the window system, blame it on the activity system. Any lack of
user functionality should be attributed to the lack of a command
processor. A suprisingly large number of people will believe that you
have thought in depth about the issue to which you are alluding when you
do.
-- from the Symbolics Guidelines for Sending Mail


From: Markus Schiltknecht <markus(at)bluegap(dot)ch>
To: Christopher Browne <cbbrowne(at)acm(dot)org>
Subject: Re: standard interfaces for replication providers
Date: 2006-08-08 18:08:52
Message-ID: 44D8D334.5050808@bluegap.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello Christopher,

Christopher Browne wrote:
> Most databases that are interesting to replicate are implemented in C
> or C++, thereby implying that a suitably "deep" API needs to be
> implemented in C.

I generally agree with you. Although it's probably worth mentioning that
the API they propose adds hooks to PostgreSQL in the form of triggers.
This API comes as a patch is against the PostgreSQL source, thus in C.

The nature of triggers in PostgreSQL would then allow to write
replication systems in whatever language you prefer, as long as there is
a PL/{$LANG} for $LANG = your favorite.

I'm questioning if a replication system can be written by only using
triggers as hooks. AFAIK Slony-I uses triggers, so you can probably
better comment on problems or limitations using triggers. For me a
shared library with some hooks as C function calls seems a more
plausible approach.

Regards

Markus


From: alfranio correia junior <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>
To: Markus Schiltknecht <markus(at)bluegap(dot)ch>
Cc: Jose Orlando Pereira <jop(at)lsd(dot)di(dot)uminho(dot)pt>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: standard interfaces for replication providers
Date: 2006-08-08 18:23:08
Message-ID: 44D8D68C.8050408@lsd.di.uminho.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Markus Schiltknecht wrote:
> Hi,
>
> Jose Orlando Pereira wrote:
>> Sorry, stuff was put twice in the zip file making it somewhat
>> confusing. It is in
>> postgresql-g-0.1/javasrc/GordaInterfaces/docs/gapi.pdf or directly on
>> the web site at http://gorda.di.uminho.pt/download/reports/gapi.pdf.
>
> Thank you. I've just had a quick glance at it.
>
>> Can you point out why is it [limiting], given that it is admittedly
>> quite close?
>
> An API is always limiting. And if you have to change the API a lot, to
> fit your needs, what's the point in using it at all? Good APIs don't
> change a lot.
>
> Even if it's quite close, I estimate the effort to port Postgres-R to
> use your API to be quite large. I.e. the first missing thing that came
> to my mind was the ordering of processes when waking them up after
> waiting for a lock. Postgres-R needs the processes to be woken up in
> the order of writeset arrival.
>
> Now, I didn't see anything related in the patch, but the gapi.pdf has
> 'Predictable Deadlock Handling' in it. I need to take another look...
If I correctly understood your idea, a priority mechanism would be
enough to do so and different applications might exploit it.
Most likely, we need this to apply remote transactions. However, note
that a priority mechanism is not only of interesting in the field of
replication systems but it might be used to improve performance for
instance.

Take a look at the ideas presented in
http://www.cs.cmu.edu/~bianca/icde04.pdf

Unfortunately, our current "prototype" only provides two levels: high
priority or normal priority.
Definitely, it should be improved and we are aware of that.

>
>> We'd rather discuss specific issues instead of the general topic of
>> whether to build APIs around them. We certainly are not married to
>> the proposed interfaces, although the functionality they capture does
>> reflect our experience with several algorithms.
>
> I still feel that I would need ways too many hooks. Especially when
> you consider advanced replication features such as data partitioning
> and remote query execution.

>
> What also worries me is the use of triggers. ISTM that using triggers
> is not deep enough in the database. In the above example, do I really
> want to fire a trigger every time the database needs to wake up a
> process? In PostgreSQL a trigger normally runs within a transaction.
> How do you work around that?
I think we are talking about different levels.... as I said a high
priority mechanism would be enough.
In this case, the API should provide only an interface to set the
priority of a transaction....
In our case, still unfinished and quite simple: "set transaction master"
but it could be easily transformed into "set transaction priority <n>".

Best regards,

Alfranio Junior.


From: alfranio correia junior <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>
To: Markus Schiltknecht <markus(at)bluegap(dot)ch>
Cc: Christopher Browne <cbbrowne(at)acm(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: standard interfaces for replication providers
Date: 2006-08-08 18:37:18
Message-ID: 44D8D9DE.50000@lsd.di.uminho.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Markus Schiltknecht wrote:
>
> I'm questioning if a replication system can be written by only using
> triggers as hooks. AFAIK Slony-I uses triggers, so you can probably
> better comment on problems or limitations using triggers. For me a
> shared library with some hooks as C function calls seems a more
> plausible approach.
Of course not...
It is impossible to build a replication system entirely by only using
triggers...
But definitely, there is a set of common requirements among a variety of
replication systems. Moreover, such requirements are also useful to
other systems as well.

Roughly, the GAPI reflects any event inside a database system and allows
any application to intercept and modify them.
For instance, an event might be:
1 - database shutdown, startup
2 - connection shutdown, startup
3 - statement reception
4 - parsing
5 - execution plan generation
6 - tuples written

Our current prototype covers some of them and some of them partially (2,6).
Besides, we also need the priority mechanism.

Best regards,

Alfranio Junior.


From: Jose Orlando Pereira <jop(at)lsd(dot)di(dot)uminho(dot)pt>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Christopher Browne <cbbrowne(at)acm(dot)org>
Subject: Re: standard interfaces for replication providers
Date: 2006-08-08 21:48:01
Message-ID: 200608082248.01322.jop@lsd.di.uminho.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tuesday 08 August 2006 17:44, Christopher Browne wrote:
> Most databases that are interesting to replicate are implemented in C
> or C++, thereby implying that a suitably "deep" API needs to be
> implemented in C.
>
> In the case of PostgresQL, at least, operating in Java means that you
> need to operate at "arms length" from the database, which means the
> replication system is by no means tightly integrated.

Yes, PostgreSQL is the tough one here. Having a single-process multithreaded
PostgreSQL in which PL/Java would run in one global JVM would sure feel like
Christmas! ;)

Note however that the problem is not Java, but any package that does not
expect the current PostgreSQL concurrency model. AFAIK Postgres-R has
same "arms length" architecture with an external process, probably for
compatibility with Spread.

We have however tried to minimize the inconvenience, even for PostgreSQL, by
doing the following:

1. Implementation was done in two layers, in which the PostgreSQL-specific one
is 100% Java-free and feature complete.

2. High level functionality (i.e. transaction priorities instead of directly
handling individual lock operations) reduce the number of round-trips to the
replication process.

3. Event listeners in Java can be registered as non-blocking, thus putting the
external JVM out of the critical path except in a few critical operations.

Finally, although I concede that most databases that are interesting to
replicate are written in C or C++, these days, most are also getting tightly
coupled JVMs fairly high in their feature lists.

--
Jose Orlando Pereira


From: Jose Orlando Pereira <jop(at)lsd(dot)di(dot)uminho(dot)pt>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Markus Schiltknecht <markus(at)bluegap(dot)ch>, alfranio(at)lsd(dot)di(dot)uminho(dot)pt
Subject: Re: standard interfaces for replication providers
Date: 2006-08-08 21:51:24
Message-ID: 200608082251.24329.jop@lsd.di.uminho.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tuesday 08 August 2006 15:24, Markus Schiltknecht wrote:
>
> An API is always limiting.

Which is a good thing when you are not the one using it but the one committing
to support it. :-)

> I still feel that I would need ways too many hooks. Especially when you
> consider advanced replication features such as data partitioning and
> remote query execution.

Indeed. We have not prototyped those features. Nonetheless, look at
the "silly" query cache example in the distribution (search for
QueryCache.java). It shows how the proposed hooks might be used to intercept
a query and fake a result set, while at the same time executing some stuff
locally. (Warning: this runs on Apache Derby only, as in PostgreSQL we'd need
something like PL/J for server side JDBC.).

> What also worries me is the use of triggers. ISTM that using triggers is
> not deep enough in the database. In the above example, do I really want
> to fire a trigger every time the database needs to wake up a process? In
> PostgreSQL a trigger normally runs within a transaction. How do you work
> around that?

As Alfranio has pointed out in another message in this thread, these triggers
are high level. We never consider some thing "trigger on lock acquire" (also
because it also would hardly be portable). They certainly are more coarse
grained than the standard on update stuff.

Furthermore, having on commit triggers running within transactional boundaries
is very useful. Think about recording global commit order or global
timestamps in the originating site after propagation.

--
Jose Orlando Pereira


From: Markus Schiltknecht <markus(at)bluegap(dot)ch>
To: alfranio correia junior <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>
Cc: Christopher Browne <cbbrowne(at)acm(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: standard interfaces for replication providers
Date: 2006-08-09 07:33:35
Message-ID: 44D98FCF.90408@bluegap.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello Alfranio,

alfranio correia junior wrote:
> Of course not...
> It is impossible to build a replication system entirely by only using
> triggers...

Hm, I don't think it's impossible, just unpractical. Anyway, if you say
so yourself, I really doubt the use of GAPI. If you need to create your
own hooks anyway beside GAPI, why use GAPI at all? Better have one kind
of 'hooking' (i.e. with a dynamically loaded library).

> But definitely, there is a set of common requirements among a variety of
> replication systems. Moreover, such requirements are also useful to
> other systems as well.

So far, they are only partly usable for replication. I never looked into
materialized views or anything else that would benefit from such triggers.

Regards

Markus


From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: Markus Schiltknecht <markus(at)bluegap(dot)ch>
Cc: alfranio correia junior <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>, Christopher Browne <cbbrowne(at)acm(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: standard interfaces for replication providers
Date: 2006-08-09 18:56:09
Message-ID: 20060809185609.GK40481@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Aug 09, 2006 at 07:33:35AM +0000, Markus Schiltknecht wrote:
> Hello Alfranio,
>
> alfranio correia junior wrote:
> >Of course not...
> >It is impossible to build a replication system entirely by only using
> >triggers...
>
> Hm, I don't think it's impossible, just unpractical. Anyway, if you say
> so yourself, I really doubt the use of GAPI. If you need to create your
> own hooks anyway beside GAPI, why use GAPI at all? Better have one kind
> of 'hooking' (i.e. with a dynamically loaded library).

Why reinvent the wheel for everything if there was an interface that
offered some of the needed functionality? Maybe PostgreSQL-R is simply
too deep in the database for any of this to be useful, but I'm 99%
certain that Slony could make use of some of this stuff, such as a hook
on tuples being written out. Likewise, if there were hooks for WAL
records and a way to inject WAL info into a backend it probably wouldn't
be too hard to build WAL-based replication on top of that. Heck, PITR
could probably be refactored to use such hooks.

One of the great things about Oracle is that they expose a hell of a lot
of the technology they use to build features like replication; ie: take
a look at DBMS_*.

> >But definitely, there is a set of common requirements among a variety of
> >replication systems. Moreover, such requirements are also useful to
> >other systems as well.
>
> So far, they are only partly usable for replication. I never looked into
> materialized views or anything else that would benefit from such triggers.
>
> Regards
>
> Markus
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>

--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461


From: Hannu Krosing <hannu(at)skype(dot)net>
To: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
Cc: Markus Schiltknecht <markus(at)bluegap(dot)ch>, alfranio correia junior <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>, Christopher Browne <cbbrowne(at)acm(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: standard interfaces for replication providers
Date: 2006-08-09 19:57:47
Message-ID: 1155153468.5899.12.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Ühel kenal päeval, K, 2006-08-09 kell 13:56, kirjutas Jim C. Nasby:
> On Wed, Aug 09, 2006 at 07:33:35AM +0000, Markus Schiltknecht wrote:
> > Hello Alfranio,
> >
> > alfranio correia junior wrote:
> > >Of course not...
> > >It is impossible to build a replication system entirely by only using
> > >triggers...
> >
> > Hm, I don't think it's impossible, just unpractical. Anyway, if you say
> > so yourself, I really doubt the use of GAPI. If you need to create your
> > own hooks anyway beside GAPI, why use GAPI at all? Better have one kind
> > of 'hooking' (i.e. with a dynamically loaded library).
>
> Why reinvent the wheel for everything if there was an interface that
> offered some of the needed functionality? Maybe PostgreSQL-R is simply
> too deep in the database for any of this to be useful, but I'm 99%
> certain that Slony could make use of some of this stuff, such as a hook
> on tuples being written out.

Slonys problems ar *not* in getting access to tuples written out. Why
fix something that aint broken ?

> Likewise, if there were hooks for WAL
> records and a way to inject WAL info into a backend it probably wouldn't
> be too hard to build WAL-based replication on top of that. Heck, PITR
> could probably be refactored to use such hooks.

What would it buy us ?

> One of the great things about Oracle is that they expose a hell of a lot
> of the technology they use to build features like replication; ie: take
> a look at DBMS_*.

Being an OSS project, postgresql exposes *everything* it has ;)

BTW, do you know how I can get something equivalent to postgresqls
snapshot from oracle ?

I know one case when people had to do a really lot of unefficient work
to find out which transactions had committed during an interval in
oracle.

> > >But definitely, there is a set of common requirements among a variety of
> > >replication systems. Moreover, such requirements are also useful to
> > >other systems as well.
> >
> > So far, they are only partly usable for replication. I never looked into
> > materialized views or anything else that would benefit from such triggers.
> >
> > Regards
> >
> > Markus
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 2: Don't 'kill -9' the postmaster
> >
>
--
----------------
Hannu Krosing
Database Architect
Skype Technologies OÜ
Akadeemia tee 21 F, Tallinn, 12618, Estonia

Skype me: callto:hkrosing
Get Skype for free: http://www.skype.com


From: José Orlando Pereira <jop(at)lsd(dot)di(dot)uminho(dot)pt>
To: pgsql-hackers(at)postgresql(dot)org, Markus Schiltknecht <markus(at)bluegap(dot)ch>
Cc: Hannu Krosing <hannu(at)skype(dot)net>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, alfranio correia junior <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>, Christopher Browne <cbbrowne(at)acm(dot)org>
Subject: Re: standard interfaces for replication providers
Date: 2006-08-10 14:00:15
Message-ID: 200608101500.16468.jop@lsd.di.uminho.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wednesday 09 August 2006 20:57, Hannu Krosing wrote:
> >
> > Why reinvent the wheel for everything if there was an interface that
> > offered some of the needed functionality? Maybe PostgreSQL-R is simply
> > too deep in the database for any of this to be useful, but I'm 99%
> > certain that Slony could make use of some of this stuff, such as a hook
> > on tuples being written out.
>
> Slonys problems ar *not* in getting access to tuples written out. Why
> fix something that aint broken ?

The current implementation of GAPI on PostgreSQL uses the same approach as
Slony-I to extract the write-set. The difference is that it can push them out
immediatly on commit, as required for eager update.

--
Jose Orlando Pereira


From: alfranio correia junior <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>
To: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
Cc: Markus Schiltknecht <markus(at)bluegap(dot)ch>, Christopher Browne <cbbrowne(at)acm(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: standard interfaces for replication providers
Date: 2006-08-10 17:29:59
Message-ID: 44DB6D17.4040902@lsd.di.uminho.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


>
> Why reinvent the wheel for everything if there was an interface that
> offered some of the needed functionality? Maybe PostgreSQL-R is simply
> too deep in the database for any of this to be useful, but I'm 99%
> certain that Slony could make use of some of this stuff, such as a hook
> on tuples being written out. Likewise, if there were hooks for WAL
> records and a way to inject WAL info into a backend it probably wouldn't
> be too hard to build WAL-based replication on top of that. Heck, PITR
> could probably be refactored to use such hooks.
>
Yeah !!!
:-)
The idea is to provide means to inject things at different levels
(statement,
parsed statements, plans, tuples, logs -wal).
So the GAPI provides a generic and standard interface
that enables any application to retrieve information at different
levels and inject information at different levels.

> One of the great things about Oracle is that they expose a hell of a lot
> of the technology they use to build features like replication; ie: take
> a look at DBMS_*.
>
If I am not wrong such procedures are only for administrative purpose.
For instance,
we cannot insert things in a queue to be replicated.


From: Jim Nasby <jnasby(at)pervasive(dot)com>
To: alfranio correia junior <alfranio(at)lsd(dot)di(dot)uminho(dot)pt>
Cc: Markus Schiltknecht <markus(at)bluegap(dot)ch>, Christopher Browne <cbbrowne(at)acm(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: standard interfaces for replication providers
Date: 2006-08-10 20:10:40
Message-ID: 9524A401-E02B-48D6-ABAC-1B7CCED63B53@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Aug 10, 2006, at 12:29 PM, alfranio correia junior wrote:
>> One of the great things about Oracle is that they expose a hell of
>> a lot
>> of the technology they use to build features like replication; ie:
>> take
>> a look at DBMS_*.
>>
> If I am not wrong such procedures are only for administrative purpose.
> For instance,
> we cannot insert things in a queue to be replicated.

No... things like DBMS_PIPE are just general tools that can be used
for anything. My point is that Oracle found they needed functionality
like that do provide a feature they were writing (such as
replication), and said "Well, if we need this, there's probably
others that need it too", so they made it all available. Granted,
they may use some internal interface to it that's faster, but they
still provided it to everyone.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461