From: | Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> |
---|---|
To: | Theo Schlossnagle <jesus(at)omniti(dot)com> |
Cc: | PostgreSQL-development Development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: question about implementing XA-ish functions |
Date: | 2009-12-18 18:34:20 |
Message-ID: | 4B2BCB2C.5070006@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Theo Schlossnagle wrote:
> I'm trying to implement a function that has some XA like properties.
>
> Is it possible to write a postgres extension function that fires when called within a pg transaction... however, the actions it takes need to be later committed or rolled back based on the containing transactions commital or not. Not having looked to deeply into this, I'm wondering if this is possible. Naively, my first hookpoint would be something like:
>
> allocate something in the transactions memory context and register a cleanup.... do my work.
>
> when the transaction memory context is cleaned up, my cleanup handler fires, I detect whether the txn was committed or rolledback and rightly mark my work as committed or rolled back.
See RegisterXactCallback(). And then there's the ResourceOwners, that
you can use to register custom resources for cleanup.
Of course, you'll never be able to make it atomic without 2PC. The
callbacks are executed very soon after after the commit record has been
flushed to disk, so the window is small but it's there.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2009-12-18 18:56:02 | Re: PATCH: Add hstore_to_json() |
Previous Message | Heikki Linnakangas | 2009-12-18 18:21:18 | Re: Backup history file should be replicated in Streaming Replication? |