You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by "David Sean Taylor (JIRA)" <je...@portals.apache.org> on 2006/02/10 20:25:56 UTC

[jira] Created: (JS2-495) OJB + Spring Transactions broken

OJB + Spring Transactions broken
--------------------------------

         Key: JS2-495
         URL: http://issues.apache.org/jira/browse/JS2-495
     Project: Jetspeed 2
        Type: Bug
  Components: Persistence and DAO  
    Versions: 2.1-dev    
    Reporter: David Sean Taylor
 Assigned to: David Sean Taylor 
    Priority: Critical
     Fix For: 2.1-dev


I tried writing a unit test to test OJB + Spring transactions.
To my suprise, transactions are not starting.

In fact, Im seeing some surprising results in mysql.log
(yes Im using InnoDB), note no transactions, and the forced autocommit

118 Query       SET autocommit=1
117 Prepare     [1] INSERT INTO FOLDER...
117 Execute     [1] INSERT INTO FOLDER...        
117 Query       SET autocommit=1


It appears that OJB repeatedly sets autocommit=1
and
it never starts any transactions

Here is my unit test, which tests out a new 'fake' API addPage to the PageManager. This API is temporary to test transactional behavior:

public void testTx() throws Exception
    {
        Folder root = pageManager.newFolder("/");
        pageManager.updateFolder(root);
        Page[] pages = new Page[3];
        pages[0] = pageManager.newPage("/test1.psml");
        pages[1] = pageManager.newPage("/test2.psml");
        pages[2] = pageManager.newPage("/test3.psml");
        try
        {
            pageManager.addPages(pages);
        }

In addPages, I try to force a rollback:

    public int addPages(Page[] pages)
    throws JetspeedException
    {
        System.out.println("Adding first page");
        this.updatePage(pages[0]);
        System.out.println("Adding second page");
        this.updatePage(pages[1]);
        System.out.println("About to throw ex");
        throw new JetspeedException("Its gonna blow captain!");
    }

Finally, add pages is enabled for a Spring tx:

                <prop key="addPages*">PROPAGATION_REQUIRED,-org.apache.jetspeed.exception.JetspeedException</prop>


-- 
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


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


[jira] Resolved: (JS2-495) OJB + Spring Transactions broken

Posted by "David Sean Taylor (JIRA)" <je...@portals.apache.org>.
     [ http://issues.apache.org/jira/browse/JS2-495?page=all ]

David Sean Taylor resolved JS2-495.
-----------------------------------

    Resolution: Fixed

We've done a lot of testing on this issue over the last 6 months.
I have no outstanding bugs on client bug tracking systems, so I will also resolve it here.

> OJB + Spring Transactions broken
> --------------------------------
>
>                 Key: JS2-495
>                 URL: http://issues.apache.org/jira/browse/JS2-495
>             Project: Jetspeed 2
>          Issue Type: Bug
>          Components: Persistence and DAO
>    Affects Versions: 2.1-dev
>            Reporter: David Sean Taylor
>         Assigned To: David Sean Taylor
>            Priority: Critical
>             Fix For: 2.1-dev
>
>         Attachments: Chatty.zip
>
>
> I tried writing a unit test to test OJB + Spring transactions.
> To my suprise, transactions are not starting.
> In fact, Im seeing some surprising results in mysql.log
> (yes Im using InnoDB), note no transactions, and the forced autocommit
> 118 Query       SET autocommit=1
> 117 Prepare     [1] INSERT INTO FOLDER...
> 117 Execute     [1] INSERT INTO FOLDER...        
> 117 Query       SET autocommit=1
> It appears that OJB repeatedly sets autocommit=1
> and
> it never starts any transactions
> Here is my unit test, which tests out a new 'fake' API addPage to the PageManager. This API is temporary to test transactional behavior:
> public void testTx() throws Exception
>     {
>         Folder root = pageManager.newFolder("/");
>         pageManager.updateFolder(root);
>         Page[] pages = new Page[3];
>         pages[0] = pageManager.newPage("/test1.psml");
>         pages[1] = pageManager.newPage("/test2.psml");
>         pages[2] = pageManager.newPage("/test3.psml");
>         try
>         {
>             pageManager.addPages(pages);
>         }
> In addPages, I try to force a rollback:
>     public int addPages(Page[] pages)
>     throws JetspeedException
>     {
>         System.out.println("Adding first page");
>         this.updatePage(pages[0]);
>         System.out.println("Adding second page");
>         this.updatePage(pages[1]);
>         System.out.println("About to throw ex");
>         throw new JetspeedException("Its gonna blow captain!");
>     }
> Finally, add pages is enabled for a Spring tx:
>                 <prop key="addPages*">PROPAGATION_REQUIRED,-org.apache.jetspeed.exception.JetspeedException</prop>

-- 
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

        

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


[jira] Updated: (JS2-495) OJB + Spring Transactions broken

Posted by "David Sean Taylor (JIRA)" <je...@portals.apache.org>.
     [ http://issues.apache.org/jira/browse/JS2-495?page=all ]

David Sean Taylor updated JS2-495:
----------------------------------

    Attachment: Chatty.zip

MySQL logs for addPages operation under DB Page Manager 

> OJB + Spring Transactions broken
> --------------------------------
>
>          Key: JS2-495
>          URL: http://issues.apache.org/jira/browse/JS2-495
>      Project: Jetspeed 2
>         Type: Bug
>   Components: Persistence and DAO
>     Versions: 2.1-dev
>     Reporter: David Sean Taylor
>     Assignee: David Sean Taylor
>     Priority: Critical
>      Fix For: 2.1-dev
>  Attachments: Chatty.zip
>
> I tried writing a unit test to test OJB + Spring transactions.
> To my suprise, transactions are not starting.
> In fact, Im seeing some surprising results in mysql.log
> (yes Im using InnoDB), note no transactions, and the forced autocommit
> 118 Query       SET autocommit=1
> 117 Prepare     [1] INSERT INTO FOLDER...
> 117 Execute     [1] INSERT INTO FOLDER...        
> 117 Query       SET autocommit=1
> It appears that OJB repeatedly sets autocommit=1
> and
> it never starts any transactions
> Here is my unit test, which tests out a new 'fake' API addPage to the PageManager. This API is temporary to test transactional behavior:
> public void testTx() throws Exception
>     {
>         Folder root = pageManager.newFolder("/");
>         pageManager.updateFolder(root);
>         Page[] pages = new Page[3];
>         pages[0] = pageManager.newPage("/test1.psml");
>         pages[1] = pageManager.newPage("/test2.psml");
>         pages[2] = pageManager.newPage("/test3.psml");
>         try
>         {
>             pageManager.addPages(pages);
>         }
> In addPages, I try to force a rollback:
>     public int addPages(Page[] pages)
>     throws JetspeedException
>     {
>         System.out.println("Adding first page");
>         this.updatePage(pages[0]);
>         System.out.println("Adding second page");
>         this.updatePage(pages[1]);
>         System.out.println("About to throw ex");
>         throw new JetspeedException("Its gonna blow captain!");
>     }
> Finally, add pages is enabled for a Spring tx:
>                 <prop key="addPages*">PROPAGATION_REQUIRED,-org.apache.jetspeed.exception.JetspeedException</prop>

-- 
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


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


[jira] Commented: (JS2-495) OJB + Spring Transactions broken

Posted by "David Sean Taylor (JIRA)" <je...@portals.apache.org>.
    [ http://issues.apache.org/jira/browse/JS2-495?page=comments#action_12367155 ] 

David Sean Taylor commented on JS2-495:
---------------------------------------

Tried running the Page Manager's TestTransactions with the following changes:

1. use this datasource

    <bean id="JetspeedDS" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
                <property name="url"><value>jdbc:mysql://localhost/j2test</value></property>
                <property name="username"><value>j2</value></property>
                <property name="password"><value>ainttelling</value></property>
        </bean>    

2. added this bean to the configuration:

    <bean id="ojbConfigurer" class="org.springframework.orm.ojb.support.LocalOjbConfigurer"/>

3. changed OJB settings

 ConnectionFactoryClass=org.springframework.orm.ojb.support.LocalDataSourceConnectionFactory 
ConnectionManagerClass=org.apache.ojb.broker.accesslayer.ConnectionManagerImpl 

And the transaction rolled back successfully (although the Page Managers cache was out of sync)



> OJB + Spring Transactions broken
> --------------------------------
>
>          Key: JS2-495
>          URL: http://issues.apache.org/jira/browse/JS2-495
>      Project: Jetspeed 2
>         Type: Bug
>   Components: Persistence and DAO
>     Versions: 2.1-dev
>     Reporter: David Sean Taylor
>     Assignee: David Sean Taylor
>     Priority: Critical
>      Fix For: 2.1-dev

>
> I tried writing a unit test to test OJB + Spring transactions.
> To my suprise, transactions are not starting.
> In fact, Im seeing some surprising results in mysql.log
> (yes Im using InnoDB), note no transactions, and the forced autocommit
> 118 Query       SET autocommit=1
> 117 Prepare     [1] INSERT INTO FOLDER...
> 117 Execute     [1] INSERT INTO FOLDER...        
> 117 Query       SET autocommit=1
> It appears that OJB repeatedly sets autocommit=1
> and
> it never starts any transactions
> Here is my unit test, which tests out a new 'fake' API addPage to the PageManager. This API is temporary to test transactional behavior:
> public void testTx() throws Exception
>     {
>         Folder root = pageManager.newFolder("/");
>         pageManager.updateFolder(root);
>         Page[] pages = new Page[3];
>         pages[0] = pageManager.newPage("/test1.psml");
>         pages[1] = pageManager.newPage("/test2.psml");
>         pages[2] = pageManager.newPage("/test3.psml");
>         try
>         {
>             pageManager.addPages(pages);
>         }
> In addPages, I try to force a rollback:
>     public int addPages(Page[] pages)
>     throws JetspeedException
>     {
>         System.out.println("Adding first page");
>         this.updatePage(pages[0]);
>         System.out.println("Adding second page");
>         this.updatePage(pages[1]);
>         System.out.println("About to throw ex");
>         throw new JetspeedException("Its gonna blow captain!");
>     }
> Finally, add pages is enabled for a Spring tx:
>                 <prop key="addPages*">PROPAGATION_REQUIRED,-org.apache.jetspeed.exception.JetspeedException</prop>

-- 
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


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


[jira] Commented: (JS2-495) OJB + Spring Transactions broken

Posted by "David Sean Taylor (JIRA)" <je...@portals.apache.org>.
    [ http://issues.apache.org/jira/browse/JS2-495?page=comments#action_12367685 ] 

David Sean Taylor commented on JS2-495:
---------------------------------------

The unit tests are passing, rollbacks execute correctly in unit test, and the cache is now rolling back.
I deployed to a Tomcat, and the rollbacks quit working.  This had me stumped for a bit.
Well interesting enough, it seems that a commit was getting in before my rollback, which tells me that OJB has some problem with ordering of DML.
Where was the commit coming from?
A very db-chatty implementation of the DB Page Manager, as it writes upon what I would expect to be read only operations.
When we build the menus and tabs to be displayed for a page, there is an awful lot of database activity, including writes.
It seems that these writes are atomic, and are forcing a commit on a shared connection with my test code (a portlet action) that executes the addPages API
(see SiteBrowserPortlet.java, txTest() method)
See attached chatty.log for database activity details
Im leaving this open until I can figure out why the commit was slipping in before the rollback.


> OJB + Spring Transactions broken
> --------------------------------
>
>          Key: JS2-495
>          URL: http://issues.apache.org/jira/browse/JS2-495
>      Project: Jetspeed 2
>         Type: Bug
>   Components: Persistence and DAO
>     Versions: 2.1-dev
>     Reporter: David Sean Taylor
>     Assignee: David Sean Taylor
>     Priority: Critical
>      Fix For: 2.1-dev

>
> I tried writing a unit test to test OJB + Spring transactions.
> To my suprise, transactions are not starting.
> In fact, Im seeing some surprising results in mysql.log
> (yes Im using InnoDB), note no transactions, and the forced autocommit
> 118 Query       SET autocommit=1
> 117 Prepare     [1] INSERT INTO FOLDER...
> 117 Execute     [1] INSERT INTO FOLDER...        
> 117 Query       SET autocommit=1
> It appears that OJB repeatedly sets autocommit=1
> and
> it never starts any transactions
> Here is my unit test, which tests out a new 'fake' API addPage to the PageManager. This API is temporary to test transactional behavior:
> public void testTx() throws Exception
>     {
>         Folder root = pageManager.newFolder("/");
>         pageManager.updateFolder(root);
>         Page[] pages = new Page[3];
>         pages[0] = pageManager.newPage("/test1.psml");
>         pages[1] = pageManager.newPage("/test2.psml");
>         pages[2] = pageManager.newPage("/test3.psml");
>         try
>         {
>             pageManager.addPages(pages);
>         }
> In addPages, I try to force a rollback:
>     public int addPages(Page[] pages)
>     throws JetspeedException
>     {
>         System.out.println("Adding first page");
>         this.updatePage(pages[0]);
>         System.out.println("Adding second page");
>         this.updatePage(pages[1]);
>         System.out.println("About to throw ex");
>         throw new JetspeedException("Its gonna blow captain!");
>     }
> Finally, add pages is enabled for a Spring tx:
>                 <prop key="addPages*">PROPAGATION_REQUIRED,-org.apache.jetspeed.exception.JetspeedException</prop>

-- 
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


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


[jira] Commented: (JS2-495) OJB + Spring Transactions broken

Posted by "David Sean Taylor (JIRA)" <je...@portals.apache.org>.
    [ http://issues.apache.org/jira/browse/JS2-495?page=comments#action_12367151 ] 

David Sean Taylor commented on JS2-495:
---------------------------------------

Just ran a test *outside* of Jetspeed on another Spring + OJB project here.
Result: transactional commits and rollbacks work as expected
So Im left wondering what we've broken here, as I was sure transactions were operational once upon a time.

Im summing up the differences:

-- Datasource --
other project:   org.springframework.jdbc.datasource.DriverManagerDataSource
Jetspeed    :     org.apache.jetspeed.components.rdbms.ojb.ConnectionRepositoryEntry

-- OJB.properties --
other project:   ConnectionFactoryClass=org.springframework.orm.ojb.support.LocalDataSourceConnectionFactory
Jetspeed:  ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl

other project:  ConnectionManagerClass=org.apache.ojb.broker.accesslayer.ConnectionManagerImpl
Jetspeed: ConnectionManagerClass=org.apache.jetspeed.components.rdbms.ojb.ConnectionManagerImpl

All other configuration files seem to be the same



> OJB + Spring Transactions broken
> --------------------------------
>
>          Key: JS2-495
>          URL: http://issues.apache.org/jira/browse/JS2-495
>      Project: Jetspeed 2
>         Type: Bug
>   Components: Persistence and DAO
>     Versions: 2.1-dev
>     Reporter: David Sean Taylor
>     Assignee: David Sean Taylor
>     Priority: Critical
>      Fix For: 2.1-dev

>
> I tried writing a unit test to test OJB + Spring transactions.
> To my suprise, transactions are not starting.
> In fact, Im seeing some surprising results in mysql.log
> (yes Im using InnoDB), note no transactions, and the forced autocommit
> 118 Query       SET autocommit=1
> 117 Prepare     [1] INSERT INTO FOLDER...
> 117 Execute     [1] INSERT INTO FOLDER...        
> 117 Query       SET autocommit=1
> It appears that OJB repeatedly sets autocommit=1
> and
> it never starts any transactions
> Here is my unit test, which tests out a new 'fake' API addPage to the PageManager. This API is temporary to test transactional behavior:
> public void testTx() throws Exception
>     {
>         Folder root = pageManager.newFolder("/");
>         pageManager.updateFolder(root);
>         Page[] pages = new Page[3];
>         pages[0] = pageManager.newPage("/test1.psml");
>         pages[1] = pageManager.newPage("/test2.psml");
>         pages[2] = pageManager.newPage("/test3.psml");
>         try
>         {
>             pageManager.addPages(pages);
>         }
> In addPages, I try to force a rollback:
>     public int addPages(Page[] pages)
>     throws JetspeedException
>     {
>         System.out.println("Adding first page");
>         this.updatePage(pages[0]);
>         System.out.println("Adding second page");
>         this.updatePage(pages[1]);
>         System.out.println("About to throw ex");
>         throw new JetspeedException("Its gonna blow captain!");
>     }
> Finally, add pages is enabled for a Spring tx:
>                 <prop key="addPages*">PROPAGATION_REQUIRED,-org.apache.jetspeed.exception.JetspeedException</prop>

-- 
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


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org