[ 
https://issues.apache.org/jira/browse/DERBY-5317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13786078#comment-13786078
 ] 

Dyre Tjeldvoll commented on DERBY-5317:
---------------------------------------

Knut also told me (offline) that he would have preferred WriteChainAlreadyInUse 
to be checked.

I decided to try that (I actually replaced WriteChainAlreadyInUse with a 
DisconnectExecption with SQLState.NET_WRITE_CHAIN_IS_DIRTY) just to see how it 
would work. When doing so, it occurred to me that there really are three 
different situations that need to be handled when reading from the InputStream 
(in Request.writePlainScalarStream()):

#  in.read() throws an exception but leaves the connection intact. This case is 
handled correctly by the existing code (the exception is saved and the stream 
value is padded with 0 and sent to the server to finish the request).
# in.read() throws an exception which renders the connection unusable (closed):
## in.read() throws SQLState.NET_WRITE_CHAIN_IS_DIRTY. Inform the user that she 
cannot use setX with a locator stream from the same connection.
## in.read() throws some other exception. Since the connection is closed we 
cannot continue the request as in 1) (that would give an NPE when accessing the 
output stream), but must throw an SqlException, which should probably be a .C 
version of XN014.S wrapping the IOException from in.read(). 

2.1 is really just a special case of 2.2 which lets us provide a better error 
message to the user, but in order to provide it we need to traverse the cause 
chain to see if it contains SQLState.NET_WRITE_CHAIN_IS_DIRTY. 

As an experiment, I tried running the repro without special handling of case 
2.1:
 {quote}
START ClobTest #4 - select and then update clob of size= 31744 - Uses setClob 
api
Exception in thread "main" java.sql.SQLNonTransientConnectionException: 
Encountered an exception which terminated the connection, while reading from 
the stream specified by parameter #1. The Exception had this message: 
`org.apache.derby.client.am.DisconnectException: A write chain that has 
transmitted 
                    data to the server cannot be reset until the request
                    is finished and the chain terminated.'.
        at 
org.apache.derby.client.am.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:104)
        at 
org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:321)
        at 
org.apache.derby.client.am.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:404)
        at Repro5317.selectUpdateClob(Repro5317.java:172)
        at Repro5317.main(Repro5317.java:43)
Caused by: org.apache.derby.client.am.SqlException: Encountered an exception 
which terminated the connection, while reading from the stream specified by 
parameter #1. The Exception had this message: 
`org.apache.derby.client.am.DisconnectException: A write chain that has 
transmitted 
                    data to the server cannot be reset until the request
                    is finished and the chain terminated.'.
        at 
org.apache.derby.client.net.Request.writePlainScalarStream(Request.java:332)
        at 
org.apache.derby.client.net.Request.writeScalarStream(Request.java:244)
        at 
org.apache.derby.client.net.Request.writeScalarStream(Request.java:515)
        at 
org.apache.derby.client.net.NetStatementRequest.buildEXTDTA(NetStatementRequest.java:1070)
        at 
org.apache.derby.client.net.NetStatementRequest.writeExecute(NetStatementRequest.java:166)
        at 
org.apache.derby.client.net.NetPreparedStatement.writeExecute_(NetPreparedStatement.java:156)
        at 
org.apache.derby.client.am.ClientPreparedStatement.writeExecute(ClientPreparedStatement.java:1832)
        at 
org.apache.derby.client.am.ClientPreparedStatement.flowExecute(ClientPreparedStatement.java:2047)
        at 
org.apache.derby.client.am.ClientPreparedStatement.executeUpdateX(ClientPreparedStatement.java:409)
        at 
org.apache.derby.client.am.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:395)
        ... 2 more
Caused by: java.io.IOException: org.apache.derby.client.am.DisconnectException: 
A write chain that has transmitted 
                    data to the server cannot be reset until the request
                    is finished and the chain terminated.
        at 
org.apache.derby.client.am.ClobLocatorReader.readCharacters(ClobLocatorReader.java:233)
        at 
org.apache.derby.client.am.ClobLocatorReader.read(ClobLocatorReader.java:152)
        at java.io.BufferedReader.fill(BufferedReader.java:154)
        at java.io.BufferedReader.read1(BufferedReader.java:205)
        at java.io.BufferedReader.read(BufferedReader.java:279)
        at 
org.apache.derby.client.am.UpdateSensitiveClobLocatorReader.read(UpdateSensitiveClobLocatorReader.java:152)
        at 
org.apache.derby.client.net.EncodedInputStream.reEncode(EncodedInputStream.java:121)
        at 
org.apache.derby.client.net.EncodedInputStream.read(EncodedInputStream.java:180)
        at java.io.InputStream.read(InputStream.java:170)
        at 
org.apache.derby.client.net.Request.writePlainScalarStream(Request.java:316)
        ... 11 more
Caused by: org.apache.derby.client.am.DisconnectException: A write chain that 
has transmitted 
                    data to the server cannot be reset until the request
                    is finished and the chain terminated.
        at 
org.apache.derby.client.net.NetAgent.verifyWriteChainIsClean(NetAgent.java:488)
        at 
org.apache.derby.client.net.NetAgent.beginWriteChain(NetAgent.java:500)
        at 
org.apache.derby.client.am.ClientPreparedStatement.flowPrepareDescribeInputOutput(ClientPreparedStatement.java:1966)
        at 
org.apache.derby.client.am.ClientPreparedStatement.prepare(ClientPreparedStatement.java:314)
        at 
org.apache.derby.client.am.ClientConnection.prepareCallX(ClientConnection.java:2003)
        at 
org.apache.derby.client.am.CallableLocatorProcedures.clobGetSubString(CallableLocatorProcedures.java:892)
        at 
org.apache.derby.client.am.ClobLocatorReader.readCharacters(ClobLocatorReader.java:223)
        ... 20 more
{quote}

So it is not strictly necessary to traverse the cause chain, but the resulting 
error message is undoubtedly harder to parse. So unless I'm told otherwise, 
I'll keep the cause-chain traversal and the special error for locator streams 
from the same connection.


>  NullPointerException in org.apache.derby.client.net.Request.sendBytes()  
> with client
> -------------------------------------------------------------------------------------
>
>                 Key: DERBY-5317
>                 URL: https://issues.apache.org/jira/browse/DERBY-5317
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Client
>    Affects Versions: 10.9.1.0
>            Reporter: Kathey Marsden
>              Labels: derby_triage10_11, patch
>         Attachments: derby-5317a.diff, derby-5317b.diff, Repro5317.java, 
> Repro5317.java, traces_10_2and10_9.zip
>
>
> Investigating DERBY-5308, I found that the LobLimits.java test run with 
> client fails with a NullPointerException.
>  
> END setup
> ========================================
> START ClobTest #1  -insertClob of size = 2147483647
> Rows inserted with clob of size (2147483647) = 2
> ========================================
> ========================================
> START ClobTest #2 - SELECT CLOB of size = 2147483647
> Matched rows selected with clob of size(2147483647) =1
> ========================================
> ========================================
> START ClobTest #3 - SELECT CLOB of size = 2147483647
> Matched rows selected with clob of size(2147483647) =1
> ========================================
> ========================================
> START ClobTest #4 - select and then update clob of size= 2147483647 - Uses 
> setClob api
> FAIL -- Unexpected exception:
> java.lang.NullPointerException
>         at org.apache.derby.client.net.Request.sendBytes(Unknown Source)
>         at 
> org.apache.derby.client.net.Request.flushScalarStreamSegment(Unknown Source)
>         at 
> org.apache.derby.client.net.Request.padScalarStreamForError(Unknown Source)
>         at org.apache.derby.client.net.Request.writePlainScalarStream(Unknown 
> Source)
>         at org.apache.derby.client.net.Request.writeScalarStream(Unknown 
> Source)
>         at org.apache.derby.client.net.Request.writeScalarStream(Unknown 
> Source)
>         at 
> org.apache.derby.client.net.NetStatementRequest.buildEXTDTA(Unknown Source)
>         at 
> org.apache.derby.client.net.NetStatementRequest.writeExecute(Unknown Source)
>         at 
> org.apache.derby.client.net.NetPreparedStatement.writeExecute_(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.writeExecute(Unknown 
> Source)
>         at org.apache.derby.client.am.PreparedStatement.flowExecute(Unknown 
> Source)
>         at 
> org.apache.derby.client.am.PreparedStatement.executeUpdateX(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.executeUpdate(Unknown 
> Source)
>         at 
> org.apache.derbyTesting.functionTests.tests.largedata.LobLimits.selectUpdateClob(LobLimits.java:115
> 7)
>         at 
> org.apache.derbyTesting.functionTests.tests.largedata.LobLimits.clobTests(LobLimits.java:313)
>         at 
> org.apache.derbyTesting.functionTests.tests.largedata.LobLimits.runTests(LobLimits.java:177)
>         at 
> org.apache.derbyTesting.functionTests.tests.largedata.LobLimits.main(LobLimits.java:151)
> ========================================
> START ClobTest #12.1  -insertClob of size = 104857600
> NEGATIVE TEST - Expected Exception:
> EXPECTED SQL Exception: (08003) No current connection.
> ========================================
> START ClobTest #12.2 - SELECT CLOB of size = 104857600
> FAIL -- Unexpected exception:
> java.sql.SQLNonTransientConnectionException: No current connection.
>         at 
> org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown 
> Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown 
> Source)
>         at org.apache.derby.client.am.PreparedStatement.setInt(Unknown Source)
>         at 
> org.apache.derbyTesting.functionTests.tests.largedata.LobLimits.selectClob(LobLimits.java:1007)
> In the derby.log I see
> derby.system.home=/local0/kmarsden/repro/largeData/testtrunkdnc/DerbyNetClient/LobLimits
> Database Class Loader started - derby.database.classpath=''
> Tue Jul 05 17:50:01 PDT 2011 Thread[DRDAConnThread_11,5,main] (DATABASE = 
> wombat), (DRDAID = .-580681567053183
> 269{2}), Execution failed because of a Distributed Protocol Error:  
> DRDA_Proto_SYNTAXRM; CODPNT arg  = 200d; E
> rror Code Value = 1d. Plaintext connection attempt from an SSL enabled client?
> Tue Jul 05 17:50:01 PDT 2011 : Execution failed because of a Distributed 
> Protocol Error:  DRDA_Proto_SYNTAXRM;
>  CODPNT arg  = 200d; Error Code Value = 1d. Plaintext connection attempt from 
> an SSL enabled client?
> org.apache.derby.impl.drda.DRDAProtocolException: Execution failed because of 
> a Distributed Protocol Error:  D
> RDA_Proto_SYNTAXRM; CODPNT arg  = 200d; Error Code Value = 1d. Plaintext 
> connection attempt from an SSL enable
> d client?
>         at org.apache.derby.impl.drda.DRDAConnThread.throwSyntaxrm(Unknown 
> Source)
>         at org.apache.derby.impl.drda.DRDAConnThread.invalidCodePoint(Unknown 
> Source)
>         at 
> org.apache.derby.impl.drda.DRDAConnThread.parseEXCSQLSTTobjects(Unknown 
> Source)
>         at org.apache.derby.impl.drda.DRDAConnThread.parseEXCSQLSTT(Unknown 
> Source)
>         at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown 
> Source)
>         at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
> Tue Jul 05 17:50:01 PDT 2011 Thread[DRDAConnThread_11,5,main] (DATABASE = 
> wombat), (DRDAID = .-580681567053183
> 269{2}), Execution failed because of a Distributed Protocol Error:  
> DRDA_Proto_SYNTAXRM; CODPNT arg  = 200d; E
> rror Code Value = 1d. Plaintext connection attempt from an SSL enabled client?
> Tue Jul 05 17:50:01 PDT 2011 : Execution failed because of a Distributed 
> Protocol Error:  DRDA_Proto_SYNTAXRM;
>  CODPNT arg  = 200d; Error Code Value = 1d. Plaintext connection attempt from 
> an SSL enabled client?
> org.apache.derby.impl.drda.DRDAProtocolException: Execution failed because of 
> a Distributed Protocol Error:  D
> RDA_Proto_SYNTAXRM; CODPNT arg  = 200d; Error Code Value = 1d. Plaintext 
> connection attempt from an SSL enable
> d client?
>         at org.apache.derby.impl.drda.DRDAConnThread.throwSyntaxrm(Unknown 
> Source)
>         at org.apache.derby.impl.drda.DRDAConnThread.invalidCodePoint(Unknown 
> Source)
>         at 
> org.apache.derby.impl.drda.DRDAConnThread.parseEXCSQLSTTobjects(Unknown 
> Source)
>         at org.apache.derby.impl.drda.DRDAConnThread.parseEXCSQLSTT(Unknown 
> Source)
>         at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown 
> Source)
>         at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
> ----------------------------------------------------------------
> Tue Jul 05 17:50:07 PDT 2011: Shutting down Derby engine
> ----------------------------------------------------------------
> Tue Jul 05 17:50:07 PDT 2011:
> To run the test, you have to remove largeData from DerbyNetClient.exclude and 
> run
> java -Dframework=DerbyNetClient 
> org.apache.derbyTesting.functionTests.harness.RunTest  
> org.apache.derbyTesting.functionTests.tests.lageData.LobLimits.
> It took about 3.5 hours to occur.
> I will work on a smaller reproduction.
>                                                                               
>               5,9           36%



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to