We've had a number of support issues with this error in the logs:

      ERROR org.hibernate.event.def.AbstractFlushingEventListener: Could not synchronize database state with session
      org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

      The Crowd method which causes this error varies. I will link related support issues for dev review.

            [CWD-2703] Hibernate StaleStateExceptions in Crowd

            Any solution?

            Fabrizio Galletti added a comment - Any solution?

            Ken Hill added a comment -

            Yes, this is still occurring in 2.7.0.

            Ken Hill added a comment - Yes, this is still occurring in 2.7.0.

            Faced with the same exceptions in 2.6.4. Is this bug present in Crowd 2.7?

            Oleksiy Brushkovskyy added a comment - Faced with the same exceptions in 2.6.4. Is this bug present in Crowd 2.7?

            April added a comment -

            We also have this with v2.6.4 (in brief):
            2013-09-03 17:49:39,685 http-8443-10 ERROR [org.hibernate.jdbc.AbstractBatcher] Exception executing batch:
            org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
            ...
            2013-09-03 17:49:39,687 http-8443-10 ERROR [hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session
            org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
            ...
            2013-09-03 17:49:39,689 http-8443-10 ERROR [[Catalina].[localhost].[/crowd].[default]] Servlet.service() for servlet default threw exception
            org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
            ...
            2013-09-03 17:49:39,692 http-8443-10 ERROR [500ErrorPage] Exception caught in 500 page Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
            org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

            April added a comment - We also have this with v2.6.4 (in brief): 2013-09-03 17:49:39,685 http-8443-10 ERROR [org.hibernate.jdbc.AbstractBatcher] Exception executing batch: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0] ; actual row count: 0; expected: 1 ... 2013-09-03 17:49:39,687 http-8443-10 ERROR [hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0] ; actual row count: 0; expected: 1 ... 2013-09-03 17:49:39,689 http-8443-10 ERROR [ [Catalina] . [localhost] . [/crowd] . [default] ] Servlet.service() for servlet default threw exception org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0] ; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0] ; actual row count: 0; expected: 1 ... 2013-09-03 17:49:39,692 http-8443-10 ERROR [500ErrorPage] Exception caught in 500 page Batch update returned unexpected row count from update [0] ; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0] ; actual row count: 0; expected: 1 org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0] ; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0] ; actual row count: 0; expected: 1

            This might not actually be the same root cause identified here. I'll work through and comment again if this needs further attention.

            Ryan Goodwin (Inactive) added a comment - This might not actually be the same root cause identified here. I'll work through and comment again if this needs further attention.

            ERROR [hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session
            org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
            	at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:85)
            	at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:70)
            	at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:90)
            	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
            	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
            	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:262)
            	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:179)
            

            Ryan Goodwin (Inactive) added a comment - ERROR [hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:85) at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:70) at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:90) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:262) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:179)

            This needs to be reopened as it is still occurring in Crowd 2.6.4.

            ERROR [500ErrorPage] Exception caught in 500 page Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
            org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
            	at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:686)
            	at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:793)
            	at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:664)
            	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
            	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
            	at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:387)
            	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
            	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
            	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
            	at $Proxy19.validateApplicationToken(Unknown Source)
            

            Ryan Goodwin (Inactive) added a comment - This needs to be reopened as it is still occurring in Crowd 2.6.4. ERROR [500ErrorPage] Exception caught in 500 page Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:686) at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:793) at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:664) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:387) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy19.validateApplicationToken(Unknown Source)

            Same with a customers' Crowd instance 2.6.4. How to resolve?

            Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into cwd_token (directory_id, entity_name, random_number, identifier_hash, random_hash, created_date, last_accesse
            d_date, last_accessed_time, duration, id) values ('-1', 'confluence', '1713930080594178013', 'USST2wTeLIe8kyLtPL5LtA00', 'XdjIkPsOvx7cjAB8uOX4tw00', '2013-07-29 14:58:07.628000 
            +02:00:00', '2013-07-29 14:58:07.628000 +02:00:00', '1375102687628', NULL, '1312568') was aborted.  Call getNextException to see the cause.
                    at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2598)
                    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
                    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
                    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2737)
                    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
                    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
                    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
                    ... 75 more
            

            Michiel Nieuwstraten added a comment - Same with a customers' Crowd instance 2.6.4. How to resolve? Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into cwd_token (directory_id, entity_name, random_number, identifier_hash, random_hash, created_date, last_accesse d_date, last_accessed_time, duration, id) values ( '-1' , 'confluence' , '1713930080594178013' , 'USST2wTeLIe8kyLtPL5LtA00' , 'XdjIkPsOvx7cjAB8uOX4tw00' , '2013-07-29 14:58:07.628000 +02:00:00 ', ' 2013-07-29 14:58:07.628000 +02:00:00 ', ' 1375102687628 ', NULL, ' 1312568') was aborted. Call getNextException to see the cause. at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2598) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2737) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268) ... 75 more

            xmonit added a comment -

            We are seeing it in 2.4.2 as well. Our Confluence is not getting synchronized with Crowd directory and we see this in the logs near the other exception:

            Batch entry 0 insert into cwd_token (directory_id, entity_name, random_number, identifier_hash, random_hash, created_date, last_accessed_date, id) values ('1409028', 'confluence', '4225117947427257002', 'jo7e1ocnYsxHcBJLaqS0hw00', 'DnQ5bnDycsWAHkiZ0BXTDQ00', '2013-06-27 13:25:38.860000 -07:00:00', '2013-06-27 13:25:38.860000 -07:00:00', '13473755') was aborted. Call getNextException to see the cause.

            Jira seems to be getting synchronized okay though.

            xmonit added a comment - We are seeing it in 2.4.2 as well. Our Confluence is not getting synchronized with Crowd directory and we see this in the logs near the other exception: Batch entry 0 insert into cwd_token (directory_id, entity_name, random_number, identifier_hash, random_hash, created_date, last_accessed_date, id) values ('1409028', 'confluence', '4225117947427257002', 'jo7e1ocnYsxHcBJLaqS0hw00', 'DnQ5bnDycsWAHkiZ0BXTDQ00', '2013-06-27 13:25:38.860000 -07:00:00', '2013-06-27 13:25:38.860000 -07:00:00', '13473755') was aborted. Call getNextException to see the cause. Jira seems to be getting synchronized okay though.

            uvoellger added a comment -

            Hi,

            In Crowd 2.5.1 this problem is still existing, Tomcat version is 6.0.32, please reopen this issue.

            Thanks and Regards
            Uwe

            uvoellger added a comment - Hi, In Crowd 2.5.1 this problem is still existing, Tomcat version is 6.0.32, please reopen this issue. Thanks and Regards Uwe

              justin@atlassian.com Justin Koke
              13e918c6b49b José M. Arnesto
              Affected customers:
              3 This affects my team
              Watchers:
              22 Start watching this issue

                Created:
                Updated:
                Resolved: