Friday, October 9, 2015

"Koka webb" in progress

What you see here is actually a rockstar and a sailor discussing some very intricate system architecture structure stuff at Nansen HQ, Stockholm. This is what we call "koka webb"

Friday, October 2, 2015

Timeout exception during PageTypeBuilder update - DefaultValueType need a companion

TL DR; On a page property in PageTypeBuilder (PTB) - If you have DefaultValueType = DefaultValueType.Value, you must have DefaultValue set to something. Otherwise your site might cause timeout on startup while PTB does it’s thing.


The last months we've had problems with a clients test environment (EPiServer 6) regarding nasty timeouts while PageTypeBuilder does it's update on site startup. I spent some time cleaning the page types from missing/conflicting sort index on properties and removed tons of old page types that weren't in use anymore.

The issue

After the above mentinoed optimization, it felt like the startup ran smoother, but it was all an illusion. Every startup when PTB ran it's update, we got this exception:
Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
At first I assumed it was network related since the hosting provider have had problems during this period with their firewall and other network issues.

The solution

After I configured EPiServerLog.config to log level ALL, I began to see the truth.
Just before every timeout error there was the same page property, over and over again.

2015-10-01 13:54:46,383 DEBUG [39] PageTypeBuilder.Synchronization.PageDefinitionSynchronization.PageDefinitionUpdater.UpdateExistingPageDefinition - Updating PageDefintion, old values: Name: AddressSlimInfoText|Type:|EditCaption:Prenumerationen registreras på din..|HelpText:|Required:False|Searchable:False|DefaultValue:|DefaultValueType:None|LanguageSpecific:False|DisplayEditUI:True|FieldOrder:1120|Tab.ID:166|,new values: Name: AddressSlimInfoText|Type: |EditCaption:Prenumerationen registreras på din..|HelpText:|Required:False|Searchable:False|DefaultValue:|DefaultValueType:Value|LanguageSpecific:False|DisplayEditUI:True|FieldOrder:1120|Tab.ID:166|.
I navigated to the code for page type that had this property and saw this:
[PageTypeProperty(EditCaption = "Prenumerationen registreras på din..",
   Type = typeof(PropertyString),
   Tab = typeof(PurchaseFlowAddressSlimTab),
   DefaultValueType = EPiServer.DataAbstraction.DefaultValueType.Value,
   SortOrder = 1120)]
public virtual string AddressSlimInfoText { get; set; }

Took a while before I saw what was different from the other properties. This:
DefaultValueType = EPiServer.DataAbstraction.DefaultValueType.Value
But no DefaultValue was set.

I corrected this and then updated the test environment. Still got the same error, but now the log told me about the next property that had the same issue, and the next and the next etc.

So I had to go through all the page type properties in the code that used DefaultValueType and check to see if it had the matching DefaultValue or not.

When this was done, took a while, the site has about 100 page types and I found about 10-15 properties that had to be corrected, I updated the test site again and tried to trigged the timeout.

But alas, there was none.


It seems weird that this causes a timeout, there should be an ArgumentException or something further inside the EPiServer.DataAccess-assembly that actually does the page definition update. So when you set DefaultValueType to Value, you have to set DefaultValue to something

For us I think it was a combination of unstable network environment and time consuming PTB update that triggered this timeout. As a developer, at least you can give PTB the best possible conditions so it runs as smooth as possible.

Anywho…  if you have weird timeouts on an Epi 6 site. Check the obvious PTB mistakes such as duplicate/missing sort index etc, but also check the DefaultValueType/DefaultValue pairings.