zzzprojects / Dapper-Plus

Dapper Plus - High-Efficient Bulk Actions (Insert, Update, Delete, and Merge) for .NET
https://dapper-plus.net/
383 stars 85 forks source link

Getting time out on Bulk Operation #92

Closed zvig-g closed 3 years ago

zvig-g commented 3 years ago

• We set 180, but in the error it writes 60 -> can it be that dapper ignore the batch timeout ?

Error:

2021-05-11 13:00:19,071 [8] [(null)] FATAL BaseProcessor: InsertServicesDetails threw an exception:A timeout error occured. Please increase the timeout globally: BulkOperationManager.BulkOperationBuilder = operation => operation.BatchTimeout = 60; or by operation: bulkOperation.BatchTimeout = 60;. at ?.Execute(List1 actions) at Z.BulkOperations.BulkOperation.Execute() at Z.Dapper.Plus.DapperPlusAction.Execute() at Z.Dapper.Plus.DapperPlusActionSet1.AddAction(String mapperKey, DapperPlusActionKind actionKind, TEntity item) at Z.Dapper.Plus.DapperPlusActionSet1.DapperPlusActionSetBuilder(DapperPlusContext context, IDbConnection connection, IDbTransaction transaction, String mapperKey, DapperPlusActionKind actionKind, TEntity item, Func2[] selectors) at Z.Dapper.Plus.DapperPlusContext.BulkInsert[T](String mapperKey, T item, Func2[] selectors) at Z.Dapper.Plus.DapperPlusContext.BulkInsert[T](T item, Func2[] selectors) at InterchangeBilling.Dao.DbManager.BulkInsertServicesDetails(List1 items) in D:\agent8\_work\189\s\SC\Sources\InterchangeBilling.Dao\DbManager.cs:line 1065 at InterchangeBilling.BaseProcessor.AbstractProcessor.InsertServicesDetails(List1 servicesDetailsTemp, ErrorContext errorContext) in D:\agent8_work\189\s\SC\Sources\InterchangeBilling.Engine\InterchangeBilling.BaseProcessor\AbstractProcessor.cs:line 541 2021-05-11 13:00:19,743 [8] [(null)] FATAL BaseProcessor: UpdateDataInDb UpdateDataInDB failed! System.Exception: A timeout error occured. Please increase the timeout globally: BulkOperationManager.BulkOperationBuilder = operation => operation.BatchTimeout = 60; or by operation: bulkOperation.BatchTimeout = 60; ---> System.Data.SqlClient.SqlException: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception: The wait operation timed out --- End of inner exception stack trace ---

Code:

var context = new DapperPlusContext(connection); context.Entity().Key(x => new { x.MovementDate, x.MovementId, x.MovementServiceId }) .BatchSize(_insertBatchSize).BatchTimeout(_batchTimeout).Table("FA_SCServicesDetails");

                var affected = context.BulkInsert(items);

with regards Zvi Gezel

JonathanMagnan commented 3 years ago

Hello @zvig-g ,

No, the 60 is hardcoded in the error message, it is just an example but that's true that's very confusing. I asked my developer to look at it and change it for the actual timeout value or at least a variable name.

I'm not really sure why you are getting a timeout with 180s, I would probably recommend you to look more at what could cause this timeout instead of increasing it.

Let me know if that answers correctly to your question.

Best Regards,

Jon

JonathanMagnan commented 3 years ago

Hello @zvig-g ,

The error message for the timeout has been modified. The current timeout will be displayed after the A timeout error occured part.

We also added some variables instead of hardcoding values to make it more clear.

Best Regards,

Jon