pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Allman <msa@allman.ms>
To: Oliver Jowett <oliver@opencloud.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: jdbc xa support
Date: Fri, 22 Jul 2005 01:28:08 -0400 (EDT)
Message-ID: <20050722010716.D7757@yvyyl> (raw)
In-Reply-To: <42E07DDA.7080103@opencloud.com>
References: <20050719193245.D20902@yvyyl>
	<E3F1D1B7-B41C-40C4-9621-60F96363A032@fastcrypt.com>
	<Pine.OSF.4.61.0507201916300.205200@kosh.hut.fi>
	<20050720211921.V54984@yvyyl>
	<Pine.OSF.4.61.0507212140250.34894@kosh.hut.fi>
	<20050721203342.W75792@yvyyl>
	<42E053B0.8080807@opencloud.com>
	<20050721220519.U75792@yvyyl>
	<42E05E6E.4070001@opencloud.com>
	<20050722003221.X7757@yvyyl>
	<42E07DDA.7080103@opencloud.com>

On Fri, 22 Jul 2005, Oliver Jowett wrote:

> Michael Allman wrote:
>
>> The C version takes an argument specifying the maximum number of xids to 
>> recover.  The Java version does not.
>
> That's at least partly because the C version makes the caller allocate the 
> array.

In this situation it is understandable why the C method is stateful and 
how it is supposed to work.  The caller tells the resource manager how 
many xids it can handle at once by passing a length argument. It also 
passes an XID* which it malloc()'s to hold

length * (3 * sizeof(long) + XIDDATASIZE * sizeof(char))

bytes, or something like that.

Without a length argument allowing the TM to tell the RM how many xids it 
can take, it doesn't make sense to return "some" xids at a time.  Because 
how many "some" is is determined by the RM, not the TM, and that defeats 
the purpose of the C version's approach.

This is why I say the Java version doesn't make sense.

>>  Without this information, the Java version not only looks silly but 
>> doesn't make a lot of sense either. 
>
> It seems ok to me -- it puts the burden for selecting a suitable batch size 
> on the resource rather than the TM, but that's six of one, half a dozen of 
> the other. That also means the RM can generate the array at whatever size is 
> convenient, rather than having to internally buffer if it retrieves xids in 
> some large block size than the TM selects.
>
> It certainly doesn't make it more or less stateful, so I still don't 
> understand your original objection.
>
>> For example, how many recovered xids should we return on the first call to 
>> recover()?
>
> For our JDBC implementation? Set a fetchsize on your query to something 
> reasonable -- perhaps 500? -- and return up to that many Xids per call until 
> you hit the end of the resultset, then return empty arrays thereafter until a 
> new scan starts.

Why 500?  It's simpler to return all of them.

>> Anyway, do you think my implementation of the recover() method violates the 
>> JTA spec?
>
> The code in pgjdbcxa-20050721.jar appears to violate the spec, as you 
> completely ignore the flags argument. You need to track the recovery scan 
> state even if you decide to return all Xids in one array, because subsequent 
> calls shouldn't return those Xids again until a new scan is started, per the 
> API docs.

I do track the recovery scan state.  Each call puts the scan cursor at the 
end of the list.

I still don't see a violation of the API.

It looks like the JTA API is wrong or there's a typo.  If we follow the 
spirit of the DTP spec it seems that the TMNOFLAGS flag means "return some 
xids starting from where we last left off".  I'm still not sure what 
TMENDRSCAN means.

Michael



view thread (27+ messages)  latest in thread

Message-ID: <20050722010716.D7757@yvyyl>
Permalink:  ../20050722010716.D7757@yvyyl/
Also on:    postgresql.org/message-id/20050722010716.D7757@yvyyl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: msa@allman.ms, oliver@opencloud.com
  Subject: Re: jdbc xa support
  In-Reply-To: <20050722010716.D7757@yvyyl>
  References: <20050719193245.D20902@yvyyl> <E3F1D1B7-B41C-40C4-9621-60F96363A032@fastcrypt.com> <Pine.OSF.4.61.0507201916300.205200@kosh.hut.fi> <20050720211921.V54984@yvyyl> <Pine.OSF.4.61.0507212140250.34894@kosh.hut.fi> <20050721203342.W75792@yvyyl> <42E053B0.8080807@opencloud.com> <20050721220519.U75792@yvyyl> <42E05E6E.4070001@opencloud.com> <20050722003221.X7757@yvyyl> <42E07DDA.7080103@opencloud.com> <20050722010716.D7757@yvyyl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox