No entries in GetLastConflicts during OptimisticVerificationException

4 posts, 0 answers
  1. Florian
    Florian avatar
    2 posts
    Member since:
    Jan 2015

    Posted 28 Jul 2015 Link to this post

    Hi there

    I try to resolve an OptimisticVerificationException: The user1 changes data of an entity but does not commit it to the database yet. Another user2 changes data on the database. Now the user1 tries to commit the data and retrieves an OptimisticVerificationException. This is expected. But now I try to resolve the entity which caused the conflict by using the GetLastConflicts method on the context. But there are no entries returned (even if ConcurrencyConflictsProcessingMode 
    is AggregateAll). Is this a known bug? I can get the object-Id by, but as I don't have the object-type, I cannot get the conflicting object.

     

    catch (OptimisticVerificationException ex)
    {
       IList<ConcurrencyConflict> conflicts = this.GetLastConflicts(); // always Count == 0

     ​

    I'm using DataAccess 2015.1.225.1.

    Greetings,

    Florian

     
  2. Ady
    Admin
    Ady avatar
    589 posts

    Posted 31 Jul 2015 Link to this post

    Hi Florian,

     Yes, this is a known bug.
    You can work around the issue by getting the inner exceptions of the OptimisticVerificationException.
    01.catch(Telerik.OpenAccess.Exceptions.OptimisticVerificationException ex)
    02.{
    03.    var optimisticVerificationExceptions = ex.InnerExceptions.Where(x => x.GetType() == typeof(OptimisticVerificationException));
    04.    foreach(var innerEx in optimisticVerificationExceptions)  
    05.    {
    06.        var failedObjectId = innerEx.FailedObject;
    07.        context.Refresh(Telerik.OpenAccess.RefreshMode.OverwriteChangesFromStore, failedObjectId)
    08.    }      
    09.}

     The Refresh call will update the in-memory object with latest values from the database.

    Do get back in case you need further assistance.

    Regards,
    Ady
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  3. DevCraft banner
  4. Martijn
    Martijn avatar
    1 posts
    Member since:
    Feb 2015

    Posted 27 Jun in reply to Ady Link to this post

    Hi Ady,

    This is still a problem in the newest DataAccess (2016.1.224.1) version, when are you going to solve this?

    Also with this workaround the amount of exceptions are incorrect, always returning 1 exception while I have e.g. 2 conflicts.

     

    Greetings,


    Martijn

     

  5. Ady
    Admin
    Ady avatar
    589 posts

    Posted 04 Jul Link to this post

    Hello Martijn,

     Given the availability of a workaround, there are no immediate plans to fix this bug for the next official release and hence I cannot commit to a fixed timeframe for the fix.

    Regarding getting only 1 exception when there more conflicts - DataAccess executes the update query for each object and fails when the first update cannot be done. Even if there are more conflicts there is not point in trying to execute the rest after the first conflict is encountered.

    Hope this answers your questions.


    Regards,
    Ady
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Back to Top