oibo8x / subsonicproject

Automatically exported from code.google.com/p/subsonicproject
0 stars 0 forks source link

Possible Threading Issues with SQLite Provider #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
when i put to db operator method test() test2() in two thread it throw 
exception

Attempted to read or write protected memory. This is often an indication 
that other memory is corrupt."}

if i put two method into main thread,it works fine

below is my test code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using SubSonic.Generated;

namespace test
{
public class Class6
{
static void Main(string[] args)
{
test(); test2();

Thread[] thd = new Thread[2];
thd[0] = new Thread(new ThreadStart(test));
thd[1] = new Thread(new ThreadStart(test2));
thd[0].Start();
thd[1].Start();

}

private static void test2()
{
List<PC> list = DB.Select().From<PC>().Where(PC.Columns.IsOnline).IsEqualTo
(true).And(
PC.Columns.LastSuccessAssignTime).IsLessThanOrEqualTo(
DateTime.Now.Subtract(new TimeSpan(0, 0, 100, 0)))
.ExecuteTypedList<PC>();
Console.WriteLine(list.Count);
Thread.Sleep(1);
}

private static void test()
{
DB.Update<PC>().Set(PC.Columns.IsOnline).EqualTo(false).Execute();
}
}
} 

What version of the product are you using? On what operating system?

vs2008 framework3.5 win2003 subsonic 2.1 final

Original issue reported on code.google.com by FREDERICK.Mao on 27 Jul 2008 at 2:44

GoogleCodeExporter commented 9 years ago
my database is sqlite3

Original comment by FREDERICK.Mao on 27 Jul 2008 at 11:09

GoogleCodeExporter commented 9 years ago

Original comment by canof...@gmail.com on 28 Jul 2008 at 4:26

GoogleCodeExporter commented 9 years ago
findal i find the answer,although sqlite support mulitple threads,but each 
thread 
should use a independent connection,so we need use Clone() a connection object 
to 
each thread,
sqlite support multiple thread isn't well,
my advice:give some notes when user want to use sqlite with multiple 
threads,it's 
not subsonic's bug 

Original comment by FREDERICK.Mao on 29 Jul 2008 at 1:53

GoogleCodeExporter commented 9 years ago
Thanks frederick - closing the issue

Original comment by robcon...@gmail.com on 9 Apr 2009 at 1:51