PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Multiple writers / rowlocking
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Multiple writers / rowlocking
![]() |
Multiple writers / rowlocking |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
I am implementing an app that will do massive updating on a DataTable with multiple threads. Typically I first look up the row: DataRow row = mydatatable.Rows.Find(key); and then do some updating: row.BeginEdit(); // here is where I get the exception foreach (string colname in collist) row[colname]=mydatacollection[colname]; row.EndEdit(); The problem is: in a multithreaded scenario the "BeginEdit" method will raise an exception if the row is already being updated by another thread. At least that's how the it looks to me. So I put a lock on the row lock (row) { row.BeginEdit(); .... but that didn't help. I could not find special sync objects on the row level, so does someone know an efficient way to get this exception over with? Thanks in advance for any suggestion, DC |
|
|
|
#2 |
|
Guest
Posts: n/a
|
I spent quiet some time trying to fix this - to no avail. I believe
that the RecordManager of the SqlData classes is buggy when it comes to massive multiple writers. I tried synchronizing with the only object that I found supporting synchronization in these classes: DataRowCollection. While putting a lock on DatarowCollection.SyncRoot does produce less exceptions, it sooner or later will. Also, locking the whole table is a bit coarse for my application, I need locks on the row level. The exception I get is a NullReferenceException at System.Data.RecordManager.NewRecordBase() at System.Data.DataTable.NewRecord(Int32 sourceRecord) at System.Data.DataRow.BeginEdit() at System.Data.DataRow.set_Item(DataColumn column, Object value) at System.Data.DataRow.set_Item(String columnName, Object value) ...(my method) I will now start writing my own datahousekeeping class for this. Regards DC dc@upsize.de (DC) wrote in message news:<5b7bac12.0306300830.4d7edd79@posting.google.com>... > Hi, > > I am implementing an app that will do massive updating on a DataTable > with multiple threads. Typically I first look up the row: > > DataRow row = mydatatable.Rows.Find(key); > > and then do some updating: > > row.BeginEdit(); // here is where I get the exception > > foreach (string colname in collist) > row[colname]=mydatacollection[colname]; > > row.EndEdit(); > > The problem is: in a multithreaded scenario the "BeginEdit" method > will raise an exception if the row is already being updated by another > thread. At least that's how the it looks to me. So I put a lock on the > row > > lock (row) > { > row.BeginEdit(); > ... > > but that didn't help. I could not find special sync objects on the row > level, so does someone know an efficient way to get this exception > over with? > > Thanks in advance for any suggestion, > > DC |
|
|
|
#3 |
|
Guest
Posts: n/a
|
http://users.pandora.be/pdo
please send me a personal email if you want to join in the development of this project... grtz Kris "DC" <dc@upsize.de> wrote in message news:5b7bac12.0307020115.335612fa@posting.google.com... > I spent quiet some time trying to fix this - to no avail. I believe > that the RecordManager of the SqlData classes is buggy when it comes > to massive multiple writers. I tried synchronizing with the only > object that I found supporting synchronization in these classes: > DataRowCollection. While putting a lock on DatarowCollection.SyncRoot > does produce less exceptions, it sooner or later will. Also, locking > the whole table is a bit coarse for my application, I need locks on > the row level. > > The exception I get is a NullReferenceException > > at System.Data.RecordManager.NewRecordBase() > at System.Data.DataTable.NewRecord(Int32 sourceRecord) > at System.Data.DataRow.BeginEdit() > at System.Data.DataRow.set_Item(DataColumn column, Object value) > at System.Data.DataRow.set_Item(String columnName, Object value) > ...(my method) > > I will now start writing my own datahousekeeping class for this. > > Regards > > DC > > > dc@upsize.de (DC) wrote in message news:<5b7bac12.0306300830.4d7edd79@posting.google.com>... > > Hi, > > > > I am implementing an app that will do massive updating on a DataTable > > with multiple threads. Typically I first look up the row: > > > > DataRow row = mydatatable.Rows.Find(key); > > > > and then do some updating: > > > > row.BeginEdit(); // here is where I get the exception > > > > foreach (string colname in collist) > > row[colname]=mydatacollection[colname]; > > > > row.EndEdit(); > > > > The problem is: in a multithreaded scenario the "BeginEdit" method > > will raise an exception if the row is already being updated by another > > thread. At least that's how the it looks to me. So I put a lock on the > > row > > > > lock (row) > > { > > row.BeginEdit(); > > ... > > > > but that didn't help. I could not find special sync objects on the row > > level, so does someone know an efficient way to get this exception > > over with? > > > > Thanks in advance for any suggestion, > > > > DC |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Hi Kris,
interesting project but not exactly what I am into. My apps (dealing with realtime information) usually work with data as dirty as possible with as little rowlocking as possible - pessimistic rowlocking is the worst I can run into. I replaced the DataTable I used to store information with a class derived from Hashtable and that threads great now. I can only recommend to any ADO.NET users: if you really don't require many of the ADO.NET classes' features and require multiple writers in a mutithreaded scenario, then you are probably better off designing your own class for this purpose; took me a couple of hours after debugging the DataRow updating for three days. Even filling my class with data (using an SqlDataReader) performs better than filling a DataTable with the SqlAdapter since my class only produces the overhead I actually need. Regards DC "Kris" <kris_de_greve@hotmail.com> wrote in message news:<OcXDQrKQDHA.2228@tk2msftngp13.phx.gbl>... > http://users.pandora.be/pdo > > > please send me a personal email if you want to join in the development of > this project... > > > grtz > > Kris > > > > "DC" <dc@upsize.de> wrote in message > news:5b7bac12.0307020115.335612fa@posting.google.com... > > I spent quiet some time trying to fix this - to no avail. I believe > > that the RecordManager of the SqlData classes is buggy when it comes > > to massive multiple writers. I tried synchronizing with the only > > object that I found supporting synchronization in these classes: > > DataRowCollection. While putting a lock on DatarowCollection.SyncRoot > > does produce less exceptions, it sooner or later will. Also, locking > > the whole table is a bit coarse for my application, I need locks on > > the row level. > > > > The exception I get is a NullReferenceException > > > > at System.Data.RecordManager.NewRecordBase() > > at System.Data.DataTable.NewRecord(Int32 sourceRecord) > > at System.Data.DataRow.BeginEdit() > > at System.Data.DataRow.set_Item(DataColumn column, Object value) > > at System.Data.DataRow.set_Item(String columnName, Object value) > > ...(my method) > > > > I will now start writing my own datahousekeeping class for this. > > > > Regards > > > > DC > > > > > > dc@upsize.de (DC) wrote in message > news:<5b7bac12.0306300830.4d7edd79@posting.google.com>... > > > Hi, > > > > > > I am implementing an app that will do massive updating on a DataTable > > > with multiple threads. Typically I first look up the row: > > > > > > DataRow row = mydatatable.Rows.Find(key); > > > > > > and then do some updating: > > > > > > row.BeginEdit(); // here is where I get the exception > > > > > > foreach (string colname in collist) > > > row[colname]=mydatacollection[colname]; > > > > > > row.EndEdit(); > > > > > > The problem is: in a multithreaded scenario the "BeginEdit" method > > > will raise an exception if the row is already being updated by another > > > thread. At least that's how the it looks to me. So I put a lock on the > > > row > > > > > > lock (row) > > > { > > > row.BeginEdit(); > > > ... > > > > > > but that didn't help. I could not find special sync objects on the row > > > level, so does someone know an efficient way to get this exception > > > over with? > > > > > > Thanks in advance for any suggestion, > > > > > > DC |
|
|
|
#5 |
|
Junior Member
|
Hi DC,
Can u share out yr class code to me as i am facing yr problem as well. Thanks in advance. My email is woosweehong@yahoo.com Regards, Woo |
|
|
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

