Thank you for quick answer.
The connection timeout is not a problem, it is set by default to 15 seconds and it never occurs.
The whole problem occurred when I use the command within the System transaction (TransactionScope). I found that even if I set DataContext CommandTimeout the error occurs just after transaction timeout is happen. So if I set command timeout shorter than transaction timeout, the exception will be thrown just after transaction timeout. So this is really confusing! In the same way if I set transaction timeout shorter than command timeout the exception is thrown after transaction timeout. The exception trace is different in these cases, additionally it is different when transaction timeout is greater than command timeout - I found three different exceptions.
So I tried to solve my problem by setting both timeouts to the same value and it is working now.
BTW, setting command timeout through connection string using "Default Command Timeout" does not work, so I did it by setting DataContext.CommandTimeout in the OnCreated method.
Here are stack traces for the cases described above:
When transaction timeout is greater than command timeout, I got different exceptions, each time different which is really confusing:
Code: Select all
Devart.Data.Linq.LinqCommandExecutionException: Error on reading data from IDataReader. ---> Devart.Data.PostgreSql.PgSqlException: Unexpected server response.
at Devart.Data.PostgreSql.i.a(Char A_0, Boolean A_1, Boolean A_2)
at Devart.Data.PostgreSql.r.a(Char A_0, Boolean A_1, Boolean A_2)
at Devart.Data.PostgreSql.i.a(Boolean A_0, Boolean A_1, Char A_2, Boolean A_3)
at Devart.Data.PostgreSql.r.i()
at Devart.Data.PostgreSql.r.a(ad A_0, Boolean A_1, Int32 A_2)
at Devart.Data.PostgreSql.ad.af()
at Devart.Data.PostgreSql.ad.m()
at Devart.Data.PostgreSql.PgSqlDataReader.Read()
at Devart.Data.Linq.Provider.ObjectReader`1.MoveNext()
--- End of inner exception stack trace ---
at Devart.Data.Linq.LinqCommandExecutionException.a(String A_0, Exception A_1)
at Devart.Data.Linq.Provider.ObjectReader`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at CC.SyncServiceClient.SyncService.SynchronizeProductGroups(Action`1 writeMessage) in D:\CC.SyncServiceClient\SyncService.cs line 55
Error message: Error on reading data from IDataReader.
System.NullReferenceException: Object reference not set to an instance of an object.
at Devart.Data.PostgreSql.ad.a(Byte[] A_0, Int32 A_1, ArrayList A_2)
at Devart.Data.PostgreSql.r.a(Boolean A_0)
at Devart.Data.PostgreSql.i.a(Char A_0, Boolean A_1, Boolean A_2)
at Devart.Data.PostgreSql.r.a(Char A_0, Boolean A_1, Boolean A_2)
at Devart.Data.PostgreSql.i.a(Boolean A_0, Boolean A_1, Char A_2, Boolean A_3)
at Devart.Data.PostgreSql.r.i()
at Devart.Data.PostgreSql.r.a(ad A_0, Boolean A_1, Int32 A_2)
at Devart.Data.PostgreSql.ad.af()
at Devart.Data.PostgreSql.ad.m()
at Devart.Data.PostgreSql.PgSqlDataReader.Read()
at Devart.Data.Linq.Provider.ObjectReader`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at CC.SyncServiceClient.SyncService.SynchronizeProductGroups(Action`1 writeMessage) in D:\CC.SyncServiceClient\SyncService.cs line 55
Error message: Object reference not set to an instance of an object.
System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
at System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count)
at Devart.Data.PostgreSql.g.a(Byte[] A_0, Int32 A_1, ArrayList A_2)
at Devart.Data.PostgreSql.g.d()
at Devart.Data.PostgreSql.g.a(Boolean A_0, Boolean A_1)
at Devart.Data.PostgreSql.g.af()
at Devart.Data.PostgreSql.g.a(Boolean A_0, Int32 A_1)
at Devart.Data.PostgreSql.PgSqlDataReader.a()
at Devart.Data.PostgreSql.PgSqlDataReader.Read()
at Devart.Data.Linq.Provider.ObjectReader`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at CC.SyncServiceClient.SyncService.SynchronizeProductGroups(Action`1 writeMessage) in D:\CC.SyncServiceClient\SyncService.cs line 55
Error message: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
When transaction timeout is smaller than command timeout:
Code: Select all
System.Transactions.TransactionAbortedException: The transaction has aborted. ---> System.TimeoutException: Transaction Timeout
--- End of inner exception stack trace ---
at System.Transactions.TransactionStateAborted.BeginCommit(InternalTransaction tx, Boolean asyncCommit, AsyncCallback asyncCallback, Object asyncState)
at System.Transactions.CommittableTransaction.Commit()
at System.Transactions.TransactionScope.InternalDispose()
at System.Transactions.TransactionScope.Dispose()
at CC.SyncServiceClient.SyncService.SynchronizeProductGroups(Action`1 writeMessage) in D:\CC.SyncServiceClient\SyncService.cs line 113
Error message: The transaction has aborted.