Recently we encountered an issue with a Sharepoint 2010 internet site we were putting the finishing touches to for a client.
After an innocuous layout and web part change, the application pool climbed to 100% CPU and would only resolve from an application pool restart. Page requests were not being served and there were many application event log entries for:
Cannot connect to SQL Server. name\SharePoint not found. Additional error information from SQL Server is included below.
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Installing SQL Management Tools (sadly not included in the base install) showed no connectivity or performance issues with the databases.
Next stop was the host - the build server was running as a single server installation as a VMWare Server Virtual Machine. We checked the resource allocation for virtual memory, hard faults, nothing unusual and no issues with the VM Host.
Time for IIS Peek, running this excellent tool showed multiple requests for a specific page from the host IP, there was no indexing going on, no site warmup routines, puzzling. The requests were to the main site collection and not the extended internet (anonymous) site. This was confirmed by viewing the active requests within IIS for the application pool worker process.
Time to inspect the page itself... our attention turned to Sharepoint Designer.
Microsoft SharePoint Designer (SPD), formerly known as Microsoft Office SharePoint Designer, is a specialized HTML editor and web design freeware for creating or modifying Microsoft SharePoint sites and web pages.
At Appius, SharePoint Designer 2010 is being used in the production of client sites, specifically in the development of page templates and layouts whilst also being used to control the look and feel through HTML, CSS and XSLT.
Recently during the build process it has been noticed that SharePoint Designer 2010, whilst being a very powerful piece of software, does come with a few drawbacks that can catch out the developer. When editing page layouts, occasionally SharePoint Designer 2010 alters the code. This can happen in one of two ways.
SharePoint Designer 2010 can alter the markup is when editing a Content Query webpart. When a Content Query webpart is placed in the layout, right clicking and selecting Properties will allow you to configure it, specifying the list or library to access, applying specific filters and controlling the output styling using xsl stylesheets. This will appear in the layout as control with a long list of attributes which are the items used to control the configurable aspects. If you need to configure webpart again however, this is where SP2010 can cause issues. If the Content Query webpart is re-opened and re-configured, upon saving SP2010 will re-write the webpart code on the page but will spit out pure html for certain parts, mainly where quotes are used (these are substituted to wrap the attribute settings).
Correctly formed webpart:
Malformed webpart after reconfiguration by SP Designer 2010:
If the layout is saved and published after this, no correlation ID or error will be shown to the user when the page is browsed, instead, the page with the malformed webpart will continue to be requested, causing the site to slowdown, ramping the host server's CPU to 100%. This makes the site unusable for the end user and eventually the page request will timeout.
Once we had identified the issue, essentially the webpart either needs to be removed and a replacement webpart placed in the layout which can be configured. Alternatively the page layout can be reverted using SharePoint Designers version history.
SharePoint Designer 2010 can also alter code when saving the file. When saving a page layout extra HTML is placed at the top and bottom of the page layout, specifically an '<html>' tag and a '<head>' at the top and ending '</html>' and '</head>' tags at the bottom.
Start of webpart:
<%@ Page language="C#" Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,
meta:progid="SharePoint.WebPartPage.Document" meta:webpartpageexpansion="full" %><%@ Register Tagprefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=184.108.40.206, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages"
Assembly="Microsoft.SharePoint, Version=220.127.116.11, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Register Tagprefix="PublishingWebControls"
Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=18.104.22.168, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Register
Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=22.214.171.124, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
If the layout is saved with the extra HTML and is published, when browsing the page the user will be presented with a page error containing a Correlation ID error.
To resolve, simply remove the extra markup and re-publish the page layout.
The moral of the story is to ensure you check your page layouts prior to them being published, specifically checking them for any malformed webparts or extra HTML!