简体   繁体   中英

Subsonic race condition detected each new DB connection

I'm having a hard time debugging a service.

I will start by explaining the cenario that I'm running. I got 9 databases using their services importations, generations of reports and exporting data. They all run fine for a day or two but after that subsonic starts to give exceptions when there is a new connection to database, all exceptions are simillar, just change the database operation, there is an exemple:

Probable I/O race condition detected while copying memory. The I/O package is not thread safe by default. In multithreaded applications, a stream must be accessed in a thread-safe way, such as a thread-safe wrapper returned by TextReader's or TextWriter's Synchronized methods. This also applies to classes like StreamWriter and StreamReader.
   at System.Buffer.InternalBlockCopy(Array src, Int32 srcOffsetBytes, Array dst, Int32 dstOffsetBytes, Int32 byteCount)
   at System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32 count)
   at System.IO.TextWriter.WriteLine(String value)
   at System.IO.TextWriter.WriteLine(String format, Object arg0)
   at System.IO.TextWriter.SyncTextWriter.WriteLine(String format, Object arg0)
   at SubSonic.DataProviders.DbDataProvider.ExecuteReader(QueryCommand qry) in C:\[path]\SubSonic.Core\DataProviders\DbDataProvider.cs:line 112
   at SubSonic.Linq.Structure.DbQueryProvider.Execute[T](QueryCommand`1 query, Object[] paramValues) in C:\[path]\SubSonic.Core\Linq\Structure\DbQueryProvider.cs:line 280
   at lambda_method(Closure )
   at SubSonic.Linq.Structure.DbQueryProvider.Execute(Expression expression) in C:\[path]\SubSonic.Core\Linq\Structure\DbQueryProvider.cs:line 131
   at SubSonic.Linq.Structure.QueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) in C:\[path]\SubSonic.Core\Linq\Structure\QueryProvider.cs:line 50
   at SubSonic.Linq.Structure.Query`1.GetEnumerator() in C:\[path]\SubSonic.Core\Linq\Structure\Query.cs:line 85
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at [namespace].ReportManager.GetAllPending() in [path]\ReportManager.cs:line 193
   at [namespace].ReportsServiceHandler.Run() in C:\[path]\ReportsServiceHandler.cs:line 137

The only solution so far that I have is to reset the service but I wasn't able yet to discovery what may cause this. I tried to debug it in my local environment but I wasn't able to do it.

Anyone know if there is a bug in subsonic or how can I find the problem in the services?

Thank you in advance for the help.

subsonics3 returns you reader , and you can dispose it following way

Query qry = Product.CreateQuery().WHERE("ListPrice > 50.00")
            .AND("Class = L").AND("Color = Yellow");
using(IDataReader rdr = qry.ExecuteReader())
{
 while (rdr.Read()) {
   Console.WriteLine(rdr[Product.Columns.Name].ToString());
 }
}

using(SqlDataReader reader = command.ExecuteReader()) { ... do your stuff ... }


i think you need to dispose you connection properly by making use of using , because there might be cause connection you used previously still open ie not closed.

using(var connection = new Connection())
{
}

above code dispose you connection. or if it is not there i suggest make use of Dispose Pattern and dispose conneciton object after use of it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM