Uploaded image for project: 'Confluence Server'
  1. Confluence Server
  2. CONFSERVER-43537

Confluence throws java.lang.IllegalStateException: ClobStringType requires active transaction synchronization

    XMLWordPrintable

    Details

    • Symptom Severity:
      Severity 3 - Minor
    • Support reference count:
      31
    • Testing Notes:
      Hide

      At this time, I only find one way to consistently reproduce this issue. And I think there might have other methods to reproduce, especially with add-ons.

      Please follow the steps to reproduce,

      • start a test Confluence instance and install the ScriptRunner for Confluence addon
      • goto "Confluence Administration-->Script Console", and copy the script below into the script textbox
      • click "Run" and observe the IllegalStateException being thrown out on Confluence console
      //groovy
      import com.atlassian.confluence.pages.Page
      import com.atlassian.confluence.pages.PageManager
      import com.atlassian.confluence.spaces.Space
      import com.atlassian.confluence.spaces.SpaceManager
      import com.atlassian.confluence.pages.Comment
      import com.atlassian.confluence.pages.CommentManager
      import com.atlassian.sal.api.component.ComponentLocator
      import com.atlassian.confluence.core.DefaultSaveContext
      
      def spaceManager = ComponentLocator.getComponent(SpaceManager)
      def pageManager = ComponentLocator.getComponent(PageManager)
      def commentManager = ComponentLocator.getComponent(CommentManager)
      
      Space space = spaceManager.allSpaces.findAll {
          it.isGlobal()
      }[0]
      Page homePage = pageManager.getPages(space, true)[0]
      
      Page page = new Page(space: space, title: "test page " + System.currentTimeMillis(), parentPage: homePage, bodyAsString: "test")   
      pageManager.saveContentEntity(page, DefaultSaveContext.DEFAULT)                     
      def comment = commentManager.addCommentToObject(page, null, "parent comment")           
      def subcomment = commentManager.addCommentToObject(page, comment, "child comment")
      
      

      Next, let's apply the fix and rerun the script above.

      To apply the fix, please check out the branch issue-510/CONF-43537 and run the same script, this time, it should not have IllegalStateException at Confluence console.

      Show
      At this time, I only find one way to consistently reproduce this issue. And I think there might have other methods to reproduce, especially with add-ons. Please follow the steps to reproduce, start a test Confluence instance and install the ScriptRunner for Confluence addon goto "Confluence Administration-->Script Console", and copy the script below into the script textbox click "Run" and observe the IllegalStateException being thrown out on Confluence console //groovy import com.atlassian.confluence.pages.Page import com.atlassian.confluence.pages.PageManager import com.atlassian.confluence.spaces.Space import com.atlassian.confluence.spaces.SpaceManager import com.atlassian.confluence.pages.Comment import com.atlassian.confluence.pages.CommentManager import com.atlassian.sal.api.component.ComponentLocator import com.atlassian.confluence.core.DefaultSaveContext def spaceManager = ComponentLocator.getComponent(SpaceManager) def pageManager = ComponentLocator.getComponent(PageManager) def commentManager = ComponentLocator.getComponent(CommentManager) Space space = spaceManager.allSpaces.findAll { it.isGlobal() }[0] Page homePage = pageManager.getPages(space, true )[0] Page page = new Page(space: space, title: "test page " + System .currentTimeMillis(), parentPage: homePage, bodyAsString: "test" ) pageManager.saveContentEntity(page, DefaultSaveContext.DEFAULT) def comment = commentManager.addCommentToObject(page, null , "parent comment" ) def subcomment = commentManager.addCommentToObject(page, comment, "child comment" ) Next, let's apply the fix and rerun the script above. To apply the fix, please check out the branch issue-510/ CONF-43537 and run the same script, this time, it should not have IllegalStateException at Confluence console.

      Description

      Summary

      Confluence throws java.lang.IllegalStateException: ClobStringType requires active transaction synchronization in the log files.

      This is often followed by the same error as logged in CONF-43246, however the steps to reproduce net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 29261827, of class: com.atlassian.confluence.pages.Page in that ticket does not generate this error.

      Environment

      Based on investigation of support tickets, I have seen this error in:

      Database

      • Microsoft SQL Server
      • MySQL
      • PostgreSQL
      • Oracle 12c

      Add-Ons

      The only Add-ons in common for the customer issues were all default Confluence Add-Ons

      • atlassian-gadgets-shared-3.3.24.jar
      • com.springsource.net.jcip.annotations-1.0.0
      • crowd.system.passwordencoders
      • org.apache.servicemix.bundles.spring-jdbc-4.2.0.RELEASE_2
      • org.apache.servicemix.bundles.spring-tx-4.2.0.RELEASE_2
      • org.randombits.confluence.toc

      Bob Swift related error

      This issue was logged with Bob Swift (SQL-446) although the fix there was to remove RandomBits Add-Ons. As shown above, not all customers have this Add-On (except the for default toc), so this is likely a red herring.

      Steps to Reproduce

      Source code

      Error comes from here, but it's unclear how it's caused.

      package com.atlassian.confluence.web.filter.ConfluenceOpenSessionInViewFilter#closeSession
      // We have to make sure that we throw NO exceptions from this method, or we just end up masking problems
      // in the Spring session filter (the terrible ClobStringType requires active txn sync bug..), and we also
      // interrupt the session cleanup and leak db connections. - cm
      @Override
      protected void closeSession(Session session, SessionFactory sessionFactory) {
          if (session != null && session.isOpen() && session.isConnected() && session.getFlushMode() != FlushMode.NEVER) {
              try {
                  session.flush();
              } catch (Exception e) {
                  log.error("Unable to flush Hibernate session. Possible data loss: " + e.getMessage(), e);
              } finally {
                  super.closeSession(session, sessionFactory);
              }
          }
      }
      
      
      
      

      Unable to reproduce at this time.

      Expected Results

      Logs have no error.

      Actual Results

      Logs throw

      2016-07-31 09:09:21,804 ERROR [http-nio-80-exec-21] [atlassian.spring.filter.FlushingSpringSessionInViewFilter] closeSession Unable to flush Hibernate session. Possible data loss: ClobStringType requires active transaction synchronization
       -- traceId: f5a84584a0aace71
      java.lang.IllegalStateException: ClobStringType requires active transaction synchronization
          at com.atlassian.hibernate.BucketClobStringType.nullSafeSet(BucketClobStringType.java:118)
          at net.sf.hibernate.type.CustomType.nullSafeSet(CustomType.java:118)
          at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:387)
          at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:651)
          at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:630)
          at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)
          at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2476)
          at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2462)
          at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2420)
          at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2288)
          at com.atlassian.spring.filter.FlushingSpringSessionInViewFilter.closeSession(FlushingSpringSessionInViewFilter.java:46)
      ...
          at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContext(VCacheRequestContextManager.java:82)
          at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContext(VCacheRequestContextManager.java:72)
      ...
          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502)
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
          at java.lang.Thread.run(Thread.java:745)
      
      
      
      
      

      Notes

      There are quite a few tickets from Confluence 1.0 days that have this same error. It is unlikely to be a regression.

      It may be based on a timeout issue. Usually occurs when returning to the Dashboard, which is why is occurs often with CONF-43246.

      Workaround

      There is no Workaround.

      More Information Required

      To further troubleshoot this we need to be able to reproduce it. To figure out how to do that, we would like to look at instances which have access logging enabled, to try and establish usage patterns that immediately precede this error. So far we have seen login and dashboard requests immediately preceding, but we don't have enough data for this to be statistically significant, given that these are two extremely common actions.

      If you are experiencing this error and would be able to work with us to troubleshoot it, please raise a Support Request.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                27 Vote for this issue
                Watchers:
                42 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Last commented:
                  2 years, 12 weeks, 3 days ago