Last night an editor push published a new page and then found that the site half went down. Lots of pages errored and the logs filled with exceptions.
I’m going through it now and piecing together what happened when but I am seeing lots of exceptions in the run up this around the Markdown editor (which is used heavily in this site).
The other weird thing is errors with corrupted URL paths. E.g. a page that would be /news/some-article. Is in the logs as unavailable /some/unrelated/section/some-article.
Throwing the exception into Claude and it suggests there’s a thread safety issue with how the value convertor deals with it’s dictionary of internal links in multiple threads. It’s rather confidently telling me this can lead to cache corruption and is fixed in v18 as the markdown us changing from HeyRed to Markdig and this will solve all my problems (I am cautious as I was asking Claude about an unrelated issue with the Markdown editor so it might be a bit keen to jump here). It has also confidently spat out solutions - the most attractive looking like a simple change to apparently make the convertor threadsafe…
CLAUDE SUGGESTION:
Option B: keep HeyRed, but make it thread-safe. This gives output identical to what you have now. Creating an instance costs little, but if you want to avoid that, a [ThreadStatic] or ThreadLocal<Markdown> works too.
ed.MarkdownSharp;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Strings;
public class ThreadSafeHeyRedMarkdownToHtmlConverter : IMarkdownToHtmlConverter
{
public string ToHtml(string markdown) => new Markdown().Transform(markdown);
}
public class MarkdownToHtmlComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
=> builder.Services.AddUnique<IMarkdownToHtmlConverter, ThreadSafeHeyRedMarkdownToHtmlConverter>();
}
A full release seemed to clear up the problem (which Claude does also not without prompt) so I believe it was likely cache corruption and the push publish just tipped it over the edge… The admin controller site in the load balancing setup was serving the pages without issue when I tried them.
Has anyone run into either / this issue (the markdown exceptions could be a red herring here)?