1 2 Previous Next 23 Replies Latest reply on Nov 15, 2012 3:16 PM by Adam Warski

    Envers not creating audit entries properly causing AssertionFailures

    Scott Mueller Newbie

      This is critical for us, it seems Envers is corrupting our _AUD audit tables with extra records of REVTYPE=1 which are missing the previous REVEND (we are using the validityAuditStrategy) references.


      mysql> select Id, REV, REVTYPE, REVEND, Day, Hour, Change_Origin_Date_and_Time_Id from Date_and_Time_AUD where Id=36076240;


      | Id       | REV    | REVTYPE | REVEND | Day  | Hour | Change_Origin_Date_and_Time_Id |


      | 36076240 | 244111 |       0 | 244135 | NULL | NULL |                           NULL |

      | 36076240 | 244128 |       1 |   NULL | NULL | NULL |                           NULL |

      | 36076240 | 244135 |       1 |   NULL | NULL | NULL |                           NULL |


      3 rows in set (0.00 sec)


      Our users are then getting errors when updating records because an AssertionFailure occurs:


      2011-09-04 15:48:45,564 ERROR [http-80-45] AssertionFailure - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
      java.lang.RuntimeException: Cannot find previous revision for entity com.mycompany.i18n.DateAndTime_AUD and id 36076240
              at org.hibernate.envers.strategy.ValidityAuditStrategy.updateLastRevision(ValidityAuditStrategy.java:182)
              at org.hibernate.envers.strategy.ValidityAuditStrategy.perform(ValidityAuditStrategy.java:71)
              at org.hibernate.envers.synchronization.work.AbstractAuditWorkUnit.perform(AbstractAuditWorkUnit.java:74)
              at org.hibernate.envers.synchronization.AuditProcess.executeInSession(AuditProcess.java:114)
              at org.hibernate.envers.synchronization.AuditProcess.doBeforeTransactionCompletion(AuditProcess.java:152)
              at org.hibernate.engine.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:543)
              at org.hibernate.engine.ActionQueue.beforeTransactionCompletion(ActionQueue.java:216)
              at org.hibernate.impl.SessionImpl.beforeTransactionCompletion(SessionImpl.java:571)
              at org.hibernate.jdbc.JDBCContext.beforeTransactionCompletion(JDBCContext.java:250)
              at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:138)

      We are using Hibernate (and Envers) v3.6.5.  Everything seemed to be working fine before, we suddenly started receiving tons and tons of these errors and user complaints.  I cannot reproduce this locally and the error doesn't ALWAYS (though more and more frequently) happen in production.  I've restarted production, redeployed, etc. to no avail.  This ONLY happens on our DateAndTime class for some reason, which is not much different from the MANY other hibernate managed entities which are frequently created and updated in production.  After the above error occurs (and the user is sufficiently annoyed), a new revision is created kind of correcting the problem where the first revision's REVEND now refers to the new revision (skipping the corrupted revision).


      Any ideas?

        1 2 Previous Next