PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Multiple writers / rowlocking

Reply

Multiple writers / rowlocking

 
Thread Tools Rate Thread
Old 30-06-2003, 04:30 PM   #1
DC
Guest
 
Posts: n/a
Default Multiple writers / rowlocking


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
  Reply With Quote
Old 02-07-2003, 09:15 AM   #2
DC
Guest
 
Posts: n/a
Default Re: Multiple writers / rowlocking

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

  Reply With Quote
Old 02-07-2003, 03:02 PM   #3
Kris
Guest
 
Posts: n/a
Default Re: Multiple writers / rowlocking

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



  Reply With Quote
Old 03-07-2003, 10:40 AM   #4
DC
Guest
 
Posts: n/a
Default Re: Multiple writers / rowlocking

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

  Reply With Quote
Old 18-07-2007, 03:45 AM   #5
shwoo79
Junior Member
 
Join Date: Jul 2007
Posts: 1
Trader Rating: (0)
Default

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
shwoo79 is offline   Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off