Working around the 'no nodes' issue with Umbraco 4.5.x
Updated: I've added some code to the snippet below to see if you have an empty cache before doing the republish.
A while back I ran into an issue where this site would regularly go off line and revert to the Umbraco "no nodes" splash page that you usually get post install.
As the forum thread explains this seems to be an issue introduced in Umbraco 4.5.x where the content cache can't be created on startup if SQL server is unavailable (I presume it just fell back to the old cache in previous versions). I was getting the issue on a regular basis as my hosting provider had enabled my server to auto restart after installing windows updates. When the server started up there was a race condition between the SQL server and IIS services - more often than not IIS would start first and SQL would not be available.
The solution was to Republish the cache manually via the Umbraco GUI once all services were up. Not wanting to have to do this every time I delved into the source and found the following code.
Server.ScriptTimeout = 100000; var cacheFile = IOHelper.MapPath("~/App_Data/umbraco.config"); var r = XmlReader.Create(cacheFile, new XmlReaderSettings() { DtdProcessing = DtdProcessing.Ignore }); var d = new XmlDocument(); d.Load(r); var n = d.SelectSingleNode("//root"); if (n.ChildNodes.Count != 0) return; Document.RePublishAll(); library.RefreshContent();
So, rather than do the republish manually every time the issue occurs, I've replaced the out of the box noNodes.aspx with a page that executes the code above and does a redirect to the referer.
The correct solution of course would to be able to control the order in which services on the server come up. But this may suffice as a nice little workaround for any of you experiencing the same problems.
Comments
Connie DeCinko
I also need more information about how to implement this. What should the page inherit from? Where do we put the codebehind? Additional information would be helpful.
Darren Ferguson
I should have mentioned that there should be some conditional logic around the code block above to check that the cache is actually empty.
Dick Gennissen
Hi Darren, We also have experienced this issue with Umbraco 4.7.0 and did not find any reason why the umbraco.config was empty. Strange this was, when we republished the entire site (from content-node) also nothing happend. The cmsContentXml table was also empty. Was this also the case when you have encountered this issue?
happyfanaticsalsero
Hi Darren, Thanks a lot for your weblog about this issue (and posts on our.umbraco.org) as I've just had a nasty occurence myself. My hosting company had some deadlocks on a database which had to restart... and because of a websitepanel upgrade IIS was restarted as well. Although it seems unlikely this will reproduce a lot of times, it may and I want to apply a fix. How do I put the custom nonodes page in place? Just make an aspx with your code and put it in the umbraco root? Or will I need to perform any other tricks? Kind regards & thanks in advance, HFS
Sebastiaan Janssen
It is possible to do some registry hacking and create dependencies for services, but that might be worse than this solution, which is a quite nice hack in actually. The real correct solution however, would be if Umbraco actually did a fallback to the disk cache as long as it can't access the database server. This is how it used to work in 4.0.x, except I don't think it ever went looking for the SQL server after the fallback.
Yohan
Darren, Could you post your code? It would be very helpful to see what all references you're using at the top of the code, what namespace "Document" is in, what type the "library" object is, etc. Also, as HFS asked, are there any other steps you have to take? Drop your own dll into the bin, make changes to web.config, etc.? I'm dealing with this nonodes.aspx issue too, so thanks for your help.