[jira] [Work logged] (DBCP-585) Connection level JMX queries result in concurrent access to connection objects, causing errors

2022-05-02 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/DBCP-585?focusedWorklogId=765183&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-765183
 ]

ASF GitHub Bot logged work on DBCP-585:
---

Author: ASF GitHub Bot
Created on: 02/May/22 22:45
Start Date: 02/May/22 22:45
Worklog Time Spent: 10m 
  Work Description: garydgregory merged PR #179:
URL: https://github.com/apache/commons-dbcp/pull/179




Issue Time Tracking
---

Worklog Id: (was: 765183)
Time Spent: 1h 20m  (was: 1h 10m)

> Connection level JMX queries result in concurrent access to connection 
> objects, causing errors
> --
>
> Key: DBCP-585
> URL: https://issues.apache.org/jira/browse/DBCP-585
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: Kurtcebe Eroglu
>Priority: Major
> Attachments: 0001-DBCP-585-idea-clarification-1.patch, 
> conn_instance_attrs.png, connections_attrs.png, ds_attrs.png, final.png
>
>  Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> As we expose Connection objects over JMX, they may be accessed by multiple 
> threads concurrently; 
> a) an application thread that borrows the Connection and uses it business as 
> usual,
> b) another thread simultaneously performing a JMX query, which in turn calls 
> getters on the same connection object via the MBean interface.
> Also, calls to Connection object getters are mostly delegated to the 
> underlying vendor-specific connection provided by the JDBC driver. For 
> example, when we make the JMX query to get the "schema" attribute of the JMX 
> connection object, this is translated into a 
> "java.sql.Connection.getSchema()", and passed to the vendor-specific 
> Connection object by DBCP. In the case of Postgres, for example, this is 
> further translated to a query "select current_schema()" and sent to the 
> server.
> Hence, querying connections over JMX result in concurrent access by multiple 
> threads to the underlying Connection provided by the vendors, to the point 
> that these two threads may be running queries simultaneously on the same 
> connection. 
> However, this is not supported by any of the major database vendors. Vendor 
> links on Connection objects not being threadsafe:
>  - [Postgres|https://jdbc.postgresql.org/documentation/head/thread.html]
> {quote}The PostgreSQL™ JDBC driver is not thread safe. The PostgreSQL server 
> is not threaded. Each connection creates a new process on the server; as such 
> any concurrent requests to the process would have to be serialized. The 
> driver makes no guarantees that methods on connections are synchronized. It 
> will be up to the caller to synchronize calls to the driver.
> {quote}
>  - 
> [Oracle|https://docs.oracle.com/en/database/oracle/oracle-database/19/jjdbc/JDBC-coding-tips.html#GUID-EE479007-D105-4F82-8D51-000CBBD4BC77]
>  
> {quote}Oracle strongly discourages sharing a database connection among 
> multiple threads. Avoid allowing multiple threads to access a connection 
> simultaneously.
> {quote}
>  - [Microsoft SQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/latest/com.microsoft.sqlserver.jdbc/com/microsoft/sqlserver/jdbc/SQLServerConnection.html]
> {quote}SQLServerConnection is not thread safe, however multiple statements 
> created from a single connection can be processing simultaneously in 
> concurrent threads.
> {quote}
> Another interesting point to note, also to do justice to previous committers 
> who have put this feature in place, is that this was not always the case. In 
> the following links, you may see the same links to the older versions of the 
> same pages. In the past, all vendors indicated that Connection is fully 
> thread-safe; [Postgres|https://www.postgresql.org/docs/7.1/jdbc-thread.html], 
> [Oracle|https://docs.oracle.com/cd/A97335_02/apps.102/a83724/tips1.htm], 
> [MSSQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/6.1.0.jre7/com/microsoft/sqlserver/jdbc/SQLServerConnection.html].
>  
> Hence, it was once safe to expose Connection objects via JMX given the 
> thread-safety guarantees for the underlying vendor connection were in place. 
> But as Vendors dropped the thread-safety guarantee one by one, it is not safe 
> anymore, and may actually cause convoluted errors that pop up intermittently 
> due to thread races in the JDBC driver code (see an example in the comments 
> section below). Accordingly, exposing Connections via JMX shall be retired 
> along with dropped support from most vendors. 
> Note: the Datasource MBeans, which provide a vital set of metrics have no 
> such problems as they don't depend on the underlying JDBC provider.



--
This message was sent by Atlassian

[jira] [Work logged] (DBCP-585) Connection level JMX queries result in concurrent access to connection objects, causing errors

2022-04-30 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/DBCP-585?focusedWorklogId=764707&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-764707
 ]

ASF GitHub Bot logged work on DBCP-585:
---

Author: ASF GitHub Bot
Created on: 30/Apr/22 22:31
Start Date: 30/Apr/22 22:31
Worklog Time Spent: 10m 
  Work Description: kurtcebe commented on PR #179:
URL: https://github.com/apache/commons-dbcp/pull/179#issuecomment-1114064561

   I've removed the test to check the default state (i.e. we don't disable 
connection MBean). It turns out that the initial states are different for 
different types of Datasources, for example, BasicManagedDatasource does not 
register connection by default, while BasicDatasource and 
PStmtPoolingBasicDatasource does, i.e. there is no common value to check. We 
still test the case when parameter is set.




Issue Time Tracking
---

Worklog Id: (was: 764707)
Time Spent: 1h 10m  (was: 1h)

> Connection level JMX queries result in concurrent access to connection 
> objects, causing errors
> --
>
> Key: DBCP-585
> URL: https://issues.apache.org/jira/browse/DBCP-585
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: Kurtcebe Eroglu
>Priority: Major
> Attachments: 0001-DBCP-585-idea-clarification-1.patch, 
> conn_instance_attrs.png, connections_attrs.png, ds_attrs.png, final.png
>
>  Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> As we expose Connection objects over JMX, they may be accessed by multiple 
> threads concurrently; 
> a) an application thread that borrows the Connection and uses it business as 
> usual,
> b) another thread simultaneously performing a JMX query, which in turn calls 
> getters on the same connection object via the MBean interface.
> Also, calls to Connection object getters are mostly delegated to the 
> underlying vendor-specific connection provided by the JDBC driver. For 
> example, when we make the JMX query to get the "schema" attribute of the JMX 
> connection object, this is translated into a 
> "java.sql.Connection.getSchema()", and passed to the vendor-specific 
> Connection object by DBCP. In the case of Postgres, for example, this is 
> further translated to a query "select current_schema()" and sent to the 
> server.
> Hence, querying connections over JMX result in concurrent access by multiple 
> threads to the underlying Connection provided by the vendors, to the point 
> that these two threads may be running queries simultaneously on the same 
> connection. 
> However, this is not supported by any of the major database vendors. Vendor 
> links on Connection objects not being threadsafe:
>  - [Postgres|https://jdbc.postgresql.org/documentation/head/thread.html]
> {quote}The PostgreSQL™ JDBC driver is not thread safe. The PostgreSQL server 
> is not threaded. Each connection creates a new process on the server; as such 
> any concurrent requests to the process would have to be serialized. The 
> driver makes no guarantees that methods on connections are synchronized. It 
> will be up to the caller to synchronize calls to the driver.
> {quote}
>  - 
> [Oracle|https://docs.oracle.com/en/database/oracle/oracle-database/19/jjdbc/JDBC-coding-tips.html#GUID-EE479007-D105-4F82-8D51-000CBBD4BC77]
>  
> {quote}Oracle strongly discourages sharing a database connection among 
> multiple threads. Avoid allowing multiple threads to access a connection 
> simultaneously.
> {quote}
>  - [Microsoft SQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/latest/com.microsoft.sqlserver.jdbc/com/microsoft/sqlserver/jdbc/SQLServerConnection.html]
> {quote}SQLServerConnection is not thread safe, however multiple statements 
> created from a single connection can be processing simultaneously in 
> concurrent threads.
> {quote}
> Another interesting point to note, also to do justice to previous committers 
> who have put this feature in place, is that this was not always the case. In 
> the following links, you may see the same links to the older versions of the 
> same pages. In the past, all vendors indicated that Connection is fully 
> thread-safe; [Postgres|https://www.postgresql.org/docs/7.1/jdbc-thread.html], 
> [Oracle|https://docs.oracle.com/cd/A97335_02/apps.102/a83724/tips1.htm], 
> [MSSQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/6.1.0.jre7/com/microsoft/sqlserver/jdbc/SQLServerConnection.html].
>  
> Hence, it was once safe to expose Connection objects via JMX given the 
> thread-safety guarantees for the underlying vendor connection were in place. 
> But as Vendors dropped the thread-safety guarantee one by one, it is not safe 
> anymore, and may actually cause convolu

[jira] [Work logged] (DBCP-585) Connection level JMX queries result in concurrent access to connection objects, causing errors

2022-04-30 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/DBCP-585?focusedWorklogId=764702&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-764702
 ]

ASF GitHub Bot logged work on DBCP-585:
---

Author: ASF GitHub Bot
Created on: 30/Apr/22 21:15
Start Date: 30/Apr/22 21:15
Worklog Time Spent: 10m 
  Work Description: kurtcebe commented on PR #179:
URL: https://github.com/apache/commons-dbcp/pull/179#issuecomment-1114055253

   @garydgregory  I'm guessing this is happening due to unit tests running in 
parallel, which was already highlighted in a TODO comment at another test 
method 
[here](https://github.com/apache/commons-dbcp/blob/14d3df96d27068b5819863aede83de9125b11021/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java#L623).
 I've followed suit by just adding the same comment, but now I'm thinking, 
maybe that was unnecessarily optimistic. Since we're using PlatformMBeanServer 
in our tests without mocking, all tests are registering/unregistering Means on 
a singleton, hence we may be seeing side effects from other tests running with 
different JMX config.  I'll take another look into this to verify this. Thanks 
for your time as always.




Issue Time Tracking
---

Worklog Id: (was: 764702)
Time Spent: 1h  (was: 50m)

> Connection level JMX queries result in concurrent access to connection 
> objects, causing errors
> --
>
> Key: DBCP-585
> URL: https://issues.apache.org/jira/browse/DBCP-585
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: Kurtcebe Eroglu
>Priority: Major
> Attachments: 0001-DBCP-585-idea-clarification-1.patch, 
> conn_instance_attrs.png, connections_attrs.png, ds_attrs.png, final.png
>
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> As we expose Connection objects over JMX, they may be accessed by multiple 
> threads concurrently; 
> a) an application thread that borrows the Connection and uses it business as 
> usual,
> b) another thread simultaneously performing a JMX query, which in turn calls 
> getters on the same connection object via the MBean interface.
> Also, calls to Connection object getters are mostly delegated to the 
> underlying vendor-specific connection provided by the JDBC driver. For 
> example, when we make the JMX query to get the "schema" attribute of the JMX 
> connection object, this is translated into a 
> "java.sql.Connection.getSchema()", and passed to the vendor-specific 
> Connection object by DBCP. In the case of Postgres, for example, this is 
> further translated to a query "select current_schema()" and sent to the 
> server.
> Hence, querying connections over JMX result in concurrent access by multiple 
> threads to the underlying Connection provided by the vendors, to the point 
> that these two threads may be running queries simultaneously on the same 
> connection. 
> However, this is not supported by any of the major database vendors. Vendor 
> links on Connection objects not being threadsafe:
>  - [Postgres|https://jdbc.postgresql.org/documentation/head/thread.html]
> {quote}The PostgreSQL™ JDBC driver is not thread safe. The PostgreSQL server 
> is not threaded. Each connection creates a new process on the server; as such 
> any concurrent requests to the process would have to be serialized. The 
> driver makes no guarantees that methods on connections are synchronized. It 
> will be up to the caller to synchronize calls to the driver.
> {quote}
>  - 
> [Oracle|https://docs.oracle.com/en/database/oracle/oracle-database/19/jjdbc/JDBC-coding-tips.html#GUID-EE479007-D105-4F82-8D51-000CBBD4BC77]
>  
> {quote}Oracle strongly discourages sharing a database connection among 
> multiple threads. Avoid allowing multiple threads to access a connection 
> simultaneously.
> {quote}
>  - [Microsoft SQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/latest/com.microsoft.sqlserver.jdbc/com/microsoft/sqlserver/jdbc/SQLServerConnection.html]
> {quote}SQLServerConnection is not thread safe, however multiple statements 
> created from a single connection can be processing simultaneously in 
> concurrent threads.
> {quote}
> Another interesting point to note, also to do justice to previous committers 
> who have put this feature in place, is that this was not always the case. In 
> the following links, you may see the same links to the older versions of the 
> same pages. In the past, all vendors indicated that Connection is fully 
> thread-safe; [Postgres|https://www.postgresql.org/docs/7.1/jdbc-thread.html], 
> [Oracle|https://docs.oracle.com/cd/A97335_02/apps.102/a83724/tips1.htm], 
> [MSSQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/6.1.0.jre7/com/mi

[jira] [Work logged] (DBCP-585) Connection level JMX queries result in concurrent access to connection objects, causing errors

2022-04-30 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/DBCP-585?focusedWorklogId=764701&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-764701
 ]

ASF GitHub Bot logged work on DBCP-585:
---

Author: ASF GitHub Bot
Created on: 30/Apr/22 20:39
Start Date: 30/Apr/22 20:39
Worklog Time Spent: 10m 
  Work Description: kurtcebe commented on PR #179:
URL: https://github.com/apache/commons-dbcp/pull/179#issuecomment-1114050656

   Hi @garydgregory thanks for the heads up , I've updated the PR.




Issue Time Tracking
---

Worklog Id: (was: 764701)
Time Spent: 50m  (was: 40m)

> Connection level JMX queries result in concurrent access to connection 
> objects, causing errors
> --
>
> Key: DBCP-585
> URL: https://issues.apache.org/jira/browse/DBCP-585
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: Kurtcebe Eroglu
>Priority: Major
> Attachments: 0001-DBCP-585-idea-clarification-1.patch, 
> conn_instance_attrs.png, connections_attrs.png, ds_attrs.png, final.png
>
>  Time Spent: 50m
>  Remaining Estimate: 0h
>
> As we expose Connection objects over JMX, they may be accessed by multiple 
> threads concurrently; 
> a) an application thread that borrows the Connection and uses it business as 
> usual,
> b) another thread simultaneously performing a JMX query, which in turn calls 
> getters on the same connection object via the MBean interface.
> Also, calls to Connection object getters are mostly delegated to the 
> underlying vendor-specific connection provided by the JDBC driver. For 
> example, when we make the JMX query to get the "schema" attribute of the JMX 
> connection object, this is translated into a 
> "java.sql.Connection.getSchema()", and passed to the vendor-specific 
> Connection object by DBCP. In the case of Postgres, for example, this is 
> further translated to a query "select current_schema()" and sent to the 
> server.
> Hence, querying connections over JMX result in concurrent access by multiple 
> threads to the underlying Connection provided by the vendors, to the point 
> that these two threads may be running queries simultaneously on the same 
> connection. 
> However, this is not supported by any of the major database vendors. Vendor 
> links on Connection objects not being threadsafe:
>  - [Postgres|https://jdbc.postgresql.org/documentation/head/thread.html]
> {quote}The PostgreSQL™ JDBC driver is not thread safe. The PostgreSQL server 
> is not threaded. Each connection creates a new process on the server; as such 
> any concurrent requests to the process would have to be serialized. The 
> driver makes no guarantees that methods on connections are synchronized. It 
> will be up to the caller to synchronize calls to the driver.
> {quote}
>  - 
> [Oracle|https://docs.oracle.com/en/database/oracle/oracle-database/19/jjdbc/JDBC-coding-tips.html#GUID-EE479007-D105-4F82-8D51-000CBBD4BC77]
>  
> {quote}Oracle strongly discourages sharing a database connection among 
> multiple threads. Avoid allowing multiple threads to access a connection 
> simultaneously.
> {quote}
>  - [Microsoft SQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/latest/com.microsoft.sqlserver.jdbc/com/microsoft/sqlserver/jdbc/SQLServerConnection.html]
> {quote}SQLServerConnection is not thread safe, however multiple statements 
> created from a single connection can be processing simultaneously in 
> concurrent threads.
> {quote}
> Another interesting point to note, also to do justice to previous committers 
> who have put this feature in place, is that this was not always the case. In 
> the following links, you may see the same links to the older versions of the 
> same pages. In the past, all vendors indicated that Connection is fully 
> thread-safe; [Postgres|https://www.postgresql.org/docs/7.1/jdbc-thread.html], 
> [Oracle|https://docs.oracle.com/cd/A97335_02/apps.102/a83724/tips1.htm], 
> [MSSQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/6.1.0.jre7/com/microsoft/sqlserver/jdbc/SQLServerConnection.html].
>  
> Hence, it was once safe to expose Connection objects via JMX given the 
> thread-safety guarantees for the underlying vendor connection were in place. 
> But as Vendors dropped the thread-safety guarantee one by one, it is not safe 
> anymore, and may actually cause convoluted errors that pop up intermittently 
> due to thread races in the JDBC driver code (see an example in the comments 
> section below). Accordingly, exposing Connections via JMX shall be retired 
> along with dropped support from most vendors. 
> Note: the Datasource MBeans, which provide a vital set of metrics have no 
> such problems as they d

[jira] [Work logged] (DBCP-585) Connection level JMX queries result in concurrent access to connection objects, causing errors

2022-04-30 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/DBCP-585?focusedWorklogId=764700&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-764700
 ]

ASF GitHub Bot logged work on DBCP-585:
---

Author: ASF GitHub Bot
Created on: 30/Apr/22 20:33
Start Date: 30/Apr/22 20:33
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on PR #179:
URL: https://github.com/apache/commons-dbcp/pull/179#issuecomment-1114049893

   Hi @kurtcebe 
   There are test failures in the GitHub builds.
   




Issue Time Tracking
---

Worklog Id: (was: 764700)
Time Spent: 40m  (was: 0.5h)

> Connection level JMX queries result in concurrent access to connection 
> objects, causing errors
> --
>
> Key: DBCP-585
> URL: https://issues.apache.org/jira/browse/DBCP-585
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: Kurtcebe Eroglu
>Priority: Major
> Attachments: 0001-DBCP-585-idea-clarification-1.patch, 
> conn_instance_attrs.png, connections_attrs.png, ds_attrs.png, final.png
>
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> As we expose Connection objects over JMX, they may be accessed by multiple 
> threads concurrently; 
> a) an application thread that borrows the Connection and uses it business as 
> usual,
> b) another thread simultaneously performing a JMX query, which in turn calls 
> getters on the same connection object via the MBean interface.
> Also, calls to Connection object getters are mostly delegated to the 
> underlying vendor-specific connection provided by the JDBC driver. For 
> example, when we make the JMX query to get the "schema" attribute of the JMX 
> connection object, this is translated into a 
> "java.sql.Connection.getSchema()", and passed to the vendor-specific 
> Connection object by DBCP. In the case of Postgres, for example, this is 
> further translated to a query "select current_schema()" and sent to the 
> server.
> Hence, querying connections over JMX result in concurrent access by multiple 
> threads to the underlying Connection provided by the vendors, to the point 
> that these two threads may be running queries simultaneously on the same 
> connection. 
> However, this is not supported by any of the major database vendors. Vendor 
> links on Connection objects not being threadsafe:
>  - [Postgres|https://jdbc.postgresql.org/documentation/head/thread.html]
> {quote}The PostgreSQL™ JDBC driver is not thread safe. The PostgreSQL server 
> is not threaded. Each connection creates a new process on the server; as such 
> any concurrent requests to the process would have to be serialized. The 
> driver makes no guarantees that methods on connections are synchronized. It 
> will be up to the caller to synchronize calls to the driver.
> {quote}
>  - 
> [Oracle|https://docs.oracle.com/en/database/oracle/oracle-database/19/jjdbc/JDBC-coding-tips.html#GUID-EE479007-D105-4F82-8D51-000CBBD4BC77]
>  
> {quote}Oracle strongly discourages sharing a database connection among 
> multiple threads. Avoid allowing multiple threads to access a connection 
> simultaneously.
> {quote}
>  - [Microsoft SQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/latest/com.microsoft.sqlserver.jdbc/com/microsoft/sqlserver/jdbc/SQLServerConnection.html]
> {quote}SQLServerConnection is not thread safe, however multiple statements 
> created from a single connection can be processing simultaneously in 
> concurrent threads.
> {quote}
> Another interesting point to note, also to do justice to previous committers 
> who have put this feature in place, is that this was not always the case. In 
> the following links, you may see the same links to the older versions of the 
> same pages. In the past, all vendors indicated that Connection is fully 
> thread-safe; [Postgres|https://www.postgresql.org/docs/7.1/jdbc-thread.html], 
> [Oracle|https://docs.oracle.com/cd/A97335_02/apps.102/a83724/tips1.htm], 
> [MSSQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/6.1.0.jre7/com/microsoft/sqlserver/jdbc/SQLServerConnection.html].
>  
> Hence, it was once safe to expose Connection objects via JMX given the 
> thread-safety guarantees for the underlying vendor connection were in place. 
> But as Vendors dropped the thread-safety guarantee one by one, it is not safe 
> anymore, and may actually cause convoluted errors that pop up intermittently 
> due to thread races in the JDBC driver code (see an example in the comments 
> section below). Accordingly, exposing Connections via JMX shall be retired 
> along with dropped support from most vendors. 
> Note: the Datasource MBeans, which provide a vital set of metrics have no 
> such problems a

[jira] [Work logged] (DBCP-585) Connection level JMX queries result in concurrent access to connection objects, causing errors

2022-04-30 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/DBCP-585?focusedWorklogId=764699&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-764699
 ]

ASF GitHub Bot logged work on DBCP-585:
---

Author: ASF GitHub Bot
Created on: 30/Apr/22 20:17
Start Date: 30/Apr/22 20:17
Worklog Time Spent: 10m 
  Work Description: garydgregory closed pull request #179: DBCP-585 PR for 
idea clarification
URL: https://github.com/apache/commons-dbcp/pull/179




Issue Time Tracking
---

Worklog Id: (was: 764699)
Time Spent: 0.5h  (was: 20m)

> Connection level JMX queries result in concurrent access to connection 
> objects, causing errors
> --
>
> Key: DBCP-585
> URL: https://issues.apache.org/jira/browse/DBCP-585
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: Kurtcebe Eroglu
>Priority: Major
> Attachments: 0001-DBCP-585-idea-clarification-1.patch, 
> conn_instance_attrs.png, connections_attrs.png, ds_attrs.png, final.png
>
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> As we expose Connection objects over JMX, they may be accessed by multiple 
> threads concurrently; 
> a) an application thread that borrows the Connection and uses it business as 
> usual,
> b) another thread simultaneously performing a JMX query, which in turn calls 
> getters on the same connection object via the MBean interface.
> Also, calls to Connection object getters are mostly delegated to the 
> underlying vendor-specific connection provided by the JDBC driver. For 
> example, when we make the JMX query to get the "schema" attribute of the JMX 
> connection object, this is translated into a 
> "java.sql.Connection.getSchema()", and passed to the vendor-specific 
> Connection object by DBCP. In the case of Postgres, for example, this is 
> further translated to a query "select current_schema()" and sent to the 
> server.
> Hence, querying connections over JMX result in concurrent access by multiple 
> threads to the underlying Connection provided by the vendors, to the point 
> that these two threads may be running queries simultaneously on the same 
> connection. 
> However, this is not supported by any of the major database vendors. Vendor 
> links on Connection objects not being threadsafe:
>  - [Postgres|https://jdbc.postgresql.org/documentation/head/thread.html]
> {quote}The PostgreSQL™ JDBC driver is not thread safe. The PostgreSQL server 
> is not threaded. Each connection creates a new process on the server; as such 
> any concurrent requests to the process would have to be serialized. The 
> driver makes no guarantees that methods on connections are synchronized. It 
> will be up to the caller to synchronize calls to the driver.
> {quote}
>  - 
> [Oracle|https://docs.oracle.com/en/database/oracle/oracle-database/19/jjdbc/JDBC-coding-tips.html#GUID-EE479007-D105-4F82-8D51-000CBBD4BC77]
>  
> {quote}Oracle strongly discourages sharing a database connection among 
> multiple threads. Avoid allowing multiple threads to access a connection 
> simultaneously.
> {quote}
>  - [Microsoft SQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/latest/com.microsoft.sqlserver.jdbc/com/microsoft/sqlserver/jdbc/SQLServerConnection.html]
> {quote}SQLServerConnection is not thread safe, however multiple statements 
> created from a single connection can be processing simultaneously in 
> concurrent threads.
> {quote}
> Another interesting point to note, also to do justice to previous committers 
> who have put this feature in place, is that this was not always the case. In 
> the following links, you may see the same links to the older versions of the 
> same pages. In the past, all vendors indicated that Connection is fully 
> thread-safe; [Postgres|https://www.postgresql.org/docs/7.1/jdbc-thread.html], 
> [Oracle|https://docs.oracle.com/cd/A97335_02/apps.102/a83724/tips1.htm], 
> [MSSQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/6.1.0.jre7/com/microsoft/sqlserver/jdbc/SQLServerConnection.html].
>  
> Hence, it was once safe to expose Connection objects via JMX given the 
> thread-safety guarantees for the underlying vendor connection were in place. 
> But as Vendors dropped the thread-safety guarantee one by one, it is not safe 
> anymore, and may actually cause convoluted errors that pop up intermittently 
> due to thread races in the JDBC driver code (see an example in the comments 
> section below). Accordingly, exposing Connections via JMX shall be retired 
> along with dropped support from most vendors. 
> Note: the Datasource MBeans, which provide a vital set of metrics have no 
> such problems as they don't depend on the underlying JDBC provider.


[jira] [Work logged] (DBCP-585) Connection level JMX queries result in concurrent access to connection objects, causing errors

2022-04-10 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/DBCP-585?focusedWorklogId=755061&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-755061
 ]

ASF GitHub Bot logged work on DBCP-585:
---

Author: ASF GitHub Bot
Created on: 11/Apr/22 00:06
Start Date: 11/Apr/22 00:06
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on PR #179:
URL: https://github.com/apache/commons-dbcp/pull/179#issuecomment-1094417650

   [DBCP-585](https://issues.apache.org/jira/browse/DBCP-585)




Issue Time Tracking
---

Worklog Id: (was: 755061)
Time Spent: 20m  (was: 10m)

> Connection level JMX queries result in concurrent access to connection 
> objects, causing errors
> --
>
> Key: DBCP-585
> URL: https://issues.apache.org/jira/browse/DBCP-585
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: Kurtcebe Eroglu
>Priority: Major
> Attachments: 0001-DBCP-585-idea-clarification-1.patch, 
> conn_instance_attrs.png, connections_attrs.png, ds_attrs.png, final.png
>
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> As we expose Connection objects over JMX, they may be accessed by multiple 
> threads concurrently; 
> a) an application thread that borrows the Connection and uses it business as 
> usual,
> b) another thread simultaneously performing a JMX query, which in turn calls 
> getters on the same connection object via the MBean interface.
> Also, calls to Connection object getters are mostly delegated to the 
> underlying vendor-specific connection provided by the JDBC driver. For 
> example, when we make the JMX query to get the "schema" attribute of the JMX 
> connection object, this is translated into a 
> "java.sql.Connection.getSchema()", and passed to the vendor-specific 
> Connection object by DBCP. In the case of Postgres, for example, this is 
> further translated to a query "select current_schema()" and sent to the 
> server.
> Hence, querying connections over JMX result in concurrent access by multiple 
> threads to the underlying Connection provided by the vendors, to the point 
> that these two threads may be running queries simultaneously on the same 
> connection. 
> However, this is not supported by any of the major database vendors. Vendor 
> links on Connection objects not being threadsafe:
>  - [Postgres|https://jdbc.postgresql.org/documentation/head/thread.html]
> {quote}The PostgreSQL™ JDBC driver is not thread safe. The PostgreSQL server 
> is not threaded. Each connection creates a new process on the server; as such 
> any concurrent requests to the process would have to be serialized. The 
> driver makes no guarantees that methods on connections are synchronized. It 
> will be up to the caller to synchronize calls to the driver.
> {quote}
>  - 
> [Oracle|https://docs.oracle.com/en/database/oracle/oracle-database/19/jjdbc/JDBC-coding-tips.html#GUID-EE479007-D105-4F82-8D51-000CBBD4BC77]
>  
> {quote}Oracle strongly discourages sharing a database connection among 
> multiple threads. Avoid allowing multiple threads to access a connection 
> simultaneously.
> {quote}
>  - [Microsoft SQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/latest/com.microsoft.sqlserver.jdbc/com/microsoft/sqlserver/jdbc/SQLServerConnection.html]
> {quote}SQLServerConnection is not thread safe, however multiple statements 
> created from a single connection can be processing simultaneously in 
> concurrent threads.
> {quote}
> Another interesting point to note, also to do justice to previous committers 
> who have put this feature in place, is that this was not always the case. In 
> the following links, you may see the same links to the older versions of the 
> same pages. In the past, all vendors indicated that Connection is fully 
> thread-safe; [Postgres|https://www.postgresql.org/docs/7.1/jdbc-thread.html], 
> [Oracle|https://docs.oracle.com/cd/A97335_02/apps.102/a83724/tips1.htm], 
> [MSSQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/6.1.0.jre7/com/microsoft/sqlserver/jdbc/SQLServerConnection.html].
>  
> Hence, it was once safe to expose Connection objects via JMX given the 
> thread-safety guarantees for the underlying vendor connection were in place. 
> But as Vendors dropped the thread-safety guarantee one by one, it is not safe 
> anymore, and may actually cause convoluted errors that pop up intermittently 
> due to thread races in the JDBC driver code (see an example in the comments 
> section below). Accordingly, exposing Connections via JMX shall be retired 
> along with dropped support from most vendors. 
> Note: the Datasource MBeans, which provide a vital set of metrics have no 
> such problems as they do

[jira] [Work logged] (DBCP-585) Connection level JMX queries result in concurrent access to connection objects, causing errors

2022-04-03 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/DBCP-585?focusedWorklogId=752103&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-752103
 ]

ASF GitHub Bot logged work on DBCP-585:
---

Author: ASF GitHub Bot
Created on: 04/Apr/22 06:56
Start Date: 04/Apr/22 06:56
Worklog Time Spent: 10m 
  Work Description: kurtcebe commented on PR #179:
URL: https://github.com/apache/commons-dbcp/pull/179#issuecomment-1087183125

   CI failed as source file length check reported 6 lines over the limit. I've 
amended PR to make the source file shorter.




Issue Time Tracking
---

Worklog Id: (was: 752103)
Remaining Estimate: 0h
Time Spent: 10m

> Connection level JMX queries result in concurrent access to connection 
> objects, causing errors
> --
>
> Key: DBCP-585
> URL: https://issues.apache.org/jira/browse/DBCP-585
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: Kurtcebe Eroglu
>Priority: Major
> Attachments: 0001-DBCP-585-idea-clarification-1.patch, 
> conn_instance_attrs.png, connections_attrs.png, ds_attrs.png, final.png
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> As we expose Connection objects over JMX, they may be accessed by multiple 
> threads concurrently; 
> a) an application thread that borrows the Connection and uses it business as 
> usual,
> b) another thread simultaneously performing a JMX query, which in turn calls 
> getters on the same connection object via the MBean interface.
> Also, calls to Connection object getters are mostly delegated to the 
> underlying vendor-specific connection provided by the JDBC driver. For 
> example, when we make the JMX query to get the "schema" attribute of the JMX 
> connection object, this is translated into a 
> "java.sql.Connection.getSchema()", and passed to the vendor-specific 
> Connection object by DBCP. In the case of Postgres, for example, this is 
> further translated to a query "select current_schema()" and sent to the 
> server.
> Hence, querying connections over JMX result in concurrent access by multiple 
> threads to the underlying Connection provided by the vendors, to the point 
> that these two threads may be running queries simultaneously on the same 
> connection. 
> However, this is not supported by any of the major database vendors. Vendor 
> links on Connection objects not being threadsafe:
>  - [Postgres|https://jdbc.postgresql.org/documentation/head/thread.html]
> {quote}The PostgreSQL™ JDBC driver is not thread safe. The PostgreSQL server 
> is not threaded. Each connection creates a new process on the server; as such 
> any concurrent requests to the process would have to be serialized. The 
> driver makes no guarantees that methods on connections are synchronized. It 
> will be up to the caller to synchronize calls to the driver.
> {quote}
>  - 
> [Oracle|https://docs.oracle.com/en/database/oracle/oracle-database/19/jjdbc/JDBC-coding-tips.html#GUID-EE479007-D105-4F82-8D51-000CBBD4BC77]
>  
> {quote}Oracle strongly discourages sharing a database connection among 
> multiple threads. Avoid allowing multiple threads to access a connection 
> simultaneously.
> {quote}
>  - [Microsoft SQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/latest/com.microsoft.sqlserver.jdbc/com/microsoft/sqlserver/jdbc/SQLServerConnection.html]
> {quote}SQLServerConnection is not thread safe, however multiple statements 
> created from a single connection can be processing simultaneously in 
> concurrent threads.
> {quote}
> Another interesting point to note, also to do justice to previous committers 
> who have put this feature in place, is that this was not always the case. In 
> the following links, you may see the same links to the older versions of the 
> same pages. In the past, all vendors indicated that Connection is fully 
> thread-safe; [Postgres|https://www.postgresql.org/docs/7.1/jdbc-thread.html], 
> [Oracle|https://docs.oracle.com/cd/A97335_02/apps.102/a83724/tips1.htm], 
> [MSSQL 
> Server|https://www.javadoc.io/doc/com.microsoft.sqlserver/mssql-jdbc/6.1.0.jre7/com/microsoft/sqlserver/jdbc/SQLServerConnection.html].
>  
> Hence, it was once safe to expose Connection objects via JMX given the 
> thread-safety guarantees for the underlying vendor connection were in place. 
> But as Vendors dropped the thread-safety guarantee one by one, it is not safe 
> anymore, and may actually cause convoluted errors that pop up intermittently 
> due to thread races in the JDBC driver code (see an example in the comments 
> section below). Accordingly, exposing Connections via JMX shall be retired 
> along with dropped support from most vendors. 
> Note: the Da