HomeHomeUsing DotNetNuk...Using DotNetNuk...Administration ...Administration ...DataCache.GetCache usage causing exceptionsDataCache.GetCache usage causing exceptions
Previous
 
Next
New Post
1/16/2006 10:13 PM
 

I've noticed in quite a few places that the root cause for exceptions is the pattern I see DataCache.GetCache() used.

The patten that I see is:

If (DataCache.GetCache("object") Is Nothing)
   Dim obj = code for loading config from files
   
DataCache.SetCache("object", obj)
End If
Return DataCache.GetCache("object")

The problem I'm seeing is there is a time window between the SetCache and the final return that can result in the cache being thrown out, especially when multithreaded operations are happening.

Wouldn't the following pattern make more sense?

Dim obj = DataCache.GetCache("object")
If obj Is Nothing
   obj = code for loading config from files
   
DataCache.SetCache("object", obj)
End If
Return obj

 

 
New Post
1/21/2006 11:14 PM
 

Maybe no one cares...  but I went through my entire project and here are the files that had what appears to be a potential timing issue bug (search for DataCache.GetCache).  The interesting thing is out of 27 files, only these 8 followed this pattern.  The rest followed the pattern I suggested.

Domain.vb
Configuration.vb
XMLLoggingProvider.vb
RewriterConfiguration.vb
ClientAPI.vb
UserOnlineController.vb
Localization.vb
SiteLogController.vb

After putting the changes on my site, the number of exceptions I ran into significantly diminished.

 
New Post
1/23/2006 7:47 AM
 
James,
I'm very interesed in this changes and wanted to know if this change continues to look as the root of these exceptions.
Please if you're monitoring your system and let us know if this was the root problem.

Disgrafic.com
 
New Post
1/24/2006 6:27 AM
 

Without digging deeper into how the Cache expires, I can't say for sure this is the root issue.  That said, coding practices do say that you shouldn't return something you haven't verified to be null if the callers are not expecting null.  I also suspect the call would be faster allocating on object on the heap and assigning it once, rather then making another stack call to the cache function, though I'd have to verify that through ILSAM.

On my server, the random null reference exceptions I was getting for various functions all went away after making these changes.  The only exception I'm getting now is intermitent Thread Abort exceptions on the scheduler threads and a couple exceptions for the Forum module that I'd still trying to track down.

If you want details of the changes I made, I can either post or send a diff.

James

 
New Post
1/24/2006 7:12 AM
 

Hey james,

Could you send me a diff?  It sounds like it would clear up a lot off errors I'm seeing on my sites.  I get referals from google andmsn search that reference pages that have moves or no longer exist and the search engines aren't picking up on the 301's I send back but DNN generates the cache error you discribe.


Paul Davis
 
Previous
 
Next
HomeHomeUsing DotNetNuk...Using DotNetNuk...Administration ...Administration ...DataCache.GetCache usage causing exceptionsDataCache.GetCache usage causing exceptions


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

Attend A Webinar
Free Demo Site
Download DotNetNuke Professional Edition Trial
Have Someone Contact Me
Have Someone Contact Me

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

DotNetNuke Scoop!

Sponsors

DotNetNuke Corporation

DotNetNuke Corp. is the steward of the DotNetNuke open source project, the most widely adopted Web Content Management Platform for building web sites and web applications on Microsoft. Organizations use DotNetNuke to quickly develop and deploy interactive and dynamic web sites, intranets, extranets and web applications. The DotNetNuke platform is available in a free Community and subscription-based Professional and Enterprise Editions with an Elite Support option. DotNetNuke Corp. also operates the DotNetNuke Store where users purchase third party apps for the platform.