S
Stephan Steiner
Hi
I have written a .NET service that uses two DataTables to store runtime
data. One column in one table is periodically updated (every 10 seconds, and
upon user request), another is updated upon user action.
The code works fine most of the time. I've had it running on a W2K server
for over half a year with little issues. Though when running the same code
on a W2K3 server, I regularly get IndexOutofRange exceptions at random
intervals (if I start the service it can run fine for two weeks, or it can
start throwing exceptions right away, and the problem might go away after a
while). Here's an example of such an exception:
03:59:03 Monitor.run for vm Cisco1 catched an exception: Index was out of
range. Must be non-negative and less than the size of the collection.
Parameter name: index source mscorlib stacktrace at
System.Collections.ArrayList.RemoveAt(Int32 index)
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)
at VRSService.Monitor.run() in c:\documents and settings\sste\my
documents\visual studio projects\vrsservice\vmmonitor.cs:line 787
The line of code throwing the exception is as follows:
myRow["timestamp"] = timestamp; // timestamp = 64bit integer representing
DateTime.Ticks
Now, in absence of any changes to the table and row in question (I have the
DataTable in one class, and send the appropriate row as constructor
parameter to the class that does the updating). The rows in the datatable
are never deleted/replaced, no new rows are ever inserted after the
application startup, and the first column (unique) is never updated. Also,
only updating the timestamp column (the most regular of any updates because
it happens every 10 seconds, whereas the rest is user triggered and a lot
less frequent) throws that error. During the 24h from Saturday midnight to
Sunday midnight (where no user ever connected), I got this error 5 times,
not for all rows, but for some rows more than once.
Since I'm not touching the table, and since the code can fail without any
apparent reason at any time, I'm getting the lingering suspicion that the
implementation of cell updates (the stacktrace makes me think the entire row
is removed and a new one added), can have a problem. I have never
experienced this problem when running the application on my development
boxes (WinXP), it might have happened once or twice in a half year period on
W2K server but it happens quite frequently on W2K3, which afaik is the only
one to not use the standard .NET framework.
Has anyone else ever experienced something like that? I have since written
my code to catch those exceptions (initially they'd be thrown and kill the
thread to do the update every 10 seconds, which eventually would lead to a
situation where the service had to be restarted), and funny enough it seems
that now once thrown, as the thread runs for the next time (10 seconds
later), things are okay again. Still, I shouldn't get those exceptions as
I'm not referencing any column in the row that is non existing.
Regards
Stephan
I have written a .NET service that uses two DataTables to store runtime
data. One column in one table is periodically updated (every 10 seconds, and
upon user request), another is updated upon user action.
The code works fine most of the time. I've had it running on a W2K server
for over half a year with little issues. Though when running the same code
on a W2K3 server, I regularly get IndexOutofRange exceptions at random
intervals (if I start the service it can run fine for two weeks, or it can
start throwing exceptions right away, and the problem might go away after a
while). Here's an example of such an exception:
03:59:03 Monitor.run for vm Cisco1 catched an exception: Index was out of
range. Must be non-negative and less than the size of the collection.
Parameter name: index source mscorlib stacktrace at
System.Collections.ArrayList.RemoveAt(Int32 index)
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)
at VRSService.Monitor.run() in c:\documents and settings\sste\my
documents\visual studio projects\vrsservice\vmmonitor.cs:line 787
The line of code throwing the exception is as follows:
myRow["timestamp"] = timestamp; // timestamp = 64bit integer representing
DateTime.Ticks
Now, in absence of any changes to the table and row in question (I have the
DataTable in one class, and send the appropriate row as constructor
parameter to the class that does the updating). The rows in the datatable
are never deleted/replaced, no new rows are ever inserted after the
application startup, and the first column (unique) is never updated. Also,
only updating the timestamp column (the most regular of any updates because
it happens every 10 seconds, whereas the rest is user triggered and a lot
less frequent) throws that error. During the 24h from Saturday midnight to
Sunday midnight (where no user ever connected), I got this error 5 times,
not for all rows, but for some rows more than once.
Since I'm not touching the table, and since the code can fail without any
apparent reason at any time, I'm getting the lingering suspicion that the
implementation of cell updates (the stacktrace makes me think the entire row
is removed and a new one added), can have a problem. I have never
experienced this problem when running the application on my development
boxes (WinXP), it might have happened once or twice in a half year period on
W2K server but it happens quite frequently on W2K3, which afaik is the only
one to not use the standard .NET framework.
Has anyone else ever experienced something like that? I have since written
my code to catch those exceptions (initially they'd be thrown and kill the
thread to do the update every 10 seconds, which eventually would lead to a
situation where the service had to be restarted), and funny enough it seems
that now once thrown, as the thread runs for the next time (10 seconds
later), things are okay again. Still, I shouldn't get those exceptions as
I'm not referencing any column in the row that is non existing.
Regards
Stephan