Joe Brinkman wrote:
The GetOrdinal problem is caused by a datareader not being properly closed in a section of code. This error normally only shows up under extremely heavy load and is a known issue with ADO.Net as it returns data from the wrong datareader.
I think there is also another explanation. I can reproduce this problem in a local site with not heavy load at all, browsing a single page, just me.
This is the problem (I think):
Let's say you have something like this in any 'controller' Core or 3rd party class:
Public
Function
GetUsersWhatever(
ByVal
PortalId
As
Integer
, ....)
As
List(Of UserInfo)
Return
CBO.FillCollection(Of UserInfo)(
DirectCast
(DataProvider.Instance().GetUsersWhatever(PortalId, ....), IDataReader))
End
Function
"GetUsersWhatever" stored procedure is not including every property of the UserInfo class. This is legitimate, right?
Let's say some of the 'missing' properties on the datareader are one or all of: CreatedByUserID, CreatedOnDate, LastModifiedByUserID, LastModifiedOnDate
These properties are not on UserInfo class, they are on BaseEntityInfo (UserInfo inherits from it).
In BaseEntityInfo class code, I read (5.6.1 source code, and I bet it's the same code in all the previous version where these properties were introduced too):
Protected
Overridable
Sub
FillInternal(
ByVal
dr
As
System.Data.IDataReader)
_CreatedByUserID = Null.SetNullInteger(dr(
"CreatedByUserID"
))
_CreatedOnDate = Null.SetNullDateTime(dr(
"CreatedOnDate"
))
_LastModifiedByUserID = Null.SetNullInteger(dr(
"LastModifiedByUserID"
))
_LastModifiedOnDate = Null.SetNullDateTime(dr(
"LastModifiedOnDate"
))
End
Sub
Which means that by default (unless FillInternal is overridden somewhere) these fields are expected, and if they are not found this will throw an exception (the one a lot of people see flooding their Event Logs).
It is OK for this code to assume the 'dr' will have these properties for sure? I think it should be changed, and do not have that for granted, because in fact, it's not always the case.
Thoughts?
Thanks,
Horacio.-