Open Closed

Multiple tabs causes log outs #9039


User avatar
0
burkay created
  • Exception message and full stack trace:
    Volo.Abp.Data.AbpDbConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions. ---> Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.

  • Steps to reproduce the issue:

    1. Set the 'Prevent Concurrent Login' setting to 'Logout from all devices.' or 'Logout from same type devices.'

    2. Open up any page of the application on multiple tabs

    3. Wait for token refresh, which typically happens in 15 minutes.

    4. Observe log outs.

This is reproducible on https://demo.abp.io/ as well. We created a new project and observed that it may not happen with two tabs sometimes. To share logs, we opened up 8 tabs and observed the logout behavior. Logs are at https://qtext.io/rgzn . Dev console of one of those tabs is below:

Screenshot 2025-03-26 at 6.26.56 PM.png

This may be somehow related to https://abp.io/support/questions/5257/Occasionally-logging-out-due-to-validating-access-token-error

We are currently experiencing this issue with our web application which is in production. Specifically, when users attempt to access the application through multiple tabs simultaneously, we encounter a concurrency exception that results in unexpected logouts. To temporarily mitigate the issue, we have asked our users to limit their access to a single tab. However, this workaround is inconvenient and reflects poorly on the user experience.

Could you kindly assist us by providing a fix for this issue or suggest an alternative workaround to address the problem? Given the urgency of the situation, we would greatly appreciate your timely support.

Thank you in advance for your help. We look forward to hearing from you soon.


4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer
  • User Avatar
    0
    burkay created

    Hello,

    As you wrote in your linked post, we added the following code to our EntityFrameworkCore project:

        using Microsoft.EntityFrameworkCore.ChangeTracking;
        using Volo.Abp.DependencyInjection;
        using Volo.Abp.EntityFrameworkCore.ChangeTrackers;
        using Volo.Abp.OpenIddict.Tokens;
        
        namespace Ptr.EntityFrameworkCore;
        
        [Dependency(ReplaceServices = true)]
        [ExposeServices(typeof(AbpEfCoreNavigationHelper))]
        public class PtrAbpEfCoreNavigationHelper : AbpEfCoreNavigationHelper
        {
            public override void ChangeTracker_Tracked(object? sender, EntityTrackedEventArgs e)
            {
                if (e.Entry.Entity.GetType() == typeof(OpenIddictToken))
                {
                    return;
                }
        
                base.ChangeTracker_Tracked(sender, e);
            }
        
            public override void ChangeTracker_StateChanged(object? sender, EntityStateChangedEventArgs e)
            {
                if (e.Entry.Entity.GetType() == typeof(OpenIddictToken))
                {
                    return;
                }
        
                base.ChangeTracker_StateChanged(sender, e);
            }
        }
    

    With this in place, we ran some tests. We waited for half an hour in 4 tabs. All of them sent requests to connect/token twice at each 15th minute. The system does not kick users out. Thank you! Now we have two questions:

    1. We still see the concurrency exception in logs:
      [ERR] The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
      Volo.Abp.Data.AbpDbConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.

    2. In your above reply, you said this will be fixed in v9.1.1. It is released, we tested using it but the error persisted. When this issue gets fixed in ABP itself, we will remove the above code from our codebase. Could you tell us in which version will this be fixed?

    Thank you again and best wishes.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    1. Can you share full logs.txt file with liming.ma@volosoft.com

    2. we tested using it but the error persisted.

    Can you also share the debug logs for 9.1.1?
    https://abp.io/support/questions/8622/How-to-enable-Debug-logs-for-troubleshoot-problems

    Thanks. Your ticket has been refunded.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Can you try to configure the IgnoredNavigationEntitySelectors in 9.1.1

    Configure<AbpEntityChangeOptions>(options =>
    {
        options.IgnoredNavigationEntitySelectors.Add("DisableOpenIddictApplication", type => type == typeof(OpenIddictApplication) || type = typeof(OpenIddictToken));
    });
    
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 25, 2025, 11:10