Bug 807674 - JDBC Cache Stores using a JTA Data Source do not participate in cache transactions
JDBC Cache Stores using a JTA Data Source do not participate in cache transac...
Status: ASSIGNED
Product: JBoss Data Grid 6
Classification: JBoss
Component: Infinispan (Show other bugs)
6.0.0
Unspecified Unspecified
low Severity low
: ---
: 7.0.0
Assigned To: Tristan Tarrant
:
: 807675 (view as bug list)
Depends On: 758178
Blocks: 838946
  Show dependency treegraph
 
Reported: 2012-03-28 09:19 EDT by mark yarborough
Modified: 2015-04-02 08:48 EDT (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Known Issue
Doc Text:
In Red Hat JBoss Data Grid's library mode, JDBC cache stores can be configured to use a JTA-aware datasource. However, operations performed on a cache backed by such a store during a JTA transaction will be persisted to the store outside of the transaction's scope. This issue is not applicable to JBoss Data Grid's Remote Client-Server mode because all cache operations are non-transactional. This is a known issue in JBoss Data Grid 6.4 and no workaround is currently available for this issue.
Story Points: ---
Clone Of: 758178
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description mark yarborough 2012-03-28 09:19:34 EDT
+++ This bug was initially created as a clone of Bug #758178 +++

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

--- Additional comment from mgencur@redhat.com on 2011-11-29 08:24:16 EST ---

Created attachment 537984 [details]
Exception thrown

--- Additional comment from mgencur@redhat.com on 2011-11-29 08:25:09 EST ---

Created attachment 537985 [details]
Configs for reproducing the bug

--- Additional comment from mgencur@redhat.com on 2012-02-10 04:52:01 EST ---

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.

--- Additional comment from pjha@redhat.com on 2012-03-04 23:03:17 EST ---

Tristan, is this going to be fixed in ER03 i.e before limited availability release?

--- Additional comment from ttarrant@redhat.com on 2012-03-05 04:05:10 EST ---

Highly unlikely unfortunately

--- Additional comment from mhusnain@redhat.com on 2012-03-22 22:19:50 EDT ---

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.

--- Additional comment from ttarrant@redhat.com on 2012-03-26 04:45:06 EDT ---

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

--- Additional comment from gsheldon@redhat.com on 2012-03-27 21:42:02 EDT ---


    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.

--- Additional comment from mhusnain@redhat.com on 2012-03-27 21:44:18 EDT ---


    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

--- Additional comment from myarboro@redhat.com on 2012-03-28 09:13:22 EDT ---

Tristan indicates that ER6 will contain a work around in the code.
Comment 1 Tristan Tarrant 2012-03-28 09:43:21 EDT
*** Bug 807675 has been marked as a duplicate of this bug. ***
Comment 2 Misha H. Ali 2012-03-28 18:15:30 EDT
    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: None
Comment 3 Tristan Tarrant 2012-04-03 01:43:42 EDT
Deleted Technical Notes Contents.

Old 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: None
Comment 4 mark yarborough 2012-04-04 09:21:06 EDT
    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:
CCFR - Tristan
Comment 5 Tristan Tarrant 2012-04-04 09:25:07 EDT
    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 @@
-CCFR - Tristan+This issue does not apply to JDG Server since all cache operations are non-transactional. For library mode, the user should be aware that persistence to a JTA-aware cache store (JDBC) does not participate in the overall JTA transaction.
Comment 6 Misha H. Ali 2012-04-04 18:27:17 EDT
Need clarification, tristan. It is not clear from the text what exactly is persisted and yet does not participate in the transaction. Can you clarify the blanks:

Despite being made persistent to a JTA-aware cache store, ____ does not participate in the overall JTA transaction.
Comment 7 Tristan Tarrant 2012-04-05 07:32:43 EDT
Actually it's best to reword it as follows:

JDBC cache stores can be configured to use a JTA-aware datasource. However operations performed on a cache backed by such a store during a JTA transaction, will be persisted to the store outside of the transaction's scope.

Is that clearer ?
Comment 8 Misha H. Ali 2012-04-05 10:16:11 EDT
    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,2 @@
-This issue does not apply to JDG Server since all cache operations are non-transactional. For library mode, the user should be aware that persistence to a JTA-aware cache store (JDBC) does not participate in the overall JTA transaction.+In JBoss Data Grid's library mode, JDBC cache stores can be configured to use a JTA-aware datasource. However
+operations performed on a cache backed by such a store during a JTA transaction, will be persisted to the store outside of the transaction's scope. This issue is not applicable to JBoss Data Grid's Remote Client-Server mode because all cache operations are non-transactional.
Comment 9 Misha H. Ali 2012-06-05 23:21:17 EDT
This bug is nominated for JDG 6 GA Release Notes as a known issue. Given no further comments have occurred since Beta on this bug, I'm assuming that the current technical note outlining the problem remains valid.
Comment 10 mark yarborough 2012-11-14 09:42:13 EST
ttarrant will add jira links as appropriate.
Comment 11 mark yarborough 2012-12-05 13:03:42 EST
Per 2012-12-05 triage session with ttarrant, mgencur and company, this fix will break backward compatibility so must be moved to the next major release, JDG 7.0. In the meantime, it should continue to be noted in the release notes for JDG 6.1, etc...
Comment 12 Misha H. Ali 2013-05-06 23:38:42 EDT
Setting flag in case we want to document this as a known issue for 6.2 release notes.

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