From: | Mark Roberts <mailing_lists(at)pandapocket(dot)com> |
---|---|
To: | Igor Katson <descentspb(at)gmail(dot)com> |
Cc: | Jeff Davis <pgsql(at)j-davis(dot)com>, pgsql-general(at)postgresql(dot)org, plproxy-users(at)pgfoundry(dot)org |
Subject: | Re: Two-phase commmit, plpgsql and plproxy |
Date: | 2009-02-18 17:42:05 |
Message-ID: | 1234978926.11148.321.camel@localhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, 2009-02-12 at 02:17 +0300, Igor Katson wrote:
>
> Thanks, Jeff. Googling smth like "postgresql transaction manager"
> does
> not give any nice result. It seems, that the one just does not exist.
> Hope, plproxy developers will answer smth. considering this problem.
I wrote my own "transaction manager" and tied it into the application
that was triggering the events in the first place. It worked remarkably
well. Greatly simplified by removing application knowledge, it looks
like this:
sub commit_prepared_xacts {
my ($master_transaction_id, @databases) = @_;
for my $database (@databases) {
if (!prepared_xact_exists($master_transaction_id, $database)) {
rollback_all_xacts($master_transaction_id, @databases);
}
}
}
sub prepared_xact_exists {
my ($master_transaction_id, $database) = @_;
return do_query($database, qq|
select gid pg_prepared_xacts from where gid = ?
|, $master_transaction_id);
}
sub rollback_all_xacts
{
my ($master_transaction_id, @databases) = @_;
for my $database (@databases) {
do_query($database, qq|
rollback prepared $master_transaction_id
|);
}
}
-Mark
From | Date | Subject | |
---|---|---|---|
Next Message | Glyn Astill | 2009-02-18 17:45:26 | Re: Query palns and tug-of-war with enable_sort |
Previous Message | Joshua D. Drake | 2009-02-18 17:36:32 | Re: Mammoth replicator |