Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
125
Database connection is not closed
posted

I'm developing MVC application. Infragistics jQuery grid (version 3.12.1.2049) is used for presentation. Entity Framework 4.1.0.0 and Devart dotConnect for Oracle 7.1.40 is  is used for data access.

Data access code is based on System.Data.Entity.DbContext. Entity classes have System.Data.Entity.DbSet<TEntity> types.

Connection pooling is used and "Max Pool Size" is set to 5 in connection string.

Application works, reads data from database, displays it in grid, but after 5 requests an exception is raised: "Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached."

I have found out that somewhere connection is not closed.

Database calls

There are following steps

1.Connection is opened

2.Statement is executed
SELECT
"top".ACCOUNT_ID,
"top".IBAN,
"top".NAME,
"top".OPENED,
"top".CLOSED
FROM ( SELECT
 "Extent1".ACCOUNT_ID,
 "Extent1".IBAN,
 "Extent1".NAME,
 "Extent1".OPENED,
 "Extent1".CLOSED
 FROM schema.view "Extent1"
 ORDER BY "Extent1".ACCOUNT_ID ASC
)  "top"
WHERE  ROWNUM <= 1

3.Statement is executed
SELECT
"GroupBy1".A1 AS C1
FROM ( SELECT Count(1) AS A1
 FROM Schema.view "Extent1"
)  "GroupBy1" is executed

4.Statement is executed
SELECT
"Extent1".ACCOUNT_ID,
"Extent1".IBAN,
"Extent1".NAME,
"Extent1".OPENED,
"Extent1".CLOSED
FROM Schema.view "Extent1"
ORDER BY "Extent1".ACCOUNT_ID ASC

5.Connection is not closed and is not returned to Connection pool

New call opens new connection.

Controller

using Infragistics.Web.Mvc;
namespace disw.Controllers
{
    public class SaskaitosController : DisBaseController
    {
        public ActionResult Perziura()
        {
            ViewBag.Title = "Accounts";
            var d = Db.Accounts
                    .OrderBy(o => o.AccountID);
            return View(d);
        }
    }
}

Where Db is DbContext object.

View

@model IQueryable<diswBL.DisModel.Account>
@using Infragistics.Web.Mvc
@using diswBL.DisModel

@section Header
{
<script src="@Url.Content("~/Scripts/ig/infragistics.loader.js")" type="text/javascript"></script>
@(Html.Infragistics()
 .Loader()
 .ScriptPath(Url.Content("~/Scripts/ig/"))
 .CssPath(Url.Content("~/Content/ig/"))
 .Render()
)
}

<h2>@ViewBag.Title</h2>

@section Grid
{
@(Html.Infragistics().Grid(Model).ID("igAccounts")
 .AutoGenerateColumns(false)
 .Columns(col =>
 {
   col.For(x => x.ACCOUNT_ID).HeaderText("ID").DataType("decimal");
   col.For(x => x.IBAN).HeaderText("Account IBAN");
   col.For(x => x.NAME).HeaderText("Account Name");
   col.For(x => x.OPENED).HeaderText("Opened").DataType("date").Format("dateTime");
   col.For(x => x.CLOSED).HeaderText("Closed").DataType("date").Format("dateTime");
 })
 .Features(features =>
 {
   features.Paging().Type(OpType.Local).PageSize(10);
   features.Sorting().Mode(SortingMode.Multiple).Type(OpType.Local);
   features.Filtering().Mode(FilterMode.Advanced).Type(OpType.Local);
   features.Selection().Mode(SelectionMode.Row).MultipleSelection(true);
 })
 .Height("500px").Width("100%")
.DataBind()
.Render()
)
}

Parents
No Data
Reply Children