question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Server Crashes after 1000 entries to Database

See original GitHub issue

I am using Abp 1.5.1 and using the code below to make database inserts:

[AbpAllowAnonymous]
        private async Task InsertPreOrders(List<TransactionItem> request, long batchId, long custRef, int serviceId, int tenantId, string service, string type)
        {
            foreach (var item in request)
            {
                var ledger = new CustomerLedgerEntry();
                ledger.CustReference = custRef;    
                ledger.DebitAmount = 0.0m;
                ledger.CreditAmount = item.Amount;
                ledger.Type = type;
                ledger.ServiceId = serviceId;
                ledger.TenantId = tenantId;
                ledger.AccountType = item.AccountType;
                ledger.ProductId = serviceId.ToString();
                ledger.ProductName = item.ProductName;
                ledger.Description = item.Description;
                ledger.CustomerTransactionBatchId = batchId;
                ledger.ServiceName = service;
                ledger.DrawId = item.DrawId;
                ledger.DrawTitle = item.DrawTitle;
                ledger.CreationTime = DateTime.UtcNow;
                ledger.TransactionTime = item.TransactionTime;
                await _entryRepository.InsertAsync(ledger);
            }
        }

When I insert 10 items, there is usually no problem. But when I insert say 2,000 items, IIS crashes, and I get this error in the Event Viewer:

Application: Platinum.CRM.Web.Mvc.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ObjectDisposedException
   at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean ByRef)
   at System.StubHelpers.StubHelpers.SafeHandleAddRef(System.Runtime.InteropServices.SafeHandle, Boolean ByRef)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv+NativeMethods.uv_async_send(Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvAsyncHandle)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.async_send(Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvAsyncHandle)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelThread.PostCloseHandle(System.Action`1<IntPtr>, IntPtr)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvHandle.ReleaseHandle()
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvStreamHandle.ReleaseHandle()
   at System.Runtime.InteropServices.SafeHandle.InternalFinalize()
   at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean)
   at System.Runtime.InteropServices.SafeHandle.Finalize()

Please what can I do about this? We are in production and this is killing me!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ismcagdascommented, Nov 10, 2017

@coommark maybe you should use raw sql for this specific case. Your code is very short and there is no point to optimize.

1reaction
natikicommented, Nov 11, 2017

@ismcagdas Seeing as though ABP is already using https://github.com/zzzprojects/EntityFramework.DynamicFilters any chance of integrating http://entityframework-plus.net/ which includes bulk update etc? And making them part of IRepository?

@coommark you may want to look at http://entityframework-extensions.net/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Whenever my PC crashes, my SQL DB adds 1000 to ...
For every next entry in any table in my database the ID becomes 1004. I was thinking maybe because the crash for some...
Read more >
Server crashing everyday around the same time. MYSQL ...
UPDATE: The issue seems to have been alot of load on the server. I had csf installed and it was scanning to server...
Read more >
CPU High usage crashing our server
You appear to be running entirely (or mostly) InnoDB. The More Important Issues: Very important: Increase innodb_buffer_pool_size to at least 2G ...
Read more >
Server Crashes after a while of Connecting to MySQL ...
So, I have it so my server queries a MySQL database every time someone places/breaks a block, and after a while of that...
Read more >
Maximum number of API request before server crashes?
We are running FM Server 18 on a Windows machine. We have several times now when we create 8000 request over a 10...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found