Open Closed

Issue creating users in production #10332


User avatar
0
rogercprops created
  • Template: microservice
  • Created ABP Studio Version: 1.0.2
  • Current ABP Studio Version: 2.1.6
  • Multi-Tenancy: Yes
  • UI Framework: mvc
  • Theme: leptonx
  • Theme Style: system
  • Theme Menu Placement: side
  • Database Provider: ef
  • Database Management System: sqlserver
  • Mobile Framework: none
  • Public Website: No
  • Social Login: Yes
  • Include Tests: Yes
  • Dynamic Localization: Yes
  • Kubernetes Configuration: Yes
  • Grafana Dashboard: Yes
  • Use Local References: No
  • Optional Modules:
    • GDPR
    • TextTemplateManagement
    • AuditLogging
    • OpenIddictAdmin
  • Selected Languages: English, English (United Kingdom), Español
  • Default Language: English
  • Create Command: abp new CloverleafCMS -t microservice --ui-framework mvc --database-provider ef --database-management-system sqlserver --theme leptonx --skip-migrator --without-cms-kit --dont-run-bundling -no-file-management -no-language-management
  • Exception message and full stack trace:
[20:28:35 INF] Request starting HTTP/1.1 POST http://cloverleafcms-pr-apps-identity/api/identity/users - application/json 519
[20:28:35 INF] Executing endpoint 'Volo.Abp.Identity.IdentityUserController.CreateAsync (Volo.Abp.Identity.Pro.HttpApi)'
[20:28:35 INF] Route matched with {area = "identity", controller = "User", action = "Create"}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.Identity.IdentityUserDto] CreateAsync(Volo.Abp.Identity.IdentityUserCreateDto) on controller Volo.Abp.Identity.IdentityUserController (Volo.Abp.Identity.Pro.HttpApi).
[20:29:05 ERR] Failed executing DbCommand (30,010ms) [Parameters=[@p2='?' (DbType = Guid), @p0='?' (Size = 40), @p3='?' (Size = 40), @p1='?' (DbType = Int32), @p6='?' (DbType = Guid), @p4='?' (Size = 40), @p7='?' (Size = 40), @p5='?' (DbType = Int32), @p8='?' (DbType = Guid), @p9='?' (DbType = Guid), @p10='?' (DbType = Guid), @p11='?' (DbType = Guid), @p12='?' (DbType = Guid), @p13='?' (DbType = Guid), @p18='?' (DbType = Guid), @p14='?' (Size = 40), @p19='?' (Size = 40), @p15='?' (DbType = Int32), @p16='?' (DbType = DateTime2), @p17='?' (DbType = Guid)], CommandType='Text', CommandTimeout='30']
SET NOCOUNT ON;
UPDATE [AbpRoles] SET [ConcurrencyStamp] = @p0, [EntityVersion] = @p1
OUTPUT 1
WHERE [Id] = @p2 AND [ConcurrencyStamp] = @p3;
UPDATE [AbpRoles] SET [ConcurrencyStamp] = @p4, [EntityVersion] = @p5
OUTPUT 1
WHERE [Id] = @p6 AND [ConcurrencyStamp] = @p7;
INSERT INTO [AbpUserRoles] ([RoleId], [UserId], [TenantId])
VALUES (@p8, @p9, @p10),
(@p11, @p12, @p13);
UPDATE [AbpUsers] SET [ConcurrencyStamp] = @p14, [EntityVersion] = @p15, [LastModificationTime] = @p16, [LastModifierId] = @p17
OUTPUT 1
WHERE [Id] = @p18 AND [ConcurrencyStamp] = @p19;
[20:29:05 ERR] An exception occurred in the database while saving changes for context type 'CloverleafCMS.IdentityService.Data.IdentityServiceDbContext'.
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
 ---> Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
 ---> System.ComponentModel.Win32Exception (258): Unknown error 258
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
ClientConnectionId:25031d3f-7e9e-4a45-b673-e954e0acbcfd
Error Number:-2,State:0,Class:11
   --- End of inner exception stack trace ---
  • Steps to reproduce the issue:
  • Either in the Web application or via Postman create a new user. This problem just started happening today in production. We don't have this issue in our dev environment where the Authserver, Identity and Administration docker images are identical.

This seems to be the only service that's having the issue.

This is impacting our production users so immediate attention would be appreciated.

Thank you


2 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    1. Solution

    The error is a pure SQL Server execution timeout:

    Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

    The command that times out is the standard ABP Identity user‑creation batch:

    UPDATE [AbpRoles] ...
    INSERT INTO [AbpUserRoles] ...
    UPDATE [AbpUsers] ...
    

    So EF/ABP are working as expected; SQL Server is taking >30 seconds to complete this batch in production (but not in dev). That means:

    • Either the AbpRoles, AbpUsers, or AbpUserRoles rows are blocked/locked by some other transaction, or
    • The database server is under heavy load / IO issues, or
    • There is a very long‑running transaction (e.g. migration, maintenance, or custom code) holding locks.

    You can resolve and mitigate this with the following steps.


    A. Immediate checks on the SQL Server

    Run these queries directly on the production database:

    1. Check blocking sessions
    -- See who is blocking whom
    SELECT
        r.session_id,
        r.status,
        r.command,
        r.blocking_session_id,
        r.wait_type,
        r.wait_time,
        r.wait_resource,
        t.text AS sql_text
    FROM sys.dm_exec_requests r
    OUTER APPLY sys.dm_exec_sql_text(r.sql_handle) t
    WHERE r.session_id > 50;  -- Ignore system sessions
    

    Look for:

    • blocking_session_id <> 0
    • Long wait_time
    • wait_type like LCK_M_* (lock waits) on AbpRoles, AbpUsers, or AbpUserRoles.
    1. Check open transactions
    SELECT
        s.session_id,
        s.login_name,
        s.host_name,
        r.status,
        r.command,
        r.blocking_session_id,
        t.transaction_id,
        t.transaction_type,
        t.transaction_state,
        at.name as transaction_name
    FROM sys.dm_tran_active_transactions t
    JOIN sys.dm_tran_session_transactions st ON t.transaction_id = st.transaction_id
    JOIN sys.dm_exec_sessions s ON st.session_id = s.session_id
    LEFT JOIN sys.dm_exec_requests r ON r.session_id = s.session_id
    LEFT JOIN sys.dm_tran_active_snapshot_database_transactions at 
           ON t.transaction_id = at.transaction_id;
    

    If you see:

    • Long‑lived transactions holding locks on Abp* tables, kill them (carefully) or stop the service that opened them.
    1. Ensure all migrations are applied

    From the ABP DbMigrator (or equivalent migration service for Identity):

    • Run migrations against the production Identity database.
    • Confirm AbpUsers, AbpRoles, AbpUserRoles schemas match dev.

    A partially run migration can leave locks or long operations.


    B. ABP / EF Core mitigation (increase command timeout)

    For an immediate workaround (to stop production user‑creation failures while you investigate), increase the EF Core command timeout for the IdentityService DbContext.

    In your IdentityService EF Core configuration module (e.g. IdentityServiceEntityFrameworkCoreModule or the module where you configure AbpDbContextOptions), add:

    using Microsoft.EntityFrameworkCore;
    using Volo.Abp.EntityFrameworkCore;
    
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        Configure<AbpDbContextOptions>(options =>
        {
            options.Configure<IdentityServiceDbContext>(c =>
            {
                c.UseSqlServer(
                    c.ExistingConnection ?? 
                    c.ConnectionString,
                    sqlOptions =>
                    {
                        // Increase command timeout (seconds)
                        sqlOptions.CommandTimeout(120);
                    });
            });
        });
    }
    

    Notes:

    • IdentityServiceDbContext is the DbContext from your Identity microservice (CloverleafCMS.IdentityService.Data.IdentityServiceDbContext in your stack trace).
    • This does not fix blocking, but prevents transient slow operations from throwing at 30 seconds.

    C. Check for custom code holding locks

    If you have any custom logic that:

    • Runs inside long unit of work scopes, or
    • Iterates over many users/roles and updates them in one large transaction, or
    • Uses manual database transactions,

    make sure those operations:

    1. Use short‑lived units of work.
    2. Are not running concurrently with normal user‑creation.
    3. Use background jobs at low traffic times if they touch Identity tables heavily.

    ABP Unit of Work best practices:

    • Prefer short transactions per operation (per request / per app service method).
    • Avoid long loops that update many AbpUsers/AbpRoles in a single UoW.

    D. Sanity checks in the Identity microservice

    1. Confirm there is no custom trigger or external process on AbpUsers, AbpRoles, AbpUserRoles that could be slow or deadlocking.
    2. Confirm connection string for IdentityService in production really points to the expected DB (not some shared, heavily used DB).
    3. Check SQL Server error log and performance metrics (CPU, IO, deadlocks) during a failing user‑creation attempt.

    If you do the SQL blocking checks while reproducing the problem (trigger a user creation and immediately inspect sys.dm_exec_requests / sys.dm_tran_locks), you will see exactly which session / query is blocking the AbpRoles / AbpUsers updates. Removing or fixing that blocker is the real solution; the increased timeout just buys time to keep production functional.


    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    rogercprops created

    We can close this for now. I ran the queries above and saw that the authserver had suspended transactions. I restarted the pod and the problem went away.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.2.0-preview. Updated on January 30, 2026, 08:56
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.