Active Azure Sql Connections are over the connection pool limit

后端 未结 3 579
盖世英雄少女心
盖世英雄少女心 2021-02-13 22:32

We fight the issue in production when once in a while our Azure SQL database performance significantly degrades. We know we have locks on one of the tables, but these locks are

3条回答
  •  执念已碎
    2021-02-13 23:09

    There are 2 things you can check on you dbcontext objects to see if you are using them correctly and dispose object to return the connection to the connection pool.

    First, you are creating the dbcontext from code. Check if there is a using statement around each creation scope of the dbcontext object. Something like:

    using (var context = new xxxContext()) {
        ...
    }
    

    This will dispose the context when it goes out of scope automatically.

    Second you are using dependency injection to inject the dbcontext object. Make sure you are using scoped:

    services.AddScoped(
    

    Then the DI will take care of disposing your context objects.

    The next thing you can check is if you have uncommitted transactions. Check if all you transactions are within using blocks, so they will commit or rollback when you are out of scope.

提交回复
热议问题