Bug 758178 - Jdbc cache stores do not work with ManagedConnectionFactory in a transactional context
Summary: Jdbc cache stores do not work with ManagedConnectionFactory in a transactiona...
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: JBoss Data Grid 6
Classification: JBoss
Component: Infinispan
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: 6.0.0
Assignee: Tristan Tarrant
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 807674 807675
TreeView+ depends on / blocked
 
Reported: 2011-11-29 13:19 UTC by Martin Gencur
Modified: 2025-02-10 03:14 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
: 807674 807675 (view as bug list)
Environment:
Last Closed: 2025-02-10 03:14:27 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Exception thrown (33.30 KB, text/plain)
2011-11-29 13:24 UTC, Martin Gencur
no flags Details
Configs for reproducing the bug (1.17 KB, text/plain)
2011-11-29 13:25 UTC, Martin Gencur
no flags Details
JDG 6.0.0.ER5 + transactional datasource hack (1.92 MB, application/x-java-archive)
2012-03-26 08:45 UTC, Tristan Tarrant
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker AS7-3674 0 Major Open Datasource injected into Infinispan subsystem unable to find active transaction 2017-08-09 09:03:44 UTC
Red Hat Issue Tracker ISPN-2040 0 Major Resolved Workaround for transactional misbehaviour of JDBC store with ManagedConnectionPool 2017-08-09 09:03:44 UTC
Red Hat Issue Tracker ISPN-586 0 Major Resolved ManagedConnectionPool doesn't work in a transactional context 2017-08-09 09:03:44 UTC
Red Hat Issue Tracker ISPN-604 0 None None None Never

Description Martin Gencur 2011-11-29 13:19:14 UTC
Description of problem:

This is probably related to https://issues.jboss.org/browse/ISPN-586.

When I configure a jdbc cache store without specifying connnectionFactoryClass, the ManagedConnectionFactory is used and it cannot acquire a connection to DB:

[java] 13:56:05,419 ERROR [org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory] (MemcachedServerWorker-2-1) ISPN008018: Sql failure retrieving connection from datasource: java.sql.SQLException: javax.resource.ResourceException: Error checking for a transaction...

...the whole exception attached

On the other hand, I was able to connect to the database with SimpleConnectionFactory but this is not usable in production environment.




Version-Release number of selected component (if applicable):

EDG Snapshot from 2011-11-25 (contains JBoss AS 7.1.0.Beta1 "Tesla" and Infinispan 5.1.0-SNAPSHOT)


How reproducible:

Store a cache entry to a cache defined with jdbc-store configuration attached, datasources subsystem configuration attached as well.

As I said, I was able to store a key to the cache store when using SimpleConnectionFactory. I needed to do a few configuration changes, though:

I needed to add the following properties to jdbc-store:

<property name="connectionFactoryClass">org.infinispan.loaders.jdbc.connectionfactory.SimpleConnectionFactory</property>
<property name="driverClass">org.h2.jdbcx.JdbcDataSource</property>
<property name="connectionUrl">jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</property>
<property name="userName">sa</property>

datasources subsystem looked like this:

<datasources>
                <datasource jndi-name="java:jboss/datasources/JdbcDS" enabled="true" use-java-context="true"
                             pool-name="java:jboss/datasources/JdbcDS">
                     <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
                     <driver>h2</driver>
                     <pool></pool>
                     <security>
                         <user-name>sa</user-name>
                         <password>sa</password>
                     </security>
                 </datasource>
                 <drivers>
                     <driver name="h2" module="com.h2database.h2">
                         <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                     </driver>
                 </drivers>
             </datasources>

Another thing that was needed was to add <module name="com.h2database.h2" export="true"/> to ${EDG_HOME}/modules/org/infinispan/cachestore/jdbc/main/module.xml

Comment 1 Martin Gencur 2011-11-29 13:24:16 UTC
Created attachment 537984 [details]
Exception thrown

Comment 2 Martin Gencur 2011-11-29 13:25:09 UTC
Created attachment 537985 [details]
Configs for reproducing the bug

Comment 3 Martin Gencur 2012-02-10 09:52:01 UTC
Just FYI: I created AS7-3674 since I thought it was another problem but it turned out to be the same issue as ISPN-604. So this bug is dependent on AS7-3674 which should be automatically fixed once ISPN-604 is implemented and this change gets into Infinispan subsystem of AS7.

Comment 4 prabhat jha 2012-03-05 04:03:17 UTC
Tristan, is this going to be fixed in ER03 i.e before limited availability release?

Comment 5 Tristan Tarrant 2012-03-05 09:05:10 UTC
Highly unlikely unfortunately

Comment 6 Misha H. Ali 2012-03-23 02:19:50 UTC
The technical_notes? flag indicates that this is a known issue. Please add summarized cause (what caused the issue) and consequence (how the issue manifests) information about this in the Technical Notes field.

Comment 7 Tristan Tarrant 2012-03-26 08:45:06 UTC
Created attachment 572707 [details]
JDG 6.0.0.ER5 + transactional datasource hack

This JAR is identical to the distributed JDG 6.0.0.ER5 JAR with the addition of Mircea's hack to workaround the issue of using a transactional datasource with a cachestore

Comment 8 gsheldon 2012-03-28 01:42:02 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause:When the JDBC Cache Store is configured without specifying connnectionFactoryClass, the ManagedConnectionFactory is selected by default.
Consequence: ManagedConnectionFactory is unable to connect to the database.
Fix: None
Result: Specify connnectionFactoryClass in jdbc cache store prior to attempting a transaction. Failure to do so will result in a connection error via the ManagedConnectionFactory.

Comment 9 Misha H. Ali 2012-03-28 01:44:18 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,4 +1,4 @@
 Cause:When the JDBC Cache Store is configured without specifying connnectionFactoryClass, the ManagedConnectionFactory is selected by default.
 Consequence: ManagedConnectionFactory is unable to connect to the database.
 Fix: None
-Result: Specify connnectionFactoryClass in jdbc cache store prior to attempting a transaction. Failure to do so will result in a connection error via the ManagedConnectionFactory.+Result: None

Comment 10 mark yarborough 2012-03-28 13:13:22 UTC
Tristan indicates that ER6 will contain a work around in the code.

Comment 11 Tristan Tarrant 2012-03-28 13:24:31 UTC
This issue has been cloned to 807674 to track the proper fix (based on ISPN-604). For JDG 6 this workaround solves the problem

Comment 12 Misha H. Ali 2012-04-04 00:48:22 UTC
To include the workaround in the release note, please specify what need to be done as a workaround in the technical notes box in addition to comments/changes to the CCFR information.

Comment 13 Tristan Tarrant 2012-04-04 05:37:16 UTC
Misha, the workaround does not require any user action: it is now built-in behaviour.

Comment 14 Misha H. Ali 2012-06-04 01:08:40 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,4 +1 @@
-Cause:When the JDBC Cache Store is configured without specifying connnectionFactoryClass, the ManagedConnectionFactory is selected by default.
+Previously, when the JDBC Cache Store was configured without specifying connnectionFactoryClass, the ManagedConnectionFactory was selected by default. As a result, ManagedConnectionFactory could not connect to the database. This behavior is now fixed and a connection to the database is established as expected when no connectionFactoryClass is specified for the JDBC Cache Store.-Consequence: ManagedConnectionFactory is unable to connect to the database.
-Fix: None
-Result: None

Comment 15 Misha H. Ali 2012-06-04 02:54:00 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-Previously, when the JDBC Cache Store was configured without specifying connnectionFactoryClass, the ManagedConnectionFactory was selected by default. As a result, ManagedConnectionFactory could not connect to the database. This behavior is now fixed and a connection to the database is established as expected when no connectionFactoryClass is specified for the JDBC Cache Store.+Previously, when the JDBC Cache Store was configured without specifying <classname>connnectionFactoryClass</classname>, the <classname>ManagedConnectionFactory</classname> was selected by default. As a result, <classname>ManagedConnectionFactory</classname> could not connect to the database. This behavior is now fixed and a connection to the database is established as expected when no <classname>connectionFactoryClass</classname> is specified for the JDBC Cache Store.

Comment 18 Red Hat Bugzilla 2025-02-10 03:14:27 UTC
This product has been discontinued or is no longer tracked in Red Hat Bugzilla.


Note You need to log in before you can comment on or make changes to this bug.