8 Replies Latest reply on Jun 27, 2013 12:09 PM by Adam Warski

    Envers without a central REVINFO table

    moriarty-s3a Newbie

      We are looking to use Envers for a new project.  For this project, we don't care whether entites were modified in the same transaction only when each change was made, so the central REVINFO table doesn't help us.  For that reason, I was trying to see what we would need to modify to make work without REVINFO.  It doesn't appear that it would be too hard, a new AuditStrategy implementation and slight modifications to, or a new implementation of, AuditProcess, AuditProcessManager, and RevisionsOfEntityQuery. 


      Has anyone tried this before? 


      If not, and we decide to go this route, would there be any interest in us committing this change back to Envers?



        • 1. Re: Envers without a central REVINFO table
          Adam Warski Master

          I'm not aware of anything similar being implemented. Why don't you want the REVINFO table in the first place?



          • 2. Re: Envers without a central REVINFO table
            moriarty-s3a Newbie

            We are converting from a custom centralized change audit that logged to a single table.  It has proved to be unwieldy to find changes and to have unacceptable performance because of the insert to a central table no matter what is changed.  We don't have that many changes (2-3 million per week), but they are strongly clustered temporally.  Most of our changes happen in two separate three to four hour periods each week.  We can keep up, but it causes some performance issues periodically. 

            While we were reviewing what we really wanted out of our audit system, we realized that we don't really care if we know which group of changes were made in a single transaction, or even in what order changes occured.  We only care when and by whom each change was made.  It doesn't matter what a given Entity looked like at 8:47 UTC as opposed to 8:51 UTC as long as we can say that person X changed this value at a certain date and time and that person Y changed that value at another specific date and time.  The order of the two changes is irrelevant unless they are changing the same data, in which case the times would have to be different or one of the transactions would have failed due to a StaleStateException.  We never actually "revert" changes as we have a change approval process in place for much of our data anyway and we can't display the changed data until it has been approved.  We are hoping that eliminating the REVINFO table would make our existing data structure more scalable in this regard.  If the REVINFO table doesn't gain us anything and would restrict our scalability, it would be nice if it wasn't required.

            Is there anything obvious that I have missed in this analysis?


            I only wonder how difficult that it will be to write an AuditReader implementation that can deal with deletions to an association without the REVINFO table.




            corrected wording.

            • 3. Re: Envers without a central REVINFO table
              moriarty-s3a Newbie

              We also have changes that are made outside of Hibernate through stored procedures in the database (Long story, you don't want to know).  That doesn't preclude the central REVINFO table, but it is much simpler to just insert one change record in the audit table for the entity that is changing. 

              • 4. Re: Envers without a central REVINFO table
                Adam Warski Master

                Sure it looks as you don't have any use for REVINFO - but unfortunately the concept is built in pretty deeply in Envers. You could of course reuse a lot of the code to generate the audit table mappings etc., but making revinfo optional (and putting some of the information that is now in revinfo - like timestamp, userid) would be quite a change; I'm not if it would be useful to a wider public.



                • 5. Re: Envers without a central REVINFO table
                  Kiran A Newbie

                  I have a similar query. Instead of revision number based on transactions, is it possible to change the generation strategy to start from 1 for any new entities created.


                  Ex: If 10 users are being added, audit table should list them with 


                       Id  - auto generated

                       rev - 1 (indicating first revision)

                       revtype - 0


                  Subsequent updates should increase the rev individually for each entity. Its easier to track the version of an entity if revisions are sequential - 1,2,3 ... vs an arbitracy sequence - 5, 55, 234 ...  because its inherited from REVINFO table.


                  Kindly suggest.

                  • 6. Re: Envers without a central REVINFO table
                    Adam Warski Master

                    Sorry, that's not possible currently.



                    • 7. Re: Envers without a central REVINFO table
                      jdot Newbie

                      Hi, has anybody found a way to take the REVINFO bottleneck our of envers. I am new to hibernate, but I do have 18 years experience writing scalable and performant Java applications. I am impressed with what envers can do out of the box but I cannot see how to stop the revinfo table being a bottleneck to performance over a multi-server & multi-threaded application, with a target of 200-300k "orders" per hour at peak throughput.



                      • 8. Re: Envers without a central REVINFO table
                        Adam Warski Master

                        For such high loads indeed - you probably need a custom solution.

                        As for taking the REVINFO bottleneck out - we're open to suggestions & pull requests