db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <Kristian.Waa...@Sun.COM>
Subject Re: instability in StreamingColumnTest
Date Wed, 28 Apr 2010 12:03:41 GMT
On 27.04.10 17:55, Rick Hillegas wrote:
> Thanks for investigating this, Kristian. Some comments inline...
> Kristian Waagan wrote:
>> On 26.04.10 22:00, Rick Hillegas wrote:
>>> I saw the following error in StreamingColumnTest when run as part of 
>>> the full JUnit suite on the 10.6 branch. I did not see this error 
>>> when I ran that test standalone on that branch or on the trunk. Has 
>>> anyone else seen this instability?
>> Hi Rick,
>> I hadn't, but when I tried harder it manifested on my system as well.
>> The message in the stack trace below was introduced by DERBY-2017, 
>> but that's a red herring.
>> Obviously the bug is timing dependent, and the issues at play here 
>> are DERBY-4315, DERBY-4531 and DERBY-2017. The direct cause is 
>> DERBY-4531, where the finalizer closes the character stream. 
>> Depending on whether Java is able to run the finalizer, the stream 
>> state differs (as observed by the Derby client driver):
>>    o returns -1 on read, results in XN017 [1] (stream open, EOF)
>>    o throws IOException ("Stream closed"), results in XN014 [2].
>> Although XN017 is technically correct, one may argue that we could 
>> introduce a special SQLState for the case where there is no data in 
>> the user stream.
> The JDBC spec seems to me to be vague in this area. At this time, the 
> major implementors may disagree on what the correct behavior is.
>> The simplest way to fix the instability is probably to fix DERBY-4531.
> Before adjusting Derby, it probably would be worthwhile to survey the 
> JDBC expert group for their opinions about what is correct.
>> Opinions?
> In the meantime, I think that we should put some defensive code in the 
> test in order to mask this non-deterministic behavior.
>> Also note that the embedded Derby driver is able to "reuse streams" 
>> for certain data types.  This is due to the fact that the source is 
>> represented as a DVD, in this case SQLVarchar, and the DVD will 
>> materialize the stream the first time it is inserted. I don't think 
>> this will work [in all cases] if the column is BLOB or CLOB.
>> The question is whether we should disallow this usage or not. It can 
>> be seen as a nice optimization, but to me this behavior isn't 
>> intuitive. The same "optimization" can be achieved by using setString 
>> instead of setXStream. The problem with keeping the current behavior 
>> is that the code will work with embedded, but not with the client 
>> driver.
> I'm afraid that I didn't follow this part of your analysis. Let me try 
> to restate what I think you may have said. Consider the following 
> example:
> ps.set???Stream( 1, userSuppliedStream, userSuppliedLength );
> ps.executeUpdate();
> ps.executeUpdate();
> The JDBC spec does not explain what should happen on the second 
> update. Major implementors may handle the second update differently, 
> particularly if the stream is actually longer than userSuppliedLength 
> (I think there is wiggle room in the spec around whether the stream's 
> length is EXACTLY or AT LEAST userSuppliedLength).

Hi Rick,

I think we are talking about three different issues here:
   (a) What will the DBMS do if the stream is longer than 
   (b) What will the DBMS do if the same stream is reused for two or 
more executeUpdate-calls.
   (c) Should the DBMS close the stream after having read data from it.

Below we are talking about (b).

> Are you saying that Derby's behavior on the second update:
> 1) Differs depending on what the data type is

Yes (at least for the embedded driver, i.e. VARCHAR vs CLOB).

> 2) Differs depending on whether you are using the client or embedded 
> driver


> 3) Differs depending on what kind of stream is being used (binary, 
> ascii, character)

Yes (only due to (c) that I know of currently).

> 4) Is non-deterministic

Well, throw GC/finalizers into the mix and we're getting close ;)

To avoid having the error pollute the test runs (too late for RC1 
unfortunately), I'll make the test code accept both XN017 and XN014. The 
test only expects that the second executeUpdate-call fails when running 
with the client driver. I'll attach this workaround to DERBY-4531.


> Thanks,
> -Rick
>> Regards,

View raw message