Re: Using postgresql connection in distributed environment

From: Kovács Péter <peter(dot)kovacs(at)sysdata(dot)siemens(dot)hu>
To: Zoltan Fulop <zfulop(at)csi(dot)ca>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Using postgresql connection in distributed environment
Date: 2002-04-15 15:57:41
Message-ID: 8A2DDD7ED7876A4698F6FF204F62CBFC0319F26E@budg112a.sysdata.siemens.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

You cannot use PostgreSQL in a truely global transaction. PostgreSQL does
not support distributed transactions in general and it does not support 2pc
in particular. The XA interface is only a fake 2pc interface. You can use it
safely only for transactions, in which one single DataSource is involved.
Last time I checked, this fake 2pc interface did not correctly work even for
single DataSource transactions without some small modification. I think that
my modification was something similar to what you mention in your mail, but
I do not remember any more. If you're interested I can dig out what
modification I needed back then to get it work properly.

Peter

> -----Original Message-----
> From: Zoltan Fulop [mailto:zfulop(at)csi(dot)ca]
> Sent: Friday, April 12, 2002 10:13 PM
> To: pgsql-jdbc(at)postgresql(dot)org
> Subject: [JDBC] Using postgresql connection in distributed environment
>
>
> Hello,
>
> I am using openorb, openorb transaction service, openorb
> implementation of JTA, and the XA classes provided by
> postgresql to execute distributed transactions.
> When i use only one resource, the transaction commits
> properly (since the prepare() method does not get invoked),
> but when i use more then one resources in a global
> transaction, it seems that the prepare() call of the
> org.postgresql.xa.XAConnectionImpl throws an XAException
> indicating that it was invoked in an improper context
> (XAException.XAER_PROTO), which is caused by having the
> TxConnection.count > 0 condition. Here is a breief
> discription on the sequence of calls:
>
> processA:
> Create transaction (getting CosTransactions::Control)
> cache it with some id.
>
> processB: (different control of thread than processA created
> Control in)
> get Control from processA for a specific ID.
> resume CosTransactions::Current with that control.
> Get XAConnection from org.postgressql.PostgresqlDataSource
> register XAResource (from XAConnection) with JTA (the JTA
> implementation uses CosTransaction::Current to talk to the
> distributed transaction)
> exercute some sql command using the connetion aquired from
> XAConnection
>
> processC:
> do the same as processB
>
> processA: (after receiving notification from processB and
> processC about the completion of the task)
> get the CosTransaction::Control for the id.
> call commit.
>
> When i call commit, it calls prepare() on the registered
> XAResources, but since the TxConnection.count is 1 it throws
> the exception (described above)
> However if i change the code
> (org.postgresql.xa.XAConnectionImpl.java: around line 670)
> that the comparison is "txConn.count > 1" (instead of
> "txConn.count > 0") the transaction commits properly...
>
>
> Any help is greatly apprechiated,
> Thank you,
> Zoltan Fulop
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to
> majordomo(at)postgresql(dot)org)
>

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2002-04-15 18:09:30 Re: getColumnName() Problems
Previous Message Barry Lind 2002-04-15 15:29:59 Re: problems with setBytes getBytes