You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Kathey Marsden (JIRA)" <de...@db.apache.org> on 2005/04/28 06:16:30 UTC

[jira] Created: (DERBY-243) connection toString doesn't give enough information

connection toString doesn't give enough information
---------------------------------------------------

         Key: DERBY-243
         URL: http://issues.apache.org/jira/browse/DERBY-243
     Project: Derby
        Type: Improvement
  Components: JDBC  
    Reporter: Kathey Marsden
    Priority: Trivial
     Fix For: 10.0.2.1, 10.0.2.0, 10.0.2.2, 10.1.0.0


The toString() on the Derby connection doesn't print 
unique information.
for example  System.out.println(conn) prints:
EmbedConnection  in the case of derby embedded


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Re: [jira] Created: (DERBY-243) connection toString doesn't give enough information

Posted by David Van Couvering <Da...@Sun.COM>.
Fair enough.  I wasn't too worried about getting this information once I 
started working on this task, and I saw it as a good opportunity to get 
my feet wet...

David

Daniel John Debrunner wrote:

> Kathey Marsden (JIRA) wrote:
> 
> 
>>connection toString doesn't give enough information
>>---------------------------------------------------
> 
> 
> It's impossible for anyone to pick this improvement up unless the type
> of information required is part of the description.
> 
> Dan.
> 

Re: [jira] Created: (DERBY-243) connection toString doesn't give enough information

Posted by Daniel John Debrunner <dj...@debrunners.com>.
Kathey Marsden (JIRA) wrote:

> connection toString doesn't give enough information
> ---------------------------------------------------

It's impossible for anyone to pick this improvement up unless the type
of information required is part of the description.

Dan.


Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <da...@vancouvering.com>.
Hi, Dag, you are right, this is the same problem.  Thanks, I didn't 
catch this when your email flew by!

David

Dag H. Wanvik wrote:

>>>>>>"DVC(" == David Van Couvering (JIRA) <de...@db.apache.org> wrote:
> 
> DVC(> 
> DVC(>      [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]
> DVC(> David Van Couvering updated DERBY-243:
> DVC(> --------------------------------------
> DVC(> 
> DVC(>     Attachment: DERBY-243.diff
> DVC(> 
> DVC(> All tests pass, except for tools/dblook_test.java, which has a
> DVC(> single-line diff that looks completely unrelated.  I am
> DVC(> investigating and may report a separate bug on this.
> 
> Is this different from Derby-266?
> 
> Dag

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "Dag H. Wanvik" <Da...@Sun.COM>.
>>>>> "DVC(" == David Van Couvering (JIRA) <de...@db.apache.org> wrote:
DVC(> 
DVC(>      [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]
DVC(> David Van Couvering updated DERBY-243:
DVC(> --------------------------------------
DVC(> 
DVC(>     Attachment: DERBY-243.diff
DVC(> 
DVC(> All tests pass, except for tools/dblook_test.java, which has a
DVC(> single-line diff that looks completely unrelated.  I am
DVC(> investigating and may report a separate bug on this.

Is this different from Derby-266?

Dag

[jira] Assigned: (DERBY-243) connection toString doesn't give enough information

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]

David Van Couvering reassigned DERBY-243:
-----------------------------------------

    Assign To: David Van Couvering

> connection toString doesn't give enough information
> ---------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.1, 10.0.2.0, 10.0.2.2, 10.1.0.0

>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]

David Van Couvering updated DERBY-243:
--------------------------------------

    Attachment: DERBY-243.diff

Revised patch based on Oystein's most recent review.  

Changes since previous patch:
- Cleared up extraneous spaces
- Used Integer.toString(int) rather than new Integer(int).toString()
- Restored original checkDataSource30.java, it is no longer part of this patch
- Fixed Javadoc for EmbedPooledConnection.toString()

derbyall passes with no errors

svn status:
M      java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
M      java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
M      java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/lang/miscerrors.sql
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
M      java/testing/org/apache/derbyTesting/functionTests/master/miscerrors.out


> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Versions: 10.0.2.1, 10.0.2.2, 10.1.0.0, 10.0.2.0
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]

David Van Couvering updated DERBY-243:
--------------------------------------

    Attachment: DERBY-243.diff

Good catch by Kathey.  I added some SQL to lang/miscerrors.sql to print out all the rows
from the error log using the ErrorLogReader VTI, and it printed out the new ID fine,
except that it was truncated because the column length for the id was 15 when it needs
to be 36 for a UUID.

I am attaching an updated patch that resolves this issue.

I modified the ErrorLogReader VTI to set the length to 36, and the data printed out
fine.  I also include the change to miscerrors.sql so that we are excercising this
VTI in our regression tests.

Thanks, Kathey!

David

> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.1, 10.0.2.0, 10.0.2.2, 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]

David Van Couvering updated DERBY-243:
--------------------------------------

    Attachment: DERBY-243.diff

I have replaced the old patch with this one.  This one uses UUID to identify a connection string.
It also provides independent connection strings for PooledConnection classes.  

I also added some new tests to jdbcapi/checkDataSource and jdbcapi/CheckDataSource30.  I refactored
the code to ensure two toStrings() are not unique for two separate objects and put this
into TestUtil.

All tests pass, except for tools/dblook_test.java, which has a single-line diff that looks completely
unrelated.  I am investigating and may report a separate bug on this.

Here is svn status output:

M      java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
M      java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
M      java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/dataSour
cePermissions.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDat
aSource.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSou
rcePermissions_net_sed.properties
M      java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dataSo
urcePermissions_net.out
M      java/testing/org/apache/derbyTesting/functionTests/master/dataSourcePermi
ssions.out
M      java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/
dataSourcePermissions_net.out
M      java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource
.out
M      java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource
30.out
M      java/testing/org/apache/derbyTesting/functionTests/suites/derbyall.proper
ties
M      java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
M      java/client/org/apache/derby/client/ClientPooledConnection.java
M      java/client/org/apache/derby/client/am/Connection.java
A      java/client/org/apache/derby/client/am/BasicUUID.java
A      java/client/org/apache/derby/client/am/BasicUUIDFactory.java
M      java/client/org/apache/derby/client/am/LogicalConnection.java


> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.0, 10.0.2.1, 10.0.2.2, 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "Kathey Marsden (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]

Kathey Marsden updated DERBY-243:
---------------------------------

        Summary: connection toString should uniquely identify the connection  (was: connection toString doesn't give enough information)
    Description: 
The toString() on the Derby connection doesn't print 
unique information.
for example  System.out.println(conn) prints:
EmbedConnection  in the case of derby embedded

It would be great if the toString() method for connections could be used to differentiate one connection from another.



  was:
The toString() on the Derby connection doesn't print 
unique information.
for example  System.out.println(conn) prints:
EmbedConnection  in the case of derby embedded



I am not sure if XA Connections and Pooled Connections have the same issue.  I didn't immediately see an override of the toString() method in BrokeredConnection.java like there is for EmbedConnection


> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.1, 10.0.2.0, 10.0.2.2, 10.1.0.0

>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Re: [jira] Commented: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
Hi, Kathey.  Thanks for checking this in (phew! :) ).

I will double-check my javadoc, I thought it was consistent.

Regarding the integer with no prefix, I thought this would allow you to 
do queries against VTIs using the current connection as a filter, e.g. 
(in pseudocode)

   SELECT * FROM ErrorLogVTI vti where vti.SESSID = conn.toString()

I also thought that normally in your trace code you would do

   System.out.println("Connection " + conn);

David

Kathey Marsden wrote:

> Kathey Marsden (JIRA) wrote:
> 
> 
>>   [ http://issues.apache.org/jira/browse/DERBY-243?page=comments#action_12313126 ] 
>>
>>Kathey Marsden commented on DERBY-243:
>>--------------------------------------
>>
>>Committed patch to print connection id in connection.toString
>>
>> 
>>
> 
> 
> Hi David,
> 
> Thanks David for all your work on connection toString().  I think it is
> great that we have our connection toString hooked up to the error logs
> in this way.
> 
>  I committed this patch.  There was some indentation with spaces  in
> checkDataSource that I changed to tabs to match the rest of the file.  
> Could you please update your comment about the connection toString
> semantics to match what went in. 
> I see we went to just an integer without a prefix.  So my
> conn.toString() for my first connection prints:
> 
> 0
> 
> I don't know why that  integer by itself seems a little funny to me, I
> think I liked Connection_0  or some such better  but  I guess it's  ok.
> 
> Kathey
>  
> 
> 

Re: [jira] Commented: (DERBY-243) connection toString should uniquely identify the connection

Posted by Kathey Marsden <km...@sbcglobal.net>.
Kathey Marsden (JIRA) wrote:

>    [ http://issues.apache.org/jira/browse/DERBY-243?page=comments#action_12313126 ] 
>
>Kathey Marsden commented on DERBY-243:
>--------------------------------------
>
>Committed patch to print connection id in connection.toString
>
>  
>

Hi David,

Thanks David for all your work on connection toString().  I think it is
great that we have our connection toString hooked up to the error logs
in this way.

 I committed this patch.  There was some indentation with spaces  in
checkDataSource that I changed to tabs to match the rest of the file.  
Could you please update your comment about the connection toString
semantics to match what went in. 
I see we went to just an integer without a prefix.  So my
conn.toString() for my first connection prints:

0

I don't know why that  integer by itself seems a little funny to me, I
think I liked Connection_0  or some such better  but  I guess it's  ok.

Kathey
 



[jira] Commented: (DERBY-243) connection toString should uniquely identify the connection

Posted by "Kathey Marsden (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-243?page=comments#action_12313126 ] 

Kathey Marsden commented on DERBY-243:
--------------------------------------

Committed patch to print connection id in connection.toString

Sending        java\engine\org\apache\derby\iapi\jdbc\BrokeredConnection.java
Sending        java\engine\org\apache\derby\impl\jdbc\EmbedConnection.java
Sending        java\engine\org\apache\derby\jdbc\EmbedPooledConnection.java
Sending        java\testing\org\apache\derbyTesting\functionTests\master\miscerrors.out
Sending        java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\checkDataSource.java
Sending        java\testing\org\apache\derbyTesting\functionTests\tests\lang\miscerrors.sql
Transmitting file data ......
Committed revision 189704.
$

> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Versions: 10.0.2.1, 10.0.2.2, 10.1.0.0, 10.0.2.0
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <da...@vancouvering.com>.

Kathey Marsden wrote:
> David Van Couvering (JIRA) wrote:
> 
> 
>>I have replaced the old patch with this one.  This one uses UUID to identify a connection string.
>>It also provides independent connection strings for PooledConnection classes.  
>>
>> 
>>
> 
> Hi David
> 
> Just so I understand the connection id semantics as I review this patch,
> could you tell me whether the following statements are true or false
> with regard to your patch. Please specify if the behaviour is different
> for embedded and client.
> 
> 
> 1)  Each physical connection has its own unique connection id,
> regardless of how it is obtained by the application.

Yes, that's right

> 
> 2) If a stored procedure is called from a connection with connection id
> X,  and the stored procedure obtains a connection with
> DriverManager.getConnection("jdbc:default:connection"),  the connection
> in the stored procedure will also have
>     connection id X.

Yes, that's right

> 
> 3) Every logical connection obtained from a single pooled connection
> will  have the same connection id.

This should generally be the case, because BrokeredConnection.toString() 
and LogicalConnection.toString() delegate to their underlying physical 
connections, which are owned by one and only one pooled connection (as 
far as I can see).

However, if for some reason a pooled connection needs to associate 
itself with a new physical connection, there is nothing in the code I 
added that prevents this, and then you will get a new id when you call 
getConnection().  I couldn't see any code that exists that actually does 
this, but I didn't make any specific assumptions of a 1-1 correspondence 
between pooled connection and the underlying physical connection.

Thanks,

David

> 
> Thanks
> 
> Kathey
> 
> 
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Kathey Marsden <km...@sbcglobal.net>.
David Van Couvering (JIRA) wrote:

>I have replaced the old patch with this one.  This one uses UUID to identify a connection string.
>It also provides independent connection strings for PooledConnection classes.  
>
>  
>
Hi David

Just so I understand the connection id semantics as I review this patch,
could you tell me whether the following statements are true or false
with regard to your patch. Please specify if the behaviour is different
for embedded and client.


1)  Each physical connection has its own unique connection id,
regardless of how it is obtained by the application.

2) If a stored procedure is called from a connection with connection id
X,  and the stored procedure obtains a connection with
DriverManager.getConnection("jdbc:default:connection"),  the connection
in the stored procedure will also have
    connection id X.

3) Every logical connection obtained from a single pooled connection
will  have the same connection id.

Thanks

Kathey




[jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]

David Van Couvering updated DERBY-243:
--------------------------------------

    Attachment: DERBY-243.diff

I have replaced the old patch with this one.  This one uses UUID to identify a connection string.
It also provides independent connection strings for PooledConnection classes.  

I also added some new tests to jdbcapi/checkDataSource and jdbcapi/CheckDataSource30.  I refactored
the code to ensure two toStrings() are not unique for two separate objects and put this
into TestUtil.

All tests pass, except for tools/dblook_test.java, which has a single-line diff that looks completely
unrelated.  I am investigating and may report a separate bug on this.

Here is svn status output:

M      java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
M      java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
M      java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/dataSour
cePermissions.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDat
aSource.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSou
rcePermissions_net_sed.properties
M      java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dataSo
urcePermissions_net.out
M      java/testing/org/apache/derbyTesting/functionTests/master/dataSourcePermi
ssions.out
M      java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/
dataSourcePermissions_net.out
M      java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource
.out
M      java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource
30.out
M      java/testing/org/apache/derbyTesting/functionTests/suites/derbyall.proper
ties
M      java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
M      java/client/org/apache/derby/client/ClientPooledConnection.java
M      java/client/org/apache/derby/client/am/Connection.java
A      java/client/org/apache/derby/client/am/BasicUUID.java
A      java/client/org/apache/derby/client/am/BasicUUIDFactory.java
M      java/client/org/apache/derby/client/am/LogicalConnection.java


> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.0, 10.0.2.1, 10.0.2.2, 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Re: [jira] Commented: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <da...@vancouvering.com>.

Kathey Marsden (JIRA) wrote:

>      [ http://issues.apache.org/jira/browse/DERBY-243?page=comments#action_65735 ]
>      
> Kathey Marsden commented on DERBY-243:
> --------------------------------------
> 
> I performed only a very rough review of this diff.  I am hoping someone else can do a more detailed review once the following issues have been resolved.
> 
> 1) I tend to think that it is confusing to have a separate UUID for the client connection.  In a client server environment, each connection has two separate UUID's, which could get confusing.  Especially since the connection id semantics change when dealing with client.  There is an existing Derby entry Derby-293 to correlate the client and server connections. Might it be good to defer the client part of this work until that is considered?

If I understand you right, you are thinking that the toString() of the 
client connection has a direct correlation to the toString() of the 
associated embedded connection, or even matches the toString() of the 
embedded connection.  I can definitely see how that would have some value.

But, wouldn't that require some message exchange during login to pass 
the embedded connection information back to the client?  I'm very new to 
DRDA and am not sure how flexible the protocol is to this sort of thing.

At any rate, perhaps you are right that this should be deferred to 
DERBY-293.  If there are no objections, I can back out the client 
changes as part of this patch.

> 
> 2) I think it would be good to document the connection id semantics in the Jira entry and the code.

OK, I can do that.

David

> 
> 
> 
> 
>>connection toString should uniquely identify the connection
>>-----------------------------------------------------------
>>
>>         Key: DERBY-243
>>         URL: http://issues.apache.org/jira/browse/DERBY-243
>>     Project: Derby
>>        Type: Improvement
>>  Components: JDBC
>>    Reporter: Kathey Marsden
>>    Assignee: David Van Couvering
>>    Priority: Trivial
>>     Fix For: 10.0.2.0, 10.0.2.1, 10.0.2.2, 10.1.0.0
>> Attachments: DERBY-243.diff
>>
>>The toString() on the Derby connection doesn't print 
>>unique information.
>>for example  System.out.println(conn) prints:
>>EmbedConnection  in the case of derby embedded
>>It would be great if the toString() method for connections could be used to differentiate one connection from another.
> 
> 


[jira] Commented: (DERBY-243) connection toString should uniquely identify the connection

Posted by "Kathey Marsden (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=comments#action_65735 ]
     
Kathey Marsden commented on DERBY-243:
--------------------------------------

I performed only a very rough review of this diff.  I am hoping someone else can do a more detailed review once the following issues have been resolved.

1) I tend to think that it is confusing to have a separate UUID for the client connection.  In a client server environment, each connection has two separate UUID's, which could get confusing.  Especially since the connection id semantics change when dealing with client.  There is an existing Derby entry Derby-293 to correlate the client and server connections. Might it be good to defer the client part of this work until that is considered?

2) I think it would be good to document the connection id semantics in the Jira entry and the code.



> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.0, 10.0.2.1, 10.0.2.2, 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]

David Van Couvering updated DERBY-243:
--------------------------------------

    Comment: was deleted

> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.0, 10.0.2.1, 10.0.2.2, 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (DERBY-243) connection toString should uniquely identify the connection

Posted by "Kathey Marsden (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]
     
Kathey Marsden closed DERBY-243:
--------------------------------


fixed

> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Versions: 10.0.2.1, 10.0.2.2, 10.1.0.0, 10.0.2.0
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Resolved: (DERBY-243) connection toString should uniquely identify the connection

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]
     
David Van Couvering resolved DERBY-243:
---------------------------------------

    Resolution: Fixed

Checked in by Kathey

> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Versions: 10.0.2.1, 10.0.2.2, 10.1.0.0, 10.0.2.0
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "Samuel Andrew McIntyre (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]

Samuel Andrew McIntyre updated DERBY-243:
-----------------------------------------

        Version: 10.0.2.1
                 10.0.2.0
                 10.0.2.2
                 10.1.0.0
    Fix Version:     (was: 10.0.2.1)
                     (was: 10.0.2.0)
                     (was: 10.0.2.2)

> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Versions: 10.0.2.1, 10.0.2.0, 10.0.2.2, 10.1.0.0
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
Kathey Marsden wrote:

> David Van Couvering wrote:
> 
> 
>>Hi, all.  I have had some further thought on this, and I have a
>>proposal.  It seems like how one generates ids depends upon the
>>environment Derby is running in.  In a single-VM environment, probably
>>the hashCode() solution is best because it works even if there are
>>multiple systems in the same VM.  However, in a clustered environment,
>>a UUID is probably required.  So I am proposing creating a new
>>service, ObjectIdGenerator.  This allows us to plug in a different
>>implementation at some future date if need be.
>>
> 
> 
> I have to admit  my feeble eyes are disappointed at the loss of the
> counter and I don't really get how you separate out some things like
> the  error logs in these multiple jvm systems , but any additional help
> in differentiating connections would be welcome so hashcodes, counters, 
> UUID's, all   fine with me.
> 

Yes, I agree, but it would be a real pain if you got the same id twice! 
And with hashCode, you can avoid the need for specifying the class name 
as part of the id, as hashCode is unique across classes.

>  I am assuming the ObjectIdGenerator is just  an engine side service? 
> Right now the only shared classes between the engine and client are the
> product version and sysinfo classes.  If classes that are likely to
> change get included in both jars it could be ugly and with mismatched
> clients and servers you would get different implementations depending on
> what came first in your classpath.

Hi, Kathey, you have a good point about the ObjectIdGenerator being 
shared.  I would like to understand our goal for sharing code across 
network client and server.  It sounds like right now there is no sharing 
and if you have similar functionality it must be duplicated.  Isn't 
there any way to fix this?  Could we have a derbyutils.jar or 
derbycore.jar or something like that which is shared between both client 
and server code, where common services like this can go?

Also, don't we have the need for pluggable services (security, logging, 
etc.) on the network client side?  Shouldn't we have some model like the 
server-side module/service model for the network client code?

In the meantime, I think what I'll do is just use the identityHashCode() 
for the network-client connection ids.  If and when we agree on an 
approach I can (or someone else can) adjust this in the future

> 
> 
> 
>>>Another thing that would be very nice is if, in client/server mode,
>>>client connection toString() has a correlation to the resulting
>>>embedded connection toString() created on the server side for that
>>>session.  This way you could get end-to-end correlation.
>>
> 
> This maybe could be done by fixing  Derby-17,   Network Server Needs to
> generate CRRTKN on ACCRDB if client does not send it. The protocol has a
> pretty specific format which  perhaps would be helpful for your embedded
> format as well except it does include the network address, so you would
> have to look at it more closely to see.
> 
> I'll add some comments to Derby-17 with some more information.

OK.  I'd like to suggest this is a separate item, and doesn't need to be 
resolved with this patch, do you agree?

Thanks,

David
> 
> What an adventure!  
> 
> Kathey
> 
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Kathey Marsden <km...@sbcglobal.net>.
David Van Couvering wrote:

> Hi, all.  I have had some further thought on this, and I have a
> proposal.  It seems like how one generates ids depends upon the
> environment Derby is running in.  In a single-VM environment, probably
> the hashCode() solution is best because it works even if there are
> multiple systems in the same VM.  However, in a clustered environment,
> a UUID is probably required.  So I am proposing creating a new
> service, ObjectIdGenerator.  This allows us to plug in a different
> implementation at some future date if need be.
>

I have to admit  my feeble eyes are disappointed at the loss of the
counter and I don't really get how you separate out some things like
the  error logs in these multiple jvm systems , but any additional help
in differentiating connections would be welcome so hashcodes, counters, 
UUID's, all   fine with me.

 I am assuming the ObjectIdGenerator is just  an engine side service? 
Right now the only shared classes between the engine and client are the
product version and sysinfo classes.  If classes that are likely to
change get included in both jars it could be ugly and with mismatched
clients and servers you would get different implementations depending on
what came first in your classpath.


>> Another thing that would be very nice is if, in client/server mode,
>> client connection toString() has a correlation to the resulting
>> embedded connection toString() created on the server side for that
>> session.  This way you could get end-to-end correlation.
>

This maybe could be done by fixing  Derby-17,   Network Server Needs to
generate CRRTKN on ACCRDB if client does not send it. The protocol has a
pretty specific format which  perhaps would be helpful for your embedded
format as well except it does include the network address, so you would
have to look at it more closely to see.

I'll add some comments to Derby-17 with some more information.

What an adventure!  

Kathey



Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
Ah, great feedback, thanks.  If there actually is a desire for 
toString() for these guys, I can easily add them, as independent from 
the application-visible connection objects.

David

Dibyendu Majumdar wrote:

> David,
> 
> Agreed, but I am developing a JTA compliant transaction manager.
> So, my interest is also in PooledConnection and XAConnection.
> 
> Regards
> ----- Original Message ----- 
> From: "David Van Couvering" <Da...@Sun.COM>
> To: "Derby Development" <de...@db.apache.org>
> Sent: Thursday, May 12, 2005 12:14 AM
> Subject: Re: [jira] Updated: (DERBY-243) connection toString should uniquely
> identify the connection
> 
> 
> 
>>Hi, Dibyendu.  You are quoting an email that's a few exchanges old.  My
>>latest proposal is actually for PooledConnection and XAConnection to not
>>have a toString() at all.  As I'm learning myself, when the application
>>does "conn.toString()" it's never on PooledConnection or XAConnection.
>>Application code never sees these classes.  They are used by connection
>>pool providers such as app server containers.  These aren't "really"
>>connections, they are something that deliver connections from a pool.
>>
>>The one "wrapper" connection that is seen by applications is
>>BrokeredConnection.  In this case I suppose we could print the id of
>>BrokeredConnection as well as the underlying physical connection, but
>>I'm not sure what value this provides.  The user would wonder why
>>they're seeing two distinct connection ids for a given connection.
>>Since BrokerConnection is a wrapper, I am proposing that it should just
>>print out the toString() of the underlying "real" connection.
>>
>>David
>>
>>Dibyendu Majumdar wrote:
>>
>>
>>>From: "David Van Couvering" <Da...@Sun.COM>
>>>
>>>>Regarding pooled connections, unless I hear otherwise, I'll modify this
>>>>to not get the id from the underlying physical connection but to have
>>>>its own id instead, so that these are traceable independently.
>>>
>>>
>>>Hi,
>>>
>>>Is it possible to have both - ie - the id for the PooledConnection and
> 
> the
> 
>>>underlying Connection to be dumped? Similarly for XAConnection?
>>>
>>>Regards
>>>
>>>
>>>
>>>
> 
> 
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Dibyendu Majumdar <di...@mazumdar.demon.co.uk>.
David,

Agreed, but I am developing a JTA compliant transaction manager.
So, my interest is also in PooledConnection and XAConnection.

Regards
----- Original Message ----- 
From: "David Van Couvering" <Da...@Sun.COM>
To: "Derby Development" <de...@db.apache.org>
Sent: Thursday, May 12, 2005 12:14 AM
Subject: Re: [jira] Updated: (DERBY-243) connection toString should uniquely
identify the connection


> Hi, Dibyendu.  You are quoting an email that's a few exchanges old.  My
> latest proposal is actually for PooledConnection and XAConnection to not
> have a toString() at all.  As I'm learning myself, when the application
> does "conn.toString()" it's never on PooledConnection or XAConnection.
> Application code never sees these classes.  They are used by connection
> pool providers such as app server containers.  These aren't "really"
> connections, they are something that deliver connections from a pool.
>
> The one "wrapper" connection that is seen by applications is
> BrokeredConnection.  In this case I suppose we could print the id of
> BrokeredConnection as well as the underlying physical connection, but
> I'm not sure what value this provides.  The user would wonder why
> they're seeing two distinct connection ids for a given connection.
> Since BrokerConnection is a wrapper, I am proposing that it should just
> print out the toString() of the underlying "real" connection.
>
> David
>
> Dibyendu Majumdar wrote:
>
> > From: "David Van Couvering" <Da...@Sun.COM>
> >
> >>Regarding pooled connections, unless I hear otherwise, I'll modify this
> >>to not get the id from the underlying physical connection but to have
> >>its own id instead, so that these are traceable independently.
> >
> >
> > Hi,
> >
> > Is it possible to have both - ie - the id for the PooledConnection and
the
> > underlying Connection to be dumped? Similarly for XAConnection?
> >
> > Regards
> >
> >
> >
> >



Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
Hi, Dibyendu.  You are quoting an email that's a few exchanges old.  My 
latest proposal is actually for PooledConnection and XAConnection to not 
have a toString() at all.  As I'm learning myself, when the application 
does "conn.toString()" it's never on PooledConnection or XAConnection. 
Application code never sees these classes.  They are used by connection 
pool providers such as app server containers.  These aren't "really" 
connections, they are something that deliver connections from a pool.

The one "wrapper" connection that is seen by applications is 
BrokeredConnection.  In this case I suppose we could print the id of 
BrokeredConnection as well as the underlying physical connection, but 
I'm not sure what value this provides.  The user would wonder why 
they're seeing two distinct connection ids for a given connection. 
Since BrokerConnection is a wrapper, I am proposing that it should just 
print out the toString() of the underlying "real" connection.

David

Dibyendu Majumdar wrote:

> From: "David Van Couvering" <Da...@Sun.COM>
> 
>>Regarding pooled connections, unless I hear otherwise, I'll modify this 
>>to not get the id from the underlying physical connection but to have 
>>its own id instead, so that these are traceable independently.
> 
> 
> Hi,
> 
> Is it possible to have both - ie - the id for the PooledConnection and the
> underlying Connection to be dumped? Similarly for XAConnection?
> 
> Regards
> 
> 
> 
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Dibyendu Majumdar <di...@mazumdar.demon.co.uk>.
From: "David Van Couvering" <Da...@Sun.COM>
> Regarding pooled connections, unless I hear otherwise, I'll modify this 
> to not get the id from the underlying physical connection but to have 
> its own id instead, so that these are traceable independently.

Hi,

Is it possible to have both - ie - the id for the PooledConnection and the
underlying Connection to be dumped? Similarly for XAConnection?

Regards





Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
Hi, all.  I have had some further thought on this, and I have a 
proposal.  It seems like how one generates ids depends upon the 
environment Derby is running in.  In a single-VM environment, probably 
the hashCode() solution is best because it works even if there are 
multiple systems in the same VM.  However, in a clustered environment, a 
UUID is probably required.  So I am proposing creating a new service, 
ObjectIdGenerator.  This allows us to plug in a different implementation 
at some future date if need be.

Regarding pooled connections, unless I hear otherwise, I'll modify this 
to not get the id from the underlying physical connection but to have 
its own id instead, so that these are traceable independently.

I don't have any clarity on what I need to do to make this work with a 
diagnostics table, so I am not sure of any changes I need to make in 
that regard, any guidance anyone has will be much appreciated.

Comments please?  If I don't here anything by say noon tomorrow I'll go 
ahead and implement the proposed changes.

Thanks,

David

David Van Couvering wrote:

> Thanks for the quick reply, Dan, some responses below.
> 
> Daniel John Debrunner wrote:
> 
>> David Van Couvering (JIRA) wrote:
>>
>>
>>>     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]
>>>
>>> David Van Couvering updated DERBY-243:
>>> --------------------------------------
>>>
>>>    Attachment: DERBY-243.diff
>>>
>>> I am attaching the patch that should resolve this bug.  I added 
>>> toString() to the
>>> appropriate connection classes and updated the 
>>> dataSourcePermissions.java and dataSourcePermissions_net.java tests 
>>> to test toString().  I mostly just verify
>>> that two connections do not have the same string and follow the 
>>> expected pattern.  I had to "sed" out the actual connection ids in 
>>> the output so we
>>> could guarantee a pass even if the ids change.
>>
>>
>>
>> I'd like to see some crisper definition around what the return from
>> toString() is meant to represent for a connection.
>>
>> - with this implementation, two different application connections from
>> the same PooledConnection end up with the same toString() output,
>> because the toString() of the underlying connection is used.
> 
> 
> I am still learning about PooledConnection, not having dealt with this 
> before.  I thought that PooledConnection was an interface only used by 
> app servers and other containers implementing connection pools.  This 
> seems to match what I saw in my tests: regardless of what kind of access 
> mechanism I used (DriverManager, DataSource, ConnectionPoolDataSource or 
> XADataSource), I always ended up with an EmbedConnection30 or a 
> NetConnection being returned to the application, and never a 
> PooledConnection class.
> 
> It is true that multiple sessions in an app server using connection 
> pooling will often get the same connection through the lifetime of the 
> container VM.  However, in terms of tracing a transaction, the 
> connection id will be consistent for the lifetime of the transaction.
> 
> Do we need a toString() in PooledConnection for debugging a container's 
> internal connection pool code?  If so, I agree 
> PooledConnection.toString() shouldn't refer to the underlying physical 
> connection, and I can fix that...
> 
>>
>> - however, a connection returned by jdbc:default:connection, has a
>> different toString() output to its parent connection.
>>
>> That seems to be somewhat conflicting behaviour.
>>
>> - do we want the class name in the output? I would say no.
> 
> 
> Well, assuming that the user only ever sees a single type of connection 
> class in a given VM (either NetConnection or EmbedConnection), then this 
> would probably work, you would not get in the situation of having two 
> connections with the same toString() output.
> 
> But, now you've got me thinking... If you have two systems running in 
> different classloaders, you could still have non-unique ids.  :(
> 
> I guess this could be solved if I follow Jack's original suggestion and 
> used hashCode(), since this will be unique across all objects in a VM. 
> But personally a simple integer id is a lot easier to read in a log file 
> than a longer hex number, or an even longer decimal number...  The 
> connection id *could* be prepended with a system id, if such a thing 
> exists.
> 
> However, thinking even further ahead, if we ever had a clustered system 
> writing to a common log, even the Jack's identityHashCode solution would 
> not be unique :)  Which takes us back to a UUID.  What do you think, 
> should we worry about this or just worry about two systems in the same 
> VM for now?
> 
> Another thing that would be very nice is if, in client/server mode, 
> client connection toString() has a correlation to the resulting embedded 
> connection toString() created on the server side for that session.  This 
> way you could get end-to-end correlation.  I don't know if DRDA supports 
> this; if people think this is a good idea I can investigate...
> 
> Sigh, and I thought this would be a simple fix, silly me! :)
> 
> 
>>
>>
>> I would like to see that at some point the return from toString() could
>> be used to correlate the connection with information from a diagnostic
>> table (vti). For example the value of PreparedStatement.toString()
>> corresponds to the identifier column of the statement cache vti.
>> This then could be used in diagnostics to show something like all locks
>> for this connection.
>>
> 
> Sorry, what's "vti"?  This is a Derby acronym I have seen while browsing 
> the source, I *think* it means "virtual table" but I'm not sure...  Does 
> such a diagnostic table exist?  Where would I look to find one?
> 
> I looked at EmbedPreparedStatement.  Its toString() invokes 
> super.toString().  It's superclass is EmbedStatement, which has no 
> toString() defined, and its superclass is ConnectionChild, which has no 
> toString() defined.  So you end up with <classname>@<hashCode>.
> 
> However, further digging reveals diag.StatementCache.java refers to 
> GenericPreparedStatement.getObjectName(), which is a UUIDString.
> 
> At this point I must confess I am a bit lost.  I can't find the 
> relationship, BTW, between GenericPreparedStatement and 
> EmbedPreparedStatement, and I can't figure out how diag.StatementCache 
> is related to a VTI.  Any guidance would be most appreciated.
> 
> I guess my key question for this bug fix would be: what would I need to 
> do to ensure that the toString() from a connection can be used in a 
> diagnostic table?
> 
> Thanks,
> 
> David
> 
>>
>> Dan.
>>

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.

David Van Couvering wrote:

> I haven't heard any responses on this, so I am going to make the 
> following changes/actions.  Speak now or... speak later, I guess :)
> 
> - Use UUID to generate a unique id.  On the engine side I will use the 
> UUID service; on the client side I will use BasicUUID hardcoded.

To be clear, I am going to *copy* the BasicUUID class and make a 
duplicate in the org.apache.derby.client.am package.

> 
> - Remove toString() from PooledConnection and its subclasses in both 
> client and engine code, as this class is never seen by application code
> 
> - Add a JIRA entry to allow for code-sharing between client and engine
> 
> - Add a JIRA entry to add a connection id to appropriate VTIs, where the 
> id is the same as toString()
> 
> - Add a JIRA entry to add a new VTI that shows all active connections, 
> where the id is the same as toString().
> 
> Thanks,
> 
> David
> 
> David Van Couvering wrote:
> 
>>
>>
>> Daniel John Debrunner wrote:
>>
>>> David Van Couvering wrote:
>>>
>>>
>>>> Thanks for the quick reply, Dan, some responses below.
>>>>
>>>> Daniel John Debrunner wrote:
>>>>
>>>
>>>
>>>>> I'd like to see some crisper definition around what the return from
>>>>> toString() is meant to represent for a connection.
>>>>>
>>>>> - with this implementation, two different application connections from
>>>>> the same PooledConnection end up with the same toString() output,
>>>>> because the toString() of the underlying connection is used.
>>>>
>>>>
>>>>
>>>>
>>>> I am still learning about PooledConnection, not having dealt with this
>>>> before.  I thought that PooledConnection was an interface only used by
>>>> app servers and other containers implementing connection pools.  This
>>>> seems to match what I saw in my tests: regardless of what kind of 
>>>> access
>>>> mechanism I used (DriverManager, DataSource, 
>>>> ConnectionPoolDataSource or
>>>> XADataSource), I always ended up with an EmbedConnection30 or a
>>>> NetConnection being returned to the application, and never a
>>>> PooledConnection class.
>>>
>>>
>>>
>>>
>>> You are right, I was talking about the connection's returned to the
>>> application, with your code in this case connection a and b have the
>>> same id, where pc is a PooledConnection object.
>>>
>>> Connection a = pc.getConnection();
>>> // some work
>>> Connection b = pc.getConnection();
>>>
>>> Now I know a is closed once b is obtained, but if there share the same
>>> id then diagnostics might be confusing, as it will be impossible to tell
>>> the activity against connection a to that against connection b. Maybe
>>> that's ok, I'm not sure at the moment what you want the return from
>>> toString() to represent.
>>>
>>
>> OK, now I understand.  I think confusion is possible whatever approach 
>> we use.  If we generate a new connection id for the underlying 
>> connection each time pc.getConnection() gets called, then it could be 
>> very confusing if the same physical connection had a problem and we 
>> couldn't determine it was the same physical connection in the trace logs.
>>
>> At the same time, if two different apps get the same connection for 
>> two separate transactions, the person reading the log may get confused 
>> about what is happening.  But I think this is actually manageable -- 
>> as long as you understand that connection pooling is going on, you 
>> should be able to trace a given transaction even if the connection is 
>> then placed back on the pool and used by someone else.  I actually 
>> think the user might be more confused to see a new connection id for 
>> each transaction, as they might not understand that pooling is happening.
>>
>> So my recommendation is to stick with the current implementation and 
>> let an EmbedConnection keep the same id for its lifetime.  I also 
>> think I should just remove toString() from PooledConnection and its 
>> subclasses since its never seen by end users.
>>
>>>
>>>
>>>> [snap]
>>>>
>>>> I guess this could be solved if I follow Jack's original suggestion and
>>>> used hashCode(), since this will be unique across all objects in a VM.
>>>> But personally a simple integer id is a lot easier to read in a log 
>>>> file
>>>> than a longer hex number, or an even longer decimal number...  The
>>>> connection id *could* be prepended with a system id, if such a thing
>>>> exists.
>>>
>>>
>>>
>>>
>>> I thought we had decided that the hashCode was not guaranteed to be 
>>> unique.
>>>
>>
>> See my previous email, I had missed your email on this.  So, I agree, 
>> hashCode is out.
>>
>> That said, we need something that is unique across all classes *and* 
>> across classloaders and potentially even across VMs.  The only 
>> alternative I can think of is UUID.
>>
>> I've been thinking about the net client side as well.  Even there, we 
>> can't assume that all ids will be generated from the same classloader. 
>> It is more than possible that the net client could be embedded in an 
>> app server or other middle-tier container.  Since an app server 
>> normally has a different classloader for each application, we have to 
>> support an net client connection id that is unique across 
>> classloaders...  So that should probably be a UUID as well...
>>
>> That said, right now there is no way to share code such as 
>> UUIDFactory, UUID and BasicUUID.  If I don't fix this, then I'll be 
>> copying a fairly large chunk of code across packages.   It seems to me 
>> there are three ways I can go here:
>>
>> (1) Copy BasicUUID and deal with the code duplication for now.  Add a 
>> separate feature request to adjust our packaging and jars to allow for 
>> code shared across the client, tools and derby jar files (I'll call 
>> these "components" for lack of a better word).
>>
>> (2) As part of this patch, create a new jar file called 
>> derbycommon.jar for packages/classes that span two or more components 
>> of Derby.  Put BasicUUID in there.
>>
>> (3) Same as (2), except that the whole services architecture goes into 
>> common, not just BasicUUID.  I would prefer this from an architectural 
>> standpoint, but I'm a bit worried about memory bloat on the client side.
>>
>> For sanity's sake, I would like to suggest (1).  I think BasicUUID is 
>> stable enough that we'll be OK for the time being. But opinions here 
>> are much appreciated.
>>
>>
>> [snip]
>>
>>>> Another thing that would be very nice is if, in client/server mode,
>>>> client connection toString() has a correlation to the resulting 
>>>> embedded
>>>> connection toString() created on the server side for that session.  
>>>> This
>>>> way you could get end-to-end correlation.  I don't know if DRDA 
>>>> supports
>>>> this; if people think this is a good idea I can investigate...
>>>
>>>
>>>
>>>
>>> I think that is there, there is a drda id which I think fulfills that
>>> purpose.
>>>
>>
>> OK, I think this is also a separate feature request, do you agree?
>>
>> [snip]
>>
>>> StatementCache is a VTI, you can execute the statement
>>>
>>> select * from new org.apache.diag.StatementCache() AS SC
>>>
>>> to get a list of statements in the cache.
>>>
>>> And use a where clause to match the current statement to its cache entry
>>>  by using the output from toString() of the PreparedStatement.
>>
>>
>>
>> OK, I got it, thanks.
>>
>> What I propose to do here is to add two feature requests:
>>
>> - all VTIs that can be scoped by connection, such as StatementCache, 
>> LockTable, TransactionTable, etc.,  should add a new column for the 
>> owning connection id, which should match the output of toString().
>>
>> - a diagnostics table for active connections,where the connection 
>> identifier in this table should match the output of toString().
>>
>> Sound good?
>>
>> Thanks,
>>
>> David
>>
>>>
>>>
>>

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
Sounds reasonable, good point.

David

Bernt M. Johnsen wrote:

>>>>>>>>>>>>>David Van Couvering wrote (2005-05-12 15:17:09):
>>
>>
>>Kathey Marsden wrote:
>>
>>[snip]
>>
>>
>>>So maybe  something like:
>>>
>>>Physical Connection c013800d-0103-d219-2006-ffffe2f84f9d
>>
>>
>>Well, I like this, except that for application code, which is where the 
>>majority of debugging would take place when using Derby, it would 
>>*always* say "Physical Connection".  Only container developers would 
>>have access to and print out pooled connections.  So how about
>>
>>  Connection c013800d-0103-d219-2006-ffffe2f84f9d
>>
>>and
>>
>>  Pooled connection a7fd6554-0103-d219-2006-ffffe2f84f9d
> 
> 
> I would prefer
>    Connection_c013800d-0103-d219-2006-ffffe2f84f9d 
> and
>    PooledConnection_a7fd6554-0103-d219-2006-ffffe2f84f9d
> 
> Avoiding spaces will facilitate parsing of the string which is
> important in e.g. automated testing.
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "Bernt M. Johnsen" <Be...@Sun.COM>.
>>>>>>>>>>>> David Van Couvering wrote (2005-05-12 15:17:09):
> 
> 
> Kathey Marsden wrote:
> 
> [snip]
> 
> >So maybe  something like:
> > 
> >Physical Connection c013800d-0103-d219-2006-ffffe2f84f9d
> 
> 
> Well, I like this, except that for application code, which is where the 
> majority of debugging would take place when using Derby, it would 
> *always* say "Physical Connection".  Only container developers would 
> have access to and print out pooled connections.  So how about
> 
>   Connection c013800d-0103-d219-2006-ffffe2f84f9d
> 
> and
> 
>   Pooled connection a7fd6554-0103-d219-2006-ffffe2f84f9d

I would prefer
   Connection_c013800d-0103-d219-2006-ffffe2f84f9d 
and
   PooledConnection_a7fd6554-0103-d219-2006-ffffe2f84f9d

Avoiding spaces will facilitate parsing of the string which is
important in e.g. automated testing.

-- 
Bernt Marius Johnsen, Database Technology Group, 
Sun Microsystems, Trondheim, Norway

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Kathey Marsden <km...@sbcglobal.net>.
David Van Couvering wrote:
[snip]

>
> Well, I like this, except that for application code, which is where
> the majority of debugging would take place when using Derby, it would
> *always* say "Physical Connection".


Actually I just thought of it as more of a documentation feature
describing our new toString() behaviour, since the connection semantics
are subtle.   I thought, for instance, it might make it clearer for the
stored procedure (jdbc:default:connection)  case,  that we are reporting
the id for the parent connection and not a separate connection id.

Anyway, I better just wait for the patch and  really understand the new
toString() before I start worrying about descriptive names. 
"Connection" is ok with me for now.

Kathey



Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.

Kathey Marsden wrote:

[snip]

> So maybe  something like:
>  
> Physical Connection c013800d-0103-d219-2006-ffffe2f84f9d


Well, I like this, except that for application code, which is where the 
majority of debugging would take place when using Derby, it would 
*always* say "Physical Connection".  Only container developers would 
have access to and print out pooled connections.  So how about

   Connection c013800d-0103-d219-2006-ffffe2f84f9d

and

   Pooled connection a7fd6554-0103-d219-2006-ffffe2f84f9d

David

> 
> Would be clearer
> 
> Kathey
> 
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Kathey Marsden <km...@sbcglobal.net>.
David Van Couvering wrote:

>> Connection.toString() is  a pretty quick and dirty debugging
>> technique. If you call toString() to debug your connections  it would
>> be nice if the output made it obvious what it meant without going to
>> a manual.  
>
>
> The output is pretty straightforward, it tells you it is a connection
> and then prints out the UUID.  Here is an example:
>
> Connection c013800d-0103-d219-2006-ffffe2f84f9d
>
I think I finally found in one of the old mails what I was looking for
which was what this represents.

David wrote ..

>>In summary, each physical connection should have its own unique
>> connection id, regardless of how it is obtained by the application.


Dan wrote ...

>That's a good definition. And it means the nested connection would need
>to have same toString() value as its parent.


So maybe  something like:
 
Physical Connection c013800d-0103-d219-2006-ffffe2f84f9d

Would be clearer

Kathey



Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
Hi, Kathey, some responses below...

Kathey Marsden wrote:

> David Van Couvering wrote:
>
[snip]
> 
> 
>>So I have been motivated to do this "right."  I suspect using the
>>default toString would have been satisfactory, but the effort required
>>to do it "right" has been minimal once we figured out what "right" was.
> 
> 
> Did we figure that out yet?   
> 
> Could you give a brief summary of what  your  UUID means to the user
> when they see it?
> Connection.toString() is  a pretty quick and dirty debugging technique. 
> If you call toString() to debug your connections  it would be nice if 
> the output made it obvious what it meant without going to a manual.   
> 

The output is pretty straightforward, it tells you it is a connection 
and then prints out the UUID.  Here is an example:

Connection c013800d-0103-d219-2006-ffffe2f84f9d

I *did* notice that for a given run (I guess for the same VM instance), 
all but the first part of the UUID sequence are identical, for example, 
here is another connection in the same run

Connection 862e0071-0103-d219-2006-ffffe2f84f9d

This should make it easier to quickly identify a given connection when 
reading output.


> For more advanced debugging folks tend to use the derby.log and the
> ErrorLogVTI, so if this effort is to assist with advanced debugging,
> these  may be worth considering before connection toString() so that
> they can be hooked up in a meaningful way.

Yes, this was what Dan was talking about, that the VTIs should include a 
column with the connection string that allows you to quickly correlate 
more detailed information with a connection string you observed in your 
debug output.  I had proposed to make this a separate JIRA item.

> 
> I  wanted to also mention that currently in the derby.log for network
> server, we currently log a DRDAID which is the correlation token that I
> mentioned in my earlier mail. This id is a combination of the network
> address and the time in milliseconds and is something that is currently
> generated by the client but really should be generated by the server
> (DERBY-17).  Just wanted to make sure that was considered in your
> connection identification solution.  Not unique but certainly useful in
> debugging as you can see where the connection is coming from.  And as
> you mentioned it would be nice to have that correlation between client
> and server, but it is not a UUID.  Something to consider when you
> evaluate the id's we already have, as well as the new one, and how they
> all fit into the debugging  picture.

I think it would be great to allow you to correlate a client and 
server-side connection.

I am suggesting we log this as a separate JIRA item, to avoid piling too 
much into DERBY-243, which only asks that connection toString() be unique.

One approach would be that the toString() of an embedded connection 
created for a network session includes the DRDAID.  However, I think 
that makes the string output too complicated.  An alternate approach is 
to create a Connection VTI which includes this information.

The same thing can be said for PooledConnections -- they have a 
relationship to an underlying physical connection.  But rather than clog 
up the toString() of PooledConnection with the id of the underlying 
physical connection, I would rather see the Connection VTI provide this 
information.

> 
> I know I said hashcodes, counters, UUID's or whatever, but I am
> beginning to reconsider that position.   If we are looking at the big 
> connection identification picture,  I would like to understand what we
> have, what  the overall goals are and how what you are doing fits in
> with the existing id's.   Too many id's can be as bad as not enough.
>

I am not fully sure I know what you mean by "what we have", but in terms 
of connections, IMHO what we have currently is not sufficient -- a 
mishmash of the default toString() output, "" (returned by 
BrokeredConnection) and "EmbedConnection" for embedded connections.

To me the overall goal is to support debugging in critical situations, 
which means to me providing a toString() representation that is unique 
across any supported or envisioned usage models.  Given that this 
includes running in multiple classloaders (and I think this not going to 
be uncommon), and after much discussion about unique identifiers, I am 
convinced the righth approach is to use UUID.

In terms of how this fits with existing ids, I think the main thing that 
needs to be addressed is what we discussed above: that relevant VTIs 
include a correlation back to the owning connection so useful queries 
can be run, and that we make it possible correlate an embedded 
connection with its matching client-side connection.  I think both of 
these are beyond the scope of DERBY-243 but are worth working on as 
separate items.

So, once we have a unique connection identifier as a basis, I think 
there is a lot of opportunity here to provide some very useful detailed 
debugging information.

> 
> 
>>I think there's value in a simple fix bringing up a larger issue for
>>discussion.  I agree that you don't want to try and *fix* these larger
>>issues as part of the initial bug, rather they should be added as new
>>feature requests or bugs.  But I think they are healthy discussions to
>>have and can improve the overall design and quality of the product.
> 
> 
> Yes, I agree, but  I do think that it is good  to start a new thread for
> new issues.  Someone interested in  a proposal on changing the jar files
> we distribute  might not think to look under the connection toString
> thread. A new thread also provides more clear separation between the
> original issue and the larger issue it raised.  There is a lot of mail
> !    You might be interested in the Jakarta project mail guidelines and
> associated links at: http://jakarta.apache.org/site/mail.html.
> 

OK, thanks, that's valuable feedback.  I will definitely keep that in 
mind in the future.

What I can do in this instance is when I create separate JIRA items for 
the things beyond the scope of DERBY-243, I will include in the comments 
a link to this thread as well as a summary of what we discussed in this 
thread.

David

> Kathey
> 
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Kathey Marsden <km...@sbcglobal.net>.
David Van Couvering wrote:

> To me, my itch around this item is debugging, I have had to do a lot
> of this in the field, and missing something like a unique identifer
> for a connection can be pretty serious in terms of time spent trying
> to track down a bug, especially if the bug only rears it head in
> specific production situations, or it has only happened once but the
> impact was severe.
>
Good!   I am glad you are making all this effort  for your own
gratification #:)

> So I have been motivated to do this "right."  I suspect using the
> default toString would have been satisfactory, but the effort required
> to do it "right" has been minimal once we figured out what "right" was.

Did we figure that out yet?   

Could you give a brief summary of what  your  UUID means to the user
when they see it?
Connection.toString() is  a pretty quick and dirty debugging technique. 
If you call toString() to debug your connections  it would be nice if 
the output made it obvious what it meant without going to a manual.   

For more advanced debugging folks tend to use the derby.log and the
ErrorLogVTI, so if this effort is to assist with advanced debugging,
these  may be worth considering before connection toString() so that
they can be hooked up in a meaningful way.

I  wanted to also mention that currently in the derby.log for network
server, we currently log a DRDAID which is the correlation token that I
mentioned in my earlier mail. This id is a combination of the network
address and the time in milliseconds and is something that is currently
generated by the client but really should be generated by the server
(DERBY-17).  Just wanted to make sure that was considered in your
connection identification solution.  Not unique but certainly useful in
debugging as you can see where the connection is coming from.  And as
you mentioned it would be nice to have that correlation between client
and server, but it is not a UUID.  Something to consider when you
evaluate the id's we already have, as well as the new one, and how they
all fit into the debugging  picture.

I know I said hashcodes, counters, UUID's or whatever, but I am
beginning to reconsider that position.   If we are looking at the big 
connection identification picture,  I would like to understand what we
have, what  the overall goals are and how what you are doing fits in
with the existing id's.   Too many id's can be as bad as not enough.
 

>
> I think there's value in a simple fix bringing up a larger issue for
> discussion.  I agree that you don't want to try and *fix* these larger
> issues as part of the initial bug, rather they should be added as new
> feature requests or bugs.  But I think they are healthy discussions to
> have and can improve the overall design and quality of the product.

Yes, I agree, but  I do think that it is good  to start a new thread for
new issues.  Someone interested in  a proposal on changing the jar files
we distribute  might not think to look under the connection toString
thread. A new thread also provides more clear separation between the
original issue and the larger issue it raised.  There is a lot of mail
!    You might be interested in the Jakarta project mail guidelines and
associated links at: http://jakarta.apache.org/site/mail.html.

Kathey



Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Dibyendu Majumdar <di...@mazumdar.demon.co.uk>.
From: "David Van Couvering" <Da...@Sun.COM>
> To me, my itch around this item is debugging, I have had to do a lot of
> this in the field, and missing something like a unique identifer for a
> connection can be pretty serious in terms of time spent trying to track
> down a bug, especially if the bug only rears it head in specific
> production situations, or it has only happened once but the impact was
> severe.

Hi,

Just wanted to add that I have had similar problems when debugging code.
Recently, I was faced with a problem when in a multi-threaded environment,
the system would run fine for a while and then suddenly the threads would
start dying with XA errors. I logged Connection.toString() - and using this
log was able to step through what was happening to the connections.
I found that the problem always occurred if the connection object was used
by another thread in a different transaction, where the first transaction
association
had been ended, but the transaction had not yet reached completion.
That is, if I reused a connection after calling XAResurce.end() in a
different
thread, then it would fail.

BTW, this problem was in Oracle, I have not tried to test this situation in
Derby.

From: "Kathey Marsden" <km...@sbcglobal.net>
> For more advanced debugging folks tend to use the derby.log and the
> ErrorLogVTI, so if this effort is to assist with advanced debugging,
> these  may be worth considering before connection toString() so that
> they can be hooked up in a meaningful way

Can this kind of problem can be debugged using derby.log or ErrorLogVTI?

Regards



Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
Hi, Kathey, this is great feedback, thanks.

I get your point about the "scratch your own itch" model and basically 
keeping a patch focused on the initial description.

To me, my itch around this item is debugging, I have had to do a lot of 
this in the field, and missing something like a unique identifer for a 
connection can be pretty serious in terms of time spent trying to track 
down a bug, especially if the bug only rears it head in specific 
production situations, or it has only happened once but the impact was 
severe.

So I have been motivated to do this "right."  I suspect using the 
default toString would have been satisfactory, but the effort required 
to do it "right" has been minimal once we figured out what "right" was. 
  Most of this has been a lot of email discussion.  The actual code 
changes have been quite small and pretty manageable.  The issues around 
code sharing, VTIs, etc., that require larger code changes I do NOT want 
to do as part of this patch, and will be logging them as separate JIRA 
items.

I think there's value in a simple fix bringing up a larger issue for 
discussion.  I agree that you don't want to try and *fix* these larger 
issues as part of the initial bug, rather they should be added as new 
feature requests or bugs.  But I think they are healthy discussions to 
have and can improve the overall design and quality of the product.  One 
of the values of open source as I see it is that we can all see and 
discuss problems in the architecture or design and if someone wants to 
put in the effort to fix it, they can.

In terms of fixing what was intended to be fixed by the initial bug 
report, perhaps we should try to be more clear in our definition of the 
situation where the bug occurred and what the expected behavior is, as 
you are suggesting in this email.  This can be done with a reproduction, 
a background description in a comment, or a combination.  I can see a 
lot of potential for someone without the background of the person who 
who logged the bug to fix the wrong thing...

Thanks,

David

Kathey Marsden wrote:

> David Van Couvering wrote:
> 
> 
>>
>>Daniel John Debrunner wrote:
>>
>>
>>>David Van Couvering wrote:
>>>
>>>
>>>
>>>>I haven't heard any responses on this, so I am going to make the
>>>>following changes/actions.  Speak now or... speak later, I guess :)
>>>>
>>>>- Use UUID to generate a unique id.  On the engine side I will use the
>>>>UUID service; on the client side I will use BasicUUID hardcoded.
>>>
> 
> I  want to interject a little history here because I am concerned that I
> may have misled you  when I rephrased the issue description.  The
> original issue summary was something like "connection toString should
> provide more information".  The request came from a user that was using 
> the toString() method in development to help figure out which connection
> was which.
> When he did this he found that we have overloaded toString() with a
> method that just printed the class name. Here is the toString() from
> EmbedConnection.java
>  public    String    toString() { return "EmbedConnection"; }
> 
> So the user filed this request for more information on
> Connection.toString()  perhaps with an implied, "Why would you override
> the toString() method to provide *less* information?"  I transferred the
> case to Jira,  thinking probably someone else would find our toString()
> implementation irritating and would want to fix it.
> 
> Looking at the case originally, I kind of figured that probably we had
> overridden the toString() method to address some testing concern that
> stemmed out of our diff based tests.  I figured if I were to look at
> this case I would probably just write a test to perform toString() on 
> all different flavors of connections,  embedded, client, connections
> obtained from pooled and xa connections, jdbc:default connections in
> stored procedures, etc and figure out what we were doing for toString()
> in all the cases.  Then in the end I would have hoped to just rip out
> that toString() override and resolve whatever testing concern caused it
> to be there in the first place.  That way we would just be using the
> default toString() implementation which is pretty well defined  in any
> scenario and certainly would provide *more* information without a lot of
> work.
> 
> When Dan suggested that I clarify the bug, I  changed the description to
> "connection toString should uniquely identify the connection"   but to
> tell you the truth now I think the original summary was probably just
> fine, because it communicated the fact that our toString()
> implementation should provide *more* information than the default
> toString() implementation and not *less*.     I couldn't say much about
> where I thought the testing above might lead and whether in fact in the
> end we could just use the default toString()  method, because I'd really
> have to do the analysis to find out.  so I thought that description
> would be more generic  but instead, my description  if taken as a
> mandate, forces us to
>      - Define and lock in to some definition of a  unique connection.
>      - Think about how to generate unique identifiers, in the context of
> class loaders,  client server environments,
>         clustered evironments etc.
>      - Think about code sharing between client and server.
>      - Think about the existing VTI's such as the ErrorLogReader VTI and
> perhaps new VTI's
>      - Analyze  the exisisting ID's that we have
>       - Consider the ease of use factor.  
>      - Consider the documentation impact of doing all this.
>        ......I don't know what else
> 
> All of a sudden we have a major engineering effort which is maybe a
> great thing if all of this is important to you, but I wouldn't want
> DERBY-243 to be the cart that pulls this horse.  If we are going down
> that road I think it requires a more comprehensive analysis of all the
> implications and dependencies than an ad hoc email conversation can
> provide.  But I just keep wondering if such a thing is really that
> important to anyone right now.
> 
> So I would like to reword the description again. What do you  think of a
> new summary for this issue?
> 
>     "Connection.toString() should help identify the connection"
> 
> With description:
> The Derby toString() implementation on connections overrides the default
> toString() implementation and prints only the class name.  This means it
> is not helpful in differentiating one connection from another.  It is
> not clear why we do this. It may just be a testing concern, but it does
> not seem to make sense that our  Connection.toString() provides less
> information than the default toString() implementation and not more. 
> Even the default toString() implementation would  be more helpful.
> 
> 
> I think in general,  when fixing a Jira issue, especially if it is
> non-standard behavioiur  it is good to consider that anyone can file any
> issue for any reason.    Often Jira entries can just be perceptions from
> some user, or someone else's idea of what might be good.  You should
> pick it up and fix it if you need it or if you think it would be a
> really good thing for Derby. Maybe it just will give you an idea of a
> more useful thing.   If  your idea doesn't mesh with the original Jira
> entry, just leave the original one alone and file another for the useful
> thing that you are actually doing.  I don't think it is good to look at
> these requests as specific user requirements that need to be filled.  
> Open source uses a "Scratch your own itch"  model which is a little hard
> to adjust to but I think is pretty healthy in terms of keeping the
> changes useful and modulate the effort/return ratio.  In this case the
> new description might have been misleading but it is up to you to decide
> how much you want to do with it.  You might want to consider what you
> think would be useful and worth the effort for Connection.toString(),
> knowing that trying to go for a truly unique identifier and defining a
> unique connection has all these potential implications.   
> 
>  I think if it were me I would ..
>     1) Try out  different types of connection scenarios to see what we
> currently print.
>          Hopefully it is just the default toString().
>     2) If everywhere we are just printing the default toString() or our
> silly override, just  get  rid of our silly override.
>     3) Address the resulting test diffs with a <test>_sed.properties file.
>      4) Go on to the next thing
> 
> But as my mother in law used to say,  "Little things for little
> minds".   This is just a description of what I would do, not what you
> should do.  I just want to make sure you aren't going to this huge
> unique connection, unique identifier journey on my behalf.
> 
> Kathey
> 
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Kathey Marsden <km...@sbcglobal.net>.
David Van Couvering wrote:

>
>
> Daniel John Debrunner wrote:
>
>> David Van Couvering wrote:
>>
>>
>>> I haven't heard any responses on this, so I am going to make the
>>> following changes/actions.  Speak now or... speak later, I guess :)
>>>
>>> - Use UUID to generate a unique id.  On the engine side I will use the
>>> UUID service; on the client side I will use BasicUUID hardcoded.
>>

I  want to interject a little history here because I am concerned that I
may have misled you  when I rephrased the issue description.  The
original issue summary was something like "connection toString should
provide more information".  The request came from a user that was using 
the toString() method in development to help figure out which connection
was which.
When he did this he found that we have overloaded toString() with a
method that just printed the class name. Here is the toString() from
EmbedConnection.java
 public    String    toString() { return "EmbedConnection"; }

So the user filed this request for more information on
Connection.toString()  perhaps with an implied, "Why would you override
the toString() method to provide *less* information?"  I transferred the
case to Jira,  thinking probably someone else would find our toString()
implementation irritating and would want to fix it.

Looking at the case originally, I kind of figured that probably we had
overridden the toString() method to address some testing concern that
stemmed out of our diff based tests.  I figured if I were to look at
this case I would probably just write a test to perform toString() on 
all different flavors of connections,  embedded, client, connections
obtained from pooled and xa connections, jdbc:default connections in
stored procedures, etc and figure out what we were doing for toString()
in all the cases.  Then in the end I would have hoped to just rip out
that toString() override and resolve whatever testing concern caused it
to be there in the first place.  That way we would just be using the
default toString() implementation which is pretty well defined  in any
scenario and certainly would provide *more* information without a lot of
work.

When Dan suggested that I clarify the bug, I  changed the description to
"connection toString should uniquely identify the connection"   but to
tell you the truth now I think the original summary was probably just
fine, because it communicated the fact that our toString()
implementation should provide *more* information than the default
toString() implementation and not *less*.     I couldn't say much about
where I thought the testing above might lead and whether in fact in the
end we could just use the default toString()  method, because I'd really
have to do the analysis to find out.  so I thought that description
would be more generic  but instead, my description  if taken as a
mandate, forces us to
     - Define and lock in to some definition of a  unique connection.
     - Think about how to generate unique identifiers, in the context of
class loaders,  client server environments,
        clustered evironments etc.
     - Think about code sharing between client and server.
     - Think about the existing VTI's such as the ErrorLogReader VTI and
perhaps new VTI's
     - Analyze  the exisisting ID's that we have
      - Consider the ease of use factor.  
     - Consider the documentation impact of doing all this.
       ......I don't know what else

All of a sudden we have a major engineering effort which is maybe a
great thing if all of this is important to you, but I wouldn't want
DERBY-243 to be the cart that pulls this horse.  If we are going down
that road I think it requires a more comprehensive analysis of all the
implications and dependencies than an ad hoc email conversation can
provide.  But I just keep wondering if such a thing is really that
important to anyone right now.

So I would like to reword the description again. What do you  think of a
new summary for this issue?

    "Connection.toString() should help identify the connection"

With description:
The Derby toString() implementation on connections overrides the default
toString() implementation and prints only the class name.  This means it
is not helpful in differentiating one connection from another.  It is
not clear why we do this. It may just be a testing concern, but it does
not seem to make sense that our  Connection.toString() provides less
information than the default toString() implementation and not more. 
Even the default toString() implementation would  be more helpful.


I think in general,  when fixing a Jira issue, especially if it is
non-standard behavioiur  it is good to consider that anyone can file any
issue for any reason.    Often Jira entries can just be perceptions from
some user, or someone else's idea of what might be good.  You should
pick it up and fix it if you need it or if you think it would be a
really good thing for Derby. Maybe it just will give you an idea of a
more useful thing.   If  your idea doesn't mesh with the original Jira
entry, just leave the original one alone and file another for the useful
thing that you are actually doing.  I don't think it is good to look at
these requests as specific user requirements that need to be filled.  
Open source uses a "Scratch your own itch"  model which is a little hard
to adjust to but I think is pretty healthy in terms of keeping the
changes useful and modulate the effort/return ratio.  In this case the
new description might have been misleading but it is up to you to decide
how much you want to do with it.  You might want to consider what you
think would be useful and worth the effort for Connection.toString(),
knowing that trying to go for a truly unique identifier and defining a
unique connection has all these potential implications.   

 I think if it were me I would ..
    1) Try out  different types of connection scenarios to see what we
currently print.
         Hopefully it is just the default toString().
    2) If everywhere we are just printing the default toString() or our
silly override, just  get  rid of our silly override.
    3) Address the resulting test diffs with a <test>_sed.properties file.
     4) Go on to the next thing

But as my mother in law used to say,  "Little things for little
minds".   This is just a description of what I would do, not what you
should do.  I just want to make sure you aren't going to this huge
unique connection, unique identifier journey on my behalf.

Kathey



Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Daniel John Debrunner <dj...@debrunners.com>.
David Van Couvering wrote:

> That said, if I understand things correctly, the BrokeredConnection is
> mostly a proxy to catch things like Connection.close(), and that the
> right thing to do in this case is return the toString() of the
> underlying EmbedConnection.   We should always delegate to the actual
> physical database connection, just like BrokeredConnection does for
> everything else.

Yes, though I would add a little more weight behind what
BrokeredConnection is for. It's main role is to provide a unique logical
connection object for the application.

In Derby both the logical connection and the physical connection are
represented by Connection objects, which can confuse the issue.

Dan.



Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.

Daniel John Debrunner wrote:

> David Van Couvering wrote:
> 
>>
>>Daniel John Debrunner wrote:
> 
> 
>>>- Connections returned from jdbc:default:connection?
>>>  Unique string or string of parent connection?
>>
>>
>>I'm not sure what you mean by "parent connection.".  Is this a
>>class-hierarchy relationship or some other kind of relationship?  Each
>>physical connection should have its own unique connection string.  If it
>>is a subclass of another connection class, it will inherit the code to
>>obtain a connection id, but the instance will have its own independent
>>string.
> 
> 
> This is a nested connection, as defined by the SQL spec. Used within
> server-side JDBC code to obtain a connection object that is in the
> transaction space of the Connection calling the Java procedure or
> function. If you look at the jdbcapi/checkDataSource test you can
> procedure calls that obtain a connection using the JDBC URL
> jdbc:default:connection. Or procedures called from the lang/procedures test.
>

Ah, OK, I understand.  I had forgotten about accessing connections from 
stored procedures.  I should add this to my test changes, make sure that 
a valid, unique string is coming out of a connection obtained from 
jdbc:default:connection.

> 
>>Well, I discussed this in my previous email, and argued that a
>>NetConnection or EmbedConnection (which is what is returned from
>>PooledConnection.getConnection()) should have a single id that lasts the
>>lifetime of the instance.  If two separate transacations in separate
>>threads get the same underlying EmbedConnection or NetConnection from a
>>PooledConnection, then they will have the same id.  This actually seemed
>>good -- it's more accurate and does not hide the reality of connection
>>pooling.
> 
> 
> Technically EmbedConnection objects are not returned from
> PooledConnection.getConnection. Instead a EmbedConnection object wrapped
> by a BrokeredConnection is returned. The EmbedConnection is the physical
> connection and the BrokeredConnection is the logical Connection object.
> 

OK, thanks.  I should just draw a picture on my whiteboard, except that 
I'm in a different office each day :)

That said, if I understand things correctly, the BrokeredConnection is 
mostly a proxy to catch things like Connection.close(), and that the 
right thing to do in this case is return the toString() of the 
underlying EmbedConnection.   We should always delegate to the actual 
physical database connection, just like BrokeredConnection does for 
everything else.

I'll assume I got this right; let me know if you disagree.

> 
>>In summary, each physical connection should have its own unique
>>connection id, regardless of how it is obtained by the application.
> 
> 
> That's a good definition. And it means the nested connection would need
> to have same toString() value as its parent.
> 
> OK

OK :)

I'll give this another go.

David
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Daniel John Debrunner <dj...@debrunners.com>.
David Van Couvering wrote:
> 
> 
> Daniel John Debrunner wrote:

>>
>> - Connections returned from jdbc:default:connection?
>>   Unique string or string of parent connection?
> 
> 
> I'm not sure what you mean by "parent connection.".  Is this a
> class-hierarchy relationship or some other kind of relationship?  Each
> physical connection should have its own unique connection string.  If it
> is a subclass of another connection class, it will inherit the code to
> obtain a connection id, but the instance will have its own independent
> string.

This is a nested connection, as defined by the SQL spec. Used within
server-side JDBC code to obtain a connection object that is in the
transaction space of the Connection calling the Java procedure or
function. If you look at the jdbcapi/checkDataSource test you can
procedure calls that obtain a connection using the JDBC URL
jdbc:default:connection. Or procedures called from the lang/procedures test.

> Well, I discussed this in my previous email, and argued that a
> NetConnection or EmbedConnection (which is what is returned from
> PooledConnection.getConnection()) should have a single id that lasts the
> lifetime of the instance.  If two separate transacations in separate
> threads get the same underlying EmbedConnection or NetConnection from a
> PooledConnection, then they will have the same id.  This actually seemed
> good -- it's more accurate and does not hide the reality of connection
> pooling.

Technically EmbedConnection objects are not returned from
PooledConnection.getConnection. Instead a EmbedConnection object wrapped
by a BrokeredConnection is returned. The EmbedConnection is the physical
connection and the BrokeredConnection is the logical Connection object.

> In summary, each physical connection should have its own unique
> connection id, regardless of how it is obtained by the application.

That's a good definition. And it means the nested connection would need
to have same toString() value as its parent.

OK


Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.

Daniel John Debrunner wrote:

> David Van Couvering wrote:
> 
> 
>>I haven't heard any responses on this, so I am going to make the
>>following changes/actions.  Speak now or... speak later, I guess :)
>>
>>- Use UUID to generate a unique id.  On the engine side I will use the
>>UUID service; on the client side I will use BasicUUID hardcoded.
> 
> 
> Sounds fine, but what still is the uniqueness of the string in just the
> *simple* cases, never mind the multiple class loaders, multiple jvms etc?

Apologies if I wasn't clear about this.  In my previous email, I argued 
that even in a "simple" case such as the network client, you can 
regularly be running in multiple classloaders (e.g. when Derby is 
running in an app server container).  So, rather than make this a 
configurable option where users have to figure out when they need use 
UUIDs, I was just going to use UUID all the time.

> 
> - Connections returned from jdbc:default:connection?
>   Unique string or string of parent connection?

I'm not sure what you mean by "parent connection.".  Is this a 
class-hierarchy relationship or some other kind of relationship?  Each 
physical connection should have its own unique connection string.  If it 
is a subclass of another connection class, it will inherit the code to 
obtain a connection id, but the instance will have its own independent 
string.

> 
> - subsequent application connections returned from
> PooledConnection.getConnection() - Unique I hope.

Well, I discussed this in my previous email, and argued that a 
NetConnection or EmbedConnection (which is what is returned from 
PooledConnection.getConnection()) should have a single id that lasts the 
lifetime of the instance.  If two separate transacations in separate 
threads get the same underlying EmbedConnection or NetConnection from a 
PooledConnection, then they will have the same id.  This actually seemed 
good -- it's more accurate and does not hide the reality of connection 
pooling.

In summary, each physical connection should have its own unique 
connection id, regardless of how it is obtained by the application.

The alternative is to "regenerate" a new id each time a connection is 
pulled off of the pool, but this seemed to create a concept of a 
"virtual" connection that only lasts the lifetime of a transaction. 
This just doesn't seem right...

David

> 
> Dan.
> 
> 
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Daniel John Debrunner <dj...@debrunners.com>.
David Van Couvering wrote:

> I haven't heard any responses on this, so I am going to make the
> following changes/actions.  Speak now or... speak later, I guess :)
> 
> - Use UUID to generate a unique id.  On the engine side I will use the
> UUID service; on the client side I will use BasicUUID hardcoded.

Sounds fine, but what still is the uniqueness of the string in just the
*simple* cases, never mind the multiple class loaders, multiple jvms etc?

- Connections returned from jdbc:default:connection?
  Unique string or string of parent connection?

- subsequent application connections returned from
PooledConnection.getConnection() - Unique I hope.

Dan.




Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
I haven't heard any responses on this, so I am going to make the 
following changes/actions.  Speak now or... speak later, I guess :)

- Use UUID to generate a unique id.  On the engine side I will use the 
UUID service; on the client side I will use BasicUUID hardcoded.

- Remove toString() from PooledConnection and its subclasses in both 
client and engine code, as this class is never seen by application code

- Add a JIRA entry to allow for code-sharing between client and engine

- Add a JIRA entry to add a connection id to appropriate VTIs, where the 
id is the same as toString()

- Add a JIRA entry to add a new VTI that shows all active connections, 
where the id is the same as toString().

Thanks,

David

David Van Couvering wrote:

> 
> 
> Daniel John Debrunner wrote:
> 
>> David Van Couvering wrote:
>>
>>
>>> Thanks for the quick reply, Dan, some responses below.
>>>
>>> Daniel John Debrunner wrote:
>>>
>>
>>
>>>> I'd like to see some crisper definition around what the return from
>>>> toString() is meant to represent for a connection.
>>>>
>>>> - with this implementation, two different application connections from
>>>> the same PooledConnection end up with the same toString() output,
>>>> because the toString() of the underlying connection is used.
>>>
>>>
>>>
>>> I am still learning about PooledConnection, not having dealt with this
>>> before.  I thought that PooledConnection was an interface only used by
>>> app servers and other containers implementing connection pools.  This
>>> seems to match what I saw in my tests: regardless of what kind of access
>>> mechanism I used (DriverManager, DataSource, ConnectionPoolDataSource or
>>> XADataSource), I always ended up with an EmbedConnection30 or a
>>> NetConnection being returned to the application, and never a
>>> PooledConnection class.
>>
>>
>>
>> You are right, I was talking about the connection's returned to the
>> application, with your code in this case connection a and b have the
>> same id, where pc is a PooledConnection object.
>>
>> Connection a = pc.getConnection();
>> // some work
>> Connection b = pc.getConnection();
>>
>> Now I know a is closed once b is obtained, but if there share the same
>> id then diagnostics might be confusing, as it will be impossible to tell
>> the activity against connection a to that against connection b. Maybe
>> that's ok, I'm not sure at the moment what you want the return from
>> toString() to represent.
>>
> 
> OK, now I understand.  I think confusion is possible whatever approach 
> we use.  If we generate a new connection id for the underlying 
> connection each time pc.getConnection() gets called, then it could be 
> very confusing if the same physical connection had a problem and we 
> couldn't determine it was the same physical connection in the trace logs.
> 
> At the same time, if two different apps get the same connection for two 
> separate transactions, the person reading the log may get confused about 
> what is happening.  But I think this is actually manageable -- as long 
> as you understand that connection pooling is going on, you should be 
> able to trace a given transaction even if the connection is then placed 
> back on the pool and used by someone else.  I actually think the user 
> might be more confused to see a new connection id for each transaction, 
> as they might not understand that pooling is happening.
> 
> So my recommendation is to stick with the current implementation and let 
> an EmbedConnection keep the same id for its lifetime.  I also think I 
> should just remove toString() from PooledConnection and its subclasses 
> since its never seen by end users.
> 
>>
>>
>>> [snap]
>>>
>>> I guess this could be solved if I follow Jack's original suggestion and
>>> used hashCode(), since this will be unique across all objects in a VM.
>>> But personally a simple integer id is a lot easier to read in a log file
>>> than a longer hex number, or an even longer decimal number...  The
>>> connection id *could* be prepended with a system id, if such a thing
>>> exists.
>>
>>
>>
>> I thought we had decided that the hashCode was not guaranteed to be 
>> unique.
>>
> 
> See my previous email, I had missed your email on this.  So, I agree, 
> hashCode is out.
> 
> That said, we need something that is unique across all classes *and* 
> across classloaders and potentially even across VMs.  The only 
> alternative I can think of is UUID.
> 
> I've been thinking about the net client side as well.  Even there, we 
> can't assume that all ids will be generated from the same classloader. 
> It is more than possible that the net client could be embedded in an app 
> server or other middle-tier container.  Since an app server normally has 
> a different classloader for each application, we have to support an net 
> client connection id that is unique across classloaders...  So that 
> should probably be a UUID as well...
> 
> That said, right now there is no way to share code such as UUIDFactory, 
> UUID and BasicUUID.  If I don't fix this, then I'll be copying a fairly 
> large chunk of code across packages.   It seems to me there are three 
> ways I can go here:
> 
> (1) Copy BasicUUID and deal with the code duplication for now.  Add a 
> separate feature request to adjust our packaging and jars to allow for 
> code shared across the client, tools and derby jar files (I'll call 
> these "components" for lack of a better word).
> 
> (2) As part of this patch, create a new jar file called derbycommon.jar 
> for packages/classes that span two or more components of Derby.  Put 
> BasicUUID in there.
> 
> (3) Same as (2), except that the whole services architecture goes into 
> common, not just BasicUUID.  I would prefer this from an architectural 
> standpoint, but I'm a bit worried about memory bloat on the client side.
> 
> For sanity's sake, I would like to suggest (1).  I think BasicUUID is 
> stable enough that we'll be OK for the time being. But opinions here are 
> much appreciated.
> 
> 
> [snip]
> 
>>> Another thing that would be very nice is if, in client/server mode,
>>> client connection toString() has a correlation to the resulting embedded
>>> connection toString() created on the server side for that session.  This
>>> way you could get end-to-end correlation.  I don't know if DRDA supports
>>> this; if people think this is a good idea I can investigate...
>>
>>
>>
>> I think that is there, there is a drda id which I think fulfills that
>> purpose.
>>
> 
> OK, I think this is also a separate feature request, do you agree?
> 
> [snip]
> 
>> StatementCache is a VTI, you can execute the statement
>>
>> select * from new org.apache.diag.StatementCache() AS SC
>>
>> to get a list of statements in the cache.
>>
>> And use a where clause to match the current statement to its cache entry
>>  by using the output from toString() of the PreparedStatement.
> 
> 
> OK, I got it, thanks.
> 
> What I propose to do here is to add two feature requests:
> 
> - all VTIs that can be scoped by connection, such as StatementCache, 
> LockTable, TransactionTable, etc.,  should add a new column for the 
> owning connection id, which should match the output of toString().
> 
> - a diagnostics table for active connections,where the connection 
> identifier in this table should match the output of toString().
> 
> Sound good?
> 
> Thanks,
> 
> David
> 
>>
>>
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.

Daniel John Debrunner wrote:

> David Van Couvering wrote:
> 
> 
>>Thanks for the quick reply, Dan, some responses below.
>>
>>Daniel John Debrunner wrote:
>>
> 
> 
>>>I'd like to see some crisper definition around what the return from
>>>toString() is meant to represent for a connection.
>>>
>>>- with this implementation, two different application connections from
>>>the same PooledConnection end up with the same toString() output,
>>>because the toString() of the underlying connection is used.
>>
>>
>>I am still learning about PooledConnection, not having dealt with this
>>before.  I thought that PooledConnection was an interface only used by
>>app servers and other containers implementing connection pools.  This
>>seems to match what I saw in my tests: regardless of what kind of access
>>mechanism I used (DriverManager, DataSource, ConnectionPoolDataSource or
>>XADataSource), I always ended up with an EmbedConnection30 or a
>>NetConnection being returned to the application, and never a
>>PooledConnection class.
> 
> 
> You are right, I was talking about the connection's returned to the
> application, with your code in this case connection a and b have the
> same id, where pc is a PooledConnection object.
> 
> Connection a = pc.getConnection();
> // some work
> Connection b = pc.getConnection();
> 
> Now I know a is closed once b is obtained, but if there share the same
> id then diagnostics might be confusing, as it will be impossible to tell
> the activity against connection a to that against connection b. Maybe
> that's ok, I'm not sure at the moment what you want the return from
> toString() to represent.
> 

OK, now I understand.  I think confusion is possible whatever approach 
we use.  If we generate a new connection id for the underlying 
connection each time pc.getConnection() gets called, then it could be 
very confusing if the same physical connection had a problem and we 
couldn't determine it was the same physical connection in the trace logs.

At the same time, if two different apps get the same connection for two 
separate transactions, the person reading the log may get confused about 
what is happening.  But I think this is actually manageable -- as long 
as you understand that connection pooling is going on, you should be 
able to trace a given transaction even if the connection is then placed 
back on the pool and used by someone else.  I actually think the user 
might be more confused to see a new connection id for each transaction, 
as they might not understand that pooling is happening.

So my recommendation is to stick with the current implementation and let 
an EmbedConnection keep the same id for its lifetime.  I also think I 
should just remove toString() from PooledConnection and its subclasses 
since its never seen by end users.

> 
> 
>>[snap]
>>
>>I guess this could be solved if I follow Jack's original suggestion and
>>used hashCode(), since this will be unique across all objects in a VM.
>>But personally a simple integer id is a lot easier to read in a log file
>>than a longer hex number, or an even longer decimal number...  The
>>connection id *could* be prepended with a system id, if such a thing
>>exists.
> 
> 
> I thought we had decided that the hashCode was not guaranteed to be unique.
>

See my previous email, I had missed your email on this.  So, I agree, 
hashCode is out.

That said, we need something that is unique across all classes *and* 
across classloaders and potentially even across VMs.  The only 
alternative I can think of is UUID.

I've been thinking about the net client side as well.  Even there, we 
can't assume that all ids will be generated from the same classloader. 
It is more than possible that the net client could be embedded in an app 
server or other middle-tier container.  Since an app server normally has 
a different classloader for each application, we have to support an net 
client connection id that is unique across classloaders...  So that 
should probably be a UUID as well...

That said, right now there is no way to share code such as UUIDFactory, 
UUID and BasicUUID.  If I don't fix this, then I'll be copying a fairly 
large chunk of code across packages.   It seems to me there are three 
ways I can go here:

(1) Copy BasicUUID and deal with the code duplication for now.  Add a 
separate feature request to adjust our packaging and jars to allow for 
code shared across the client, tools and derby jar files (I'll call 
these "components" for lack of a better word).

(2) As part of this patch, create a new jar file called derbycommon.jar 
for packages/classes that span two or more components of Derby.  Put 
BasicUUID in there.

(3) Same as (2), except that the whole services architecture goes into 
common, not just BasicUUID.  I would prefer this from an architectural 
standpoint, but I'm a bit worried about memory bloat on the client side.

For sanity's sake, I would like to suggest (1).  I think BasicUUID is 
stable enough that we'll be OK for the time being. But opinions here are 
much appreciated.


[snip]

>>Another thing that would be very nice is if, in client/server mode,
>>client connection toString() has a correlation to the resulting embedded
>>connection toString() created on the server side for that session.  This
>>way you could get end-to-end correlation.  I don't know if DRDA supports
>>this; if people think this is a good idea I can investigate...
> 
> 
> I think that is there, there is a drda id which I think fulfills that
> purpose.
> 

OK, I think this is also a separate feature request, do you agree?

[snip]

> StatementCache is a VTI, you can execute the statement
> 
> select * from new org.apache.diag.StatementCache() AS SC
> 
> to get a list of statements in the cache.
> 
> And use a where clause to match the current statement to its cache entry
>  by using the output from toString() of the PreparedStatement.

OK, I got it, thanks.

What I propose to do here is to add two feature requests:

- all VTIs that can be scoped by connection, such as StatementCache, 
LockTable, TransactionTable, etc.,  should add a new column for the 
owning connection id, which should match the output of toString().

- a diagnostics table for active connections,where the connection 
identifier in this table should match the output of toString().

Sound good?

Thanks,

David

> 
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Daniel John Debrunner <dj...@debrunners.com>.
David Van Couvering wrote:

> Thanks for the quick reply, Dan, some responses below.
> 
> Daniel John Debrunner wrote:
> 

>> I'd like to see some crisper definition around what the return from
>> toString() is meant to represent for a connection.
>>
>> - with this implementation, two different application connections from
>> the same PooledConnection end up with the same toString() output,
>> because the toString() of the underlying connection is used.
> 
> 
> I am still learning about PooledConnection, not having dealt with this
> before.  I thought that PooledConnection was an interface only used by
> app servers and other containers implementing connection pools.  This
> seems to match what I saw in my tests: regardless of what kind of access
> mechanism I used (DriverManager, DataSource, ConnectionPoolDataSource or
> XADataSource), I always ended up with an EmbedConnection30 or a
> NetConnection being returned to the application, and never a
> PooledConnection class.

You are right, I was talking about the connection's returned to the
application, with your code in this case connection a and b have the
same id, where pc is a PooledConnection object.

Connection a = pc.getConnection();
// some work
Connection b = pc.getConnection();

Now I know a is closed once b is obtained, but if there share the same
id then diagnostics might be confusing, as it will be impossible to tell
the activity against connection a to that against connection b. Maybe
that's ok, I'm not sure at the moment what you want the return from
toString() to represent.


> [snap]
> 
> I guess this could be solved if I follow Jack's original suggestion and
> used hashCode(), since this will be unique across all objects in a VM.
> But personally a simple integer id is a lot easier to read in a log file
> than a longer hex number, or an even longer decimal number...  The
> connection id *could* be prepended with a system id, if such a thing
> exists.

I thought we had decided that the hashCode was not guaranteed to be unique.


> However, thinking even further ahead, if we ever had a clustered system
> writing to a common log, even the Jack's identityHashCode solution would
> not be unique :)  Which takes us back to a UUID.  What do you think,
> should we worry about this or just worry about two systems in the same
> VM for now?
> 
> Another thing that would be very nice is if, in client/server mode,
> client connection toString() has a correlation to the resulting embedded
> connection toString() created on the server side for that session.  This
> way you could get end-to-end correlation.  I don't know if DRDA supports
> this; if people think this is a good idea I can investigate...

I think that is there, there is a drda id which I think fulfills that
purpose.

> Sigh, and I thought this would be a simple fix, silly me! :)

Sad thing is, with an eight year old project, all the easy fixes have
been done already. :-(


>> I would like to see that at some point the return from toString() could
>> be used to correlate the connection with information from a diagnostic
>> table (vti). For example the value of PreparedStatement.toString()
>> corresponds to the identifier column of the statement cache vti.
>> This then could be used in diagnostics to show something like all locks
>> for this connection.
>>
> 
> Sorry, what's "vti"?  This is a Derby acronym I have seen while browsing
> the source, I *think* it means "virtual table" but I'm not sure...  Does
> such a diagnostic table exist?  Where would I look to find one?

Virtual Table Interfacce, see the classes in org.apache.derby.diag

> 
> I looked at EmbedPreparedStatement.  Its toString() invokes
> super.toString().  It's superclass is EmbedStatement, which has no
> toString() defined, and its superclass is ConnectionChild, which has no
> toString() defined.  So you end up with <classname>@<hashCode>.

No, you missed some code in EmbedPreparedStatement.toString(), if it
has an activation, then it returns a value from its language prepared
statement.
> 
> However, further digging reveals diag.StatementCache.java refers to
> GenericPreparedStatement.getObjectName(), which is a UUIDString.
> 
> At this point I must confess I am a bit lost.  I can't find the
> relationship, BTW, between GenericPreparedStatement and
> EmbedPreparedStatement, and I can't figure out how diag.StatementCache
> is related to a VTI.  Any guidance would be most appreciated.

StatementCache is a VTI, you can execute the statement

select * from new org.apache.diag.StatementCache() AS SC

to get a list of statements in the cache.

And use a where clause to match the current statement to its cache entry
 by using the output from toString() of the PreparedStatement.



Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
Thanks for the quick reply, Dan, some responses below.

Daniel John Debrunner wrote:

> David Van Couvering (JIRA) wrote:
> 
> 
>>     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]
>>
>>David Van Couvering updated DERBY-243:
>>--------------------------------------
>>
>>    Attachment: DERBY-243.diff
>>
>>I am attaching the patch that should resolve this bug.  I added toString() to the
>>appropriate connection classes and updated the dataSourcePermissions.java and 
>>dataSourcePermissions_net.java tests to test toString().  I mostly just verify
>>that two connections do not have the same string and follow the expected 
>>pattern.  I had to "sed" out the actual connection ids in the output so we
>>could guarantee a pass even if the ids change.
> 
> 
> I'd like to see some crisper definition around what the return from
> toString() is meant to represent for a connection.
> 
> - with this implementation, two different application connections from
> the same PooledConnection end up with the same toString() output,
> because the toString() of the underlying connection is used.

I am still learning about PooledConnection, not having dealt with this 
before.  I thought that PooledConnection was an interface only used by 
app servers and other containers implementing connection pools.  This 
seems to match what I saw in my tests: regardless of what kind of access 
mechanism I used (DriverManager, DataSource, ConnectionPoolDataSource or 
XADataSource), I always ended up with an EmbedConnection30 or a 
NetConnection being returned to the application, and never a 
PooledConnection class.

It is true that multiple sessions in an app server using connection 
pooling will often get the same connection through the lifetime of the 
container VM.  However, in terms of tracing a transaction, the 
connection id will be consistent for the lifetime of the transaction.

Do we need a toString() in PooledConnection for debugging a container's 
internal connection pool code?  If so, I agree 
PooledConnection.toString() shouldn't refer to the underlying physical 
connection, and I can fix that...

> 
> - however, a connection returned by jdbc:default:connection, has a
> different toString() output to its parent connection.
> 
> That seems to be somewhat conflicting behaviour.
> 
> - do we want the class name in the output? I would say no.

Well, assuming that the user only ever sees a single type of connection 
class in a given VM (either NetConnection or EmbedConnection), then this 
would probably work, you would not get in the situation of having two 
connections with the same toString() output.

But, now you've got me thinking... If you have two systems running in 
different classloaders, you could still have non-unique ids.  :(

I guess this could be solved if I follow Jack's original suggestion and 
used hashCode(), since this will be unique across all objects in a VM. 
But personally a simple integer id is a lot easier to read in a log file 
than a longer hex number, or an even longer decimal number...  The 
connection id *could* be prepended with a system id, if such a thing exists.

However, thinking even further ahead, if we ever had a clustered system 
writing to a common log, even the Jack's identityHashCode solution would 
not be unique :)  Which takes us back to a UUID.  What do you think, 
should we worry about this or just worry about two systems in the same 
VM for now?

Another thing that would be very nice is if, in client/server mode, 
client connection toString() has a correlation to the resulting embedded 
connection toString() created on the server side for that session.  This 
way you could get end-to-end correlation.  I don't know if DRDA supports 
this; if people think this is a good idea I can investigate...

Sigh, and I thought this would be a simple fix, silly me! :)


> 
> 
> I would like to see that at some point the return from toString() could
> be used to correlate the connection with information from a diagnostic
> table (vti). For example the value of PreparedStatement.toString()
> corresponds to the identifier column of the statement cache vti.
> This then could be used in diagnostics to show something like all locks
> for this connection.
> 

Sorry, what's "vti"?  This is a Derby acronym I have seen while browsing 
the source, I *think* it means "virtual table" but I'm not sure...  Does 
such a diagnostic table exist?  Where would I look to find one?

I looked at EmbedPreparedStatement.  Its toString() invokes 
super.toString().  It's superclass is EmbedStatement, which has no 
toString() defined, and its superclass is ConnectionChild, which has no 
toString() defined.  So you end up with <classname>@<hashCode>.

However, further digging reveals diag.StatementCache.java refers to 
GenericPreparedStatement.getObjectName(), which is a UUIDString.

At this point I must confess I am a bit lost.  I can't find the 
relationship, BTW, between GenericPreparedStatement and 
EmbedPreparedStatement, and I can't figure out how diag.StatementCache 
is related to a VTI.  Any guidance would be most appreciated.

I guess my key question for this bug fix would be: what would I need to 
do to ensure that the toString() from a connection can be used in a 
diagnostic table?

Thanks,

David

> 
> Dan.
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Daniel John Debrunner <dj...@debrunners.com>.
David Van Couvering (JIRA) wrote:

>      [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]
> 
> David Van Couvering updated DERBY-243:
> --------------------------------------
> 
>     Attachment: DERBY-243.diff
> 
> I am attaching the patch that should resolve this bug.  I added toString() to the
> appropriate connection classes and updated the dataSourcePermissions.java and 
> dataSourcePermissions_net.java tests to test toString().  I mostly just verify
> that two connections do not have the same string and follow the expected 
> pattern.  I had to "sed" out the actual connection ids in the output so we
> could guarantee a pass even if the ids change.

I'd like to see some crisper definition around what the return from
toString() is meant to represent for a connection.

- with this implementation, two different application connections from
the same PooledConnection end up with the same toString() output,
because the toString() of the underlying connection is used.

- however, a connection returned by jdbc:default:connection, has a
different toString() output to its parent connection.

That seems to be somewhat conflicting behaviour.

- do we want the class name in the output? I would say no.


I would like to see that at some point the return from toString() could
be used to correlate the connection with information from a diagnostic
table (vti). For example the value of PreparedStatement.toString()
corresponds to the identifier column of the statement cache vti.
This then could be used in diagnostics to show something like all locks
for this connection.


Dan.


[jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]

David Van Couvering updated DERBY-243:
--------------------------------------

    Attachment: DERBY-243.diff

I am attaching the patch that should resolve this bug.  I added toString() to the
appropriate connection classes and updated the dataSourcePermissions.java and 
dataSourcePermissions_net.java tests to test toString().  I mostly just verify
that two connections do not have the same string and follow the expected 
pattern.  I had to "sed" out the actual connection ids in the output so we
could guarantee a pass even if the ids change.

Here is the output of svn status

M      java\engine\org\apache\derby\impl\jdbc\EmbedConnection.java
M      java\engine\org\apache\derby\jdbc\EmbedPooledConnection.java
M      java\engine\org\apache\derby\iapi\jdbc\BrokeredConnection.java
M      java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\dataSour
cePermissions.java
A      java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\dataSour
cePermissions_sed.properties
M      java\testing\org\apache\derbyTesting\functionTests\tests\jdbcapi\copyfile
s.ant
M      java\testing\org\apache\derbyTesting\functionTests\tests\derbynet\dataSou
rcePermissions_net_sed.properties
M      java\testing\org\apache\derbyTesting\functionTests\tests\derbynet\dataSou
rcePermissions_net.java
M      java\testing\org\apache\derbyTesting\functionTests\master\DerbyNet\dataSo
urcePermissions_net.out
M      java\testing\org\apache\derbyTesting\functionTests\master\dataSourcePermi
ssions.out
M      java\testing\org\apache\derbyTesting\functionTests\master\DerbyNetClient\
dataSourcePermissions_net.out
M      java\client\org\apache\derby\client\ClientPooledConnection.java
M      java\client\org\apache\derby\client\am\Connection.java
M      java\client\org\apache\derby\client\am\LogicalConnection.java

David

> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.0, 10.0.2.1, 10.0.2.2, 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]

David Van Couvering updated DERBY-243:
--------------------------------------

    Attachment: DERBY-243.diff

I have attached the latest patch in response to Kathey's comments.  

I added comments to the Javadoc for the connection string semantics, and I removed 
the toString() code for the client side.  derbyall passes with the exception of 
parameterMapping and backupRestore, which others have noted are currently failing.

Output of svn status:

M      java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
M      java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
M      java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/dataSourcePermissions.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net_sed.properties
M      java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dataSourcePermissions_net.out
M      java/testing/org/apache/derbyTesting/functionTests/master/dataSourcePermissions.out
M       java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dataSourcePermissions_net.out
M      java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out
M      java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
M      java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java

> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.0, 10.0.2.1, 10.0.2.2, 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
OK, thanks.  I have made modifications based on your comments and am 
re-running derbyall.  Once this passes I will submit a revised patch.

David

Øystein Grøvlen wrote:

>>>>>>"ØG" == Øystein Grøvlen <Oy...@Sun.COM> writes:
> 
> 
>     ØG> Looks very good.  I am running derbylang on it know and will let you
>     ØG> know about the results when it is finished.
> 
> I have run derbyall on your patch.  The only failure was in testij
> which I think have been mentioned by others today.
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Øystein Grøvlen <Oy...@Sun.COM>.
>>>>> "ØG" == Øystein Grøvlen <Oy...@Sun.COM> writes:

    ØG> Looks very good.  I am running derbylang on it know and will let you
    ØG> know about the results when it is finished.

I have run derbyall on your patch.  The only failure was in testij
which I think have been mentioned by others today.

-- 
Øystein


Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
Hi, Andrew.  I am going through some of these items with patches 
pending.  DERBY-217 appears to have already been applied by Satheesh.

David

Andrew McIntyre wrote:

> 
> On Jun 8, 2005, at 9:33 AM, David Van Couvering wrote:
> 
>> Thanks, Oystein, for the quick turnaround.  Your comments involve  
>> some minor changes.  I can go ahead and do this and submit an  updated 
>> patch ASAP.  Someone let me know if you'd rather take what  I have now 
>> -- I am not clear on the constraints of the release  schedule.
> 
> 
> There's not really a 'schedule,' so there aren't really any specific  
> time constraints. :-)
> 
> My plan is to create a release whenever all the bugs targeted for the  
> 10.1 release are fixed. Currently, that includes Derby-243. Now that  
> there are patches in review for all the issues targeted for 10.1, I'm  
> guessing I'll be able to start putting binaries together for people  to 
> test by the end of the week, or early next week at the latest. So,  if 
> your patch is still pending a week from now, I'll probably suggest  that 
> we move it to 10.2, since it's not a showstopper. But  considering how 
> close it is to completion, that doesn't seem likely.
> 
> One thing to remember is that *anyone* can review patches. So, anyone  
> with some free time should take a look at the remaining issues with  
> patches pending:
> 
> http://issues.apache.org/jira/browse/DERBY-217
> http://issues.apache.org/jira/browse/DERBY-319
> http://issues.apache.org/jira/browse/DERBY-334
> http://issues.apache.org/jira/browse/DERBY-337
> http://issues.apache.org/jira/browse/DERBY-338
> http://issues.apache.org/jira/browse/DERBY-339
> 
> The sooner patches are reviewed, the sooner they can be committed.
> 
> cheers,
> andrew

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Andrew McIntyre <mc...@gmail.com>.
On Jun 8, 2005, at 9:33 AM, David Van Couvering wrote:

> Thanks, Oystein, for the quick turnaround.  Your comments involve  
> some minor changes.  I can go ahead and do this and submit an  
> updated patch ASAP.  Someone let me know if you'd rather take what  
> I have now -- I am not clear on the constraints of the release  
> schedule.

There's not really a 'schedule,' so there aren't really any specific  
time constraints. :-)

My plan is to create a release whenever all the bugs targeted for the  
10.1 release are fixed. Currently, that includes Derby-243. Now that  
there are patches in review for all the issues targeted for 10.1, I'm  
guessing I'll be able to start putting binaries together for people  
to test by the end of the week, or early next week at the latest. So,  
if your patch is still pending a week from now, I'll probably suggest  
that we move it to 10.2, since it's not a showstopper. But  
considering how close it is to completion, that doesn't seem likely.

One thing to remember is that *anyone* can review patches. So, anyone  
with some free time should take a look at the remaining issues with  
patches pending:

http://issues.apache.org/jira/browse/DERBY-217
http://issues.apache.org/jira/browse/DERBY-319
http://issues.apache.org/jira/browse/DERBY-334
http://issues.apache.org/jira/browse/DERBY-337
http://issues.apache.org/jira/browse/DERBY-338
http://issues.apache.org/jira/browse/DERBY-339

The sooner patches are reviewed, the sooner they can be committed.

cheers,
andrew

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
Thanks, Oystein, for the quick turnaround.  Your comments involve some 
minor changes.  I can go ahead and do this and submit an updated patch 
ASAP.  Someone let me know if you'd rather take what I have now -- I am 
not clear on the constraints of the release schedule.

Some comments interspersed below...

David

Øystein Grøvlen wrote:

>>>>>>"DVC(" == David Van Couvering (JIRA) <de...@db.apache.org> writes:
> 
> 
>     DVC(>      [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]
>     DVC(> David Van Couvering updated DERBY-243:
>     DVC(> --------------------------------------
> 
>     DVC(>     Attachment: DERBY-243.diff
> 
>     DVC(> Updated patch for this issue.  Here is a summary of what I changed.  A lot of what I did was remove code I had put in, 
>     DVC(> so I think you'll see a much simpler patch.
> 
> Looks very good.  I am running derbylang on it know and will let you
> know about the results when it is finished.
> 
> A few minor comments:
> 
>     - EmbedPooledConnection.toString(): You do not have to create an
>       Integer object to convert int to String.  You can use the static
>       Integer.toString(int) function.

Duh! :)

> 
>     - There is some unecessary white space changes.  Adding or
>       removing empty lines are OK, but the use of "svn blame" (or
>       praise) becomes less useful if lines that are unrelated to the
>       check-in are changed.  Even worse, checkDataSource30.java only
>       contains white space changes.  This gives the false impression
>       that this test is changed by your fix.

OK, I didn't think this was too important, but I'll see if I can fix this.

With checkDataSource30, that should just not be there.  I will revert 
back to the original one.


> 
>     - The Javadoc for checkDataSource.checkToString(Connection) seems
>       to lack the word "sure".

OK

> 
>     - You have changed the checkDataSource.main test so it may throw
>       an Exception.  What is the purpose of that.  Will the test
>       harness handle the Exception?

It used to throw an exception.  I just changed it to print the stack 
trace prior to throwing the exception to the caller because I wasn't 
getting a stack trace when I was hitting bugs in the tests.

David
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Øystein Grøvlen <Oy...@Sun.COM>.
>>>>> "DVC(" == David Van Couvering (JIRA) <de...@db.apache.org> writes:

    DVC(>      [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]
    DVC(> David Van Couvering updated DERBY-243:
    DVC(> --------------------------------------

    DVC(>     Attachment: DERBY-243.diff

    DVC(> Updated patch for this issue.  Here is a summary of what I changed.  A lot of what I did was remove code I had put in, 
    DVC(> so I think you'll see a much simpler patch.

Looks very good.  I am running derbylang on it know and will let you
know about the results when it is finished.

A few minor comments:

    - EmbedPooledConnection.toString(): You do not have to create an
      Integer object to convert int to String.  You can use the static
      Integer.toString(int) function.

    - There is some unecessary white space changes.  Adding or
      removing empty lines are OK, but the use of "svn blame" (or
      praise) becomes less useful if lines that are unrelated to the
      check-in are changed.  Even worse, checkDataSource30.java only
      contains white space changes.  This gives the false impression
      that this test is changed by your fix.

    - The Javadoc for checkDataSource.checkToString(Connection) seems
      to lack the word "sure".

    - You have changed the checkDataSource.main test so it may throw
      an Exception.  What is the purpose of that.  Will the test
      harness handle the Exception?

-- 
Øystein


[jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]

David Van Couvering updated DERBY-243:
--------------------------------------

    Attachment: DERBY-243.diff

Updated patch for this issue.  Here is a summary of what I changed.  A lot of what I did was remove code I had put in, 
so I think you'll see a much simpler patch.

- Reverted back to using a simple integer for the GenericLanguageConnectionContext id
- All trace and log statements and the ErrorLogReader VTI go back to using the simple integer SESSIONID/LCCID
- EmbedConnection uses the LCC ID as its toString value
- BrokeredConnection continues to use the underlying physical connection's toString value for it's toString value
- EmbedPooledConnection now uses a simple integer instead of a UUID
- Reworked the tests to open 10 connections and make sure they are all unique.  It does this for a DriverManager
  connection, a connection from a DataSource, a PooledConnection from a ConnectionPoolDataSource and an
  XAConnection from an XADataSource.  It also ensures connections obtained from the same PooledConnection
  have the same toString() value
- I no longer print out the toString() value in the test.
- I modified lang/miscerrors.sql to select from the ErrorLogReader VTI so we can validate that this output is
  correct.  

Ran derbyall, everything passed except for a strange error in encryptionAll/multi/stress which appears completely
unrelated.  Every now and then my stress tests fail for reasons I don't fully fathom.  Should I be investigating these
or is this a known issue?

Here is the output of svn status:

M      java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
M      java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
M      java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/lang/miscerrors.sql
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java
M      java/testing/org/apache/derbyTesting/functionTests/master/miscerrors.out

> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Versions: 10.0.2.1, 10.0.2.2, 10.1.0.0, 10.0.2.0
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Re: [jira] Commented: (DERBY-243) connection toString should uniquely identify the connection

Posted by Kathey Marsden <km...@sbcglobal.net>.
David Van Couvering wrote:

>Does anyone else have any comments on this?  Kathey, are you OK with
>this change?  If so, you could hold off on the patch I submitted and
>wait for a new one with these changes...
>  
>
Sounds good  to me.

Kathey



Re: [jira] Commented: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <Da...@Sun.COM>.
Does anyone else have any comments on this?  Kathey, are you OK with
this change?  If so, you could hold off on the patch I submitted and
wait for a new one with these changes...

Thanks,

David

Daniel John Debrunner (JIRA) wrote:

>     [ http://issues.apache.org/jira/browse/DERBY-243?page=comments#action_66186 ]
>     
>Daniel John Debrunner commented on DERBY-243:
>---------------------------------------------
>
>David wrote
>  
>
>>For this reason, it makes much more sense to use the LanguageConnectionContext as the owner of a unique identification for the session.
>>    
>>
>
>I agree, the LCC is the "physical connection", thus having it define the unique identification matches the definition.
>
>  
>
>>connection toString should uniquely identify the connection
>>-----------------------------------------------------------
>>
>>         Key: DERBY-243
>>         URL: http://issues.apache.org/jira/browse/DERBY-243
>>     Project: Derby
>>        Type: Improvement
>>  Components: JDBC
>>    Reporter: Kathey Marsden
>>    Assignee: David Van Couvering
>>    Priority: Trivial
>>     Fix For: 10.0.2.1, 10.0.2.0, 10.0.2.2, 10.1.0.0
>> Attachments: DERBY-243.diff
>>
>>The toString() on the Derby connection doesn't print 
>>unique information.
>>for example  System.out.println(conn) prints:
>>EmbedConnection  in the case of derby embedded
>>It would be great if the toString() method for connections could be used to differentiate one connection from another.
>>    
>>
>
>  
>


[jira] Commented: (DERBY-243) connection toString should uniquely identify the connection

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=comments#action_66186 ]
     
Daniel John Debrunner commented on DERBY-243:
---------------------------------------------

David wrote
> For this reason, it makes much more sense to use the LanguageConnectionContext as the owner of a unique identification for the session.

I agree, the LCC is the "physical connection", thus having it define the unique identification matches the definition.

> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.1, 10.0.2.0, 10.0.2.2, 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-243) connection toString should uniquely identify the connection

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=comments#action_66181 ]
     
David Van Couvering commented on DERBY-243:
-------------------------------------------

In my investigations to understand how to add the connection string to VTIs, I have thought further about this item, and it has become clear to me that storing the unique id in the Connection object is putting it at the wrong level.  If, for example, we ever want to provide a separate API for obtaining a session into the Derby database outside of JDBC, this information would not be available.

For this reason, it makes much more sense to use the LanguageConnectionContext as the owner of a unique identification for the session.  

As some of our discussion has revealed, the LanguageConnectionContext already has an instance number, printed out as either "SESSIONID" or "LCCID" in the logs and VTIs.  One could argue that we should just use this id.  However, this id is a simple static integer incremented each time a new LanguageConnectionContext is created, and my concerns about loss of uniqueness across classloaders stands for this id, and I think it is going to cause us problems, particularly in the context of an app server where there is normally a separate classloader for each deployed application.

I am recommending that we add a new method to LanguageConnectionContext, UUID getId().  Connection.toString() will return "Connection_" + the String representation of this id.  

Also, today our error logs and VTIs today all use the existing instance number as the LanguageConnectionContext id (SESSIONID or LCCID).  I would like to propose that this be replaced to print out the new UUID instead.  

Pooled connections, as we have already discussed, have their own separate identity, and I am recommending that we keep them using their own UUID as it is already implemented.

> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.1, 10.0.2.0, 10.0.2.2, 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]

David Van Couvering updated DERBY-243:
--------------------------------------

    Attachment: DERBY-243.diff

A rescan of svn status revealed that the patch included my modification of 
derby.properties to use the "test: durability mode.  Oops!

This updated patch does not include this modification.

> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.0, 10.0.2.1, 10.0.2.2, 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-243) connection toString should uniquely identify the connection

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=comments#action_65821 ]
     
David Van Couvering commented on DERBY-243:
-------------------------------------------

In response to Kathey's request, I am providing information on the semantics for providing a unique string representation for a connection.  

First, it is important to identify three major types of connections in Derby:

POOLED CONNECTIONS
Pooled Connections are a subtype of javax.sql.PooledConnection.  They represent a connection stored on a pool.  References to PooledConnections are never directly visible to application code.  They are used by implementors of connection pools so that management of pooled connections can be standardized across JDBC driver providers.

PROXY CONNECTIONS
Proxy connections are a class of connections that, although they implement the java.sql.Connection interface, don't directly implement the methods of java.sql.Connection.  Instead, they act as a proxy to an underlying physical connection, and allow containers to "inject" container logic when key connectoin lifecycle events occur.  These are also sometimes called "logical connections" or "brokered connections".

PHYSICAL CONNECTIONS

These are the connection classes that do the "heavy lifting" of actually implementing the methods on java.sql.Connection.  They are the underlying physical connections wrapped by proxy connections.  

CONNECTION STRING SEMANTICS
With these definitions in place, here are the semantics of connection strings:

- When a physical connection is created, it is assigned a unique UUID that is unchanged for the lifetime of the connection.

- When an application calls Connection.toString(), it gets the string "Connection_<UUID>" of the underlying physical connection, regardless of where the application has a reference to the physical connection itself a reference to a proxy connection (aka brokered connection) that wraps the physical connection.

- A pooled connection is assigned a separate UUID from a physical connection.  When a container calls PooledConnection.toString(), it gets the string "PooledConnection_<UUID>".  This is useful for developers implementing connection pools when they are trying to debug pooled connections



> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.0, 10.0.2.1, 10.0.2.2, 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by David Van Couvering <da...@vancouvering.com>.
Hi, Kathey.  It's not a huge pressure to get this done (at least on my 
end), but I agree it would be great if somebody else did the initial 
verification that it works OK.

Yes, the Error Log VTI output should have changed.  I will run a test to 
make sure it looks OK.

David

Kathey Marsden wrote:

> David Van Couvering (JIRA) wrote:
> 
> 
>>Here is an updated patch for this item.  This addresses my previous comment by pushing
>>the unique id down to the LanguageConnectionContext.
>> 
>>
> 
> Thanks David,
> 
> It is probably going to be this weekend before I have a chance to look
> at this patch.  Do you think you can lobby someone else  (maybe some of
> our friends from Norway) to do the initial review and try out this
> patch?  It would be a huge help in moving this along.  Also I wanted to
> mention that I thought I remember you mentioning that you were changing
> a value that already shows up in the  Error Log VTI from an integer to
> the UUID.  If that's the case, I think that means the VTI will have to
> be changed.    If what prints in the VTI's was affected at all, could 
> give it a try and make sure it still works ok?  I don't see the test
> that I think used to be there to test the diagnostic VTI's.   Sorry I
> can't review right away. Got myself in a bit  of a bind this week #:(
> 
> Kathey
> 
> 
> 
> 

Re: [jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by Kathey Marsden <km...@sbcglobal.net>.
David Van Couvering (JIRA) wrote:

>Here is an updated patch for this item.  This addresses my previous comment by pushing
>the unique id down to the LanguageConnectionContext.
>  
>
Thanks David,

It is probably going to be this weekend before I have a chance to look
at this patch.  Do you think you can lobby someone else  (maybe some of
our friends from Norway) to do the initial review and try out this
patch?  It would be a huge help in moving this along.  Also I wanted to
mention that I thought I remember you mentioning that you were changing
a value that already shows up in the  Error Log VTI from an integer to
the UUID.  If that's the case, I think that means the VTI will have to
be changed.    If what prints in the VTI's was affected at all, could 
give it a try and make sure it still works ok?  I don't see the test
that I think used to be there to test the diagnostic VTI's.   Sorry I
can't review right away. Got myself in a bit  of a bind this week #:(

Kathey





[jira] Updated: (DERBY-243) connection toString should uniquely identify the connection

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-243?page=all ]

David Van Couvering updated DERBY-243:
--------------------------------------

    Attachment: DERBY-243.diff

Here is an updated patch for this item.  This addresses my previous comment by pushing
the unique id down to the LanguageConnectionContext.

I also modified the trace and log output to use this id rather than the LCC instance
number.  This means that you can correlate the output from Connection.toString()
with the output in the error log and traces.

Finally, upon further rumination, I decided to remove the "Connection_" and 
"PooledConnection_" prefix from the toString() output.  As I worked with this
code, it seemed odd to have ths prefix here, when the user will normally print out 
debug code like 

  System.out.println("Connection: " + conn.toString());

Removing the "Connection_" prefix also means the output of toString() 
exactly matches the output of lcc.getId(), which may make it easier 
in the future to do filters against VTIs using the output of conn.toString().

Output of svn status:

M      java/engine/org/apache/derby/impl/sql/GenericStatement.java
M      java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
M      java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionFactory.java
M      java/engine/org/apache/derby/impl/sql/execute/BasicNoPutResultSetImpl.java
M      java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
M      java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
M      java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
M      java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
M      java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
M      java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/dataSourcePermissions.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net_sed.properties
M      java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dataSourcePermissions_net.out
M      java/testing/org/apache/derbyTesting/functionTests/master/dataSourcePermissions.out
M      java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dataSourcePermissions_net.out
M      java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out
M      java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
M      java/testing/org/apache/derbyTesting/functionTests/suites/derbyall.properties
M      java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java


David

> connection toString should uniquely identify the connection
> -----------------------------------------------------------
>
>          Key: DERBY-243
>          URL: http://issues.apache.org/jira/browse/DERBY-243
>      Project: Derby
>         Type: Improvement
>   Components: JDBC
>     Reporter: Kathey Marsden
>     Assignee: David Van Couvering
>     Priority: Trivial
>      Fix For: 10.0.2.0, 10.0.2.1, 10.0.2.2, 10.1.0.0
>  Attachments: DERBY-243.diff
>
> The toString() on the Derby connection doesn't print 
> unique information.
> for example  System.out.println(conn) prints:
> EmbedConnection  in the case of derby embedded
> It would be great if the toString() method for connections could be used to differentiate one connection from another.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira