Re: jdbc xa support

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Michael Allman <msa(at)allman(dot)ms>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: jdbc xa support
Date: 2005-07-23 07:09:06
Message-ID: 42E1ED12.6060105@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Michael Allman wrote:

> Since the code returns the complete list,
> the "cursor" is always at the "end" of the "list" of prepared xids.

Correct.

> The code simply starts at the beginning for each call to recover().

This however isn't true -- the cursor should only be reset if
TMSTARTRSCAN is specified, not on every call.

> I don't see anything in the JTA spec that says the TMNOFLAGS int means
> anything other than that no other flag was passed to recover(). In the
> DTP spec it says something about returning xids starting at the current
> cursor position.

See the description of recover() in the JTA spec:

>> The flag parameter indicates where the recover scan should start or end,
>> or start and end. This method may be invoked one or more times during a
>> recovery scan. The resource manager maintains a cursor which marks the
>> current position of the prepared or heuristically completed transaction
>> list. Each invocation of the recover method moves the cursor passed the
>> set of Xids that are returned.
[...]
>> TMSTARTRSCAN - indicates that the recovery scan should be started at the beginning of the
>> prepared or heuristically completed transaction list.

So if TMSTARTRSCAN is specified, you move the cursor to the start of the
list.

Then (regardless of if TMSTARTRSCAN was specified) you generate an array
of Xids to return starting from the current cursor position, and move
the cursor forward past those Xids.

In your case, if you return the whole list when TMSTARTRSCAN is
specified, then that implies you should return an empty list when it's
not specified.

> I added the lines
>
> if (flag != TMSTARTRSCAN) {
> return new Xid[0];
> }
>
> to the top of the recover() method and posted a new version at
>
> http://www.allman.ms/pgjdbcxa/pgjdbcxa-20050722.jar

Not quite -- it's a flag not an enumerated value -- the TM can specify
TMENDRSCAN|TMSTARTRSCAN to restart a scan currently in progress.

'if ((flag & TMSTARTRSCAN) == 0)' should work.

-O

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2005-07-23 07:13:03 Re: jdbc xa support
Previous Message Michael Allman 2005-07-22 23:07:32 Re: jdbc xa support