New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Umbraco 8 - SQL Server 2022 NuCache Error Using JSON Serializer #14173
Umbraco 8 - SQL Server 2022 NuCache Error Using JSON Serializer #14173
Conversation
Hi there @justin-nevitech, thank you for this contribution! 👍 While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
Apologies if this is the wrong base branch to use, let me know if I need to change it. |
Thanks @justin-nevitech for spotting and fixing this. Someone from the team will have a look at it soon. Regarding the branch, I'm not sure but @nul800sebastiaan will certainly be able to help 😁 Cheers! |
Just to add a bit more context, when the NuCache is rebuilt using the JSON serializer, the binary raw data is null. For a null value, NPoco assumes it is a string and creates an NVARCHAR(4000) parameter which causes this error. The solution is to ensure the parameter is a VARBINARY(MAX) for a null raw data. This must be a change in SQL Server as it worked in 2019. I tried adding an NPoco mapper but this did not get called as the value was null. A workaround is to change the serialiser to MsgPack in the web.config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @justin-nevitech I've left a few comments.
I don't see any build errors (the CodeScene ones are just warnings, no need to look at those) so everything is completely fine!
The branch is also correct 👍
Hi! I have run into this issue on a few clients that are moving to a new hosting solution, which involves upgrading our SQL server to 2022. Is there anything we can do to help implement this solution in Umbraco? :) |
Hi Elisabeth, If you add/change the serializer in your web.config to the following as a work-around it should work.
Regards, |
Thanks again @justin-nevitech and sorry for the delay, this is good to go now. That said, I am unsure when we'll create a new release of v8, but at least there's a workaround for now. Thanks! |
Hi @justin-nevitech @nul800sebastiaan, I'm running into the issue on Umbraco 8.18.8 but I don't see this line in the web.config Just to confirm do I need to add this into the config to fix the issue? And will it have any adverse effects on Umbraco Cloud hosting? (sry if this is a question with an obvious answer, pretty new to this side of Umbraco) Thanks, |
Hi @si25 Yes, you will need to add the following to your web.config:
I've not noticed any issues doing this on my local development machine but I've not had to do it on any production sites or Umbraco Cloud. Maybe try it on a staging copy of the site first just to be sure. I don't know what version of SQL Server is used on Umbraco Cloud as to whether this is a problem or not. Regards, |
Thanks @justin-nevitech! |
Just upgraded my developer workstation and ran straight into this issue, took a while to find this link. Is there any information available on what effects the 'set Serialiser to MsgPack` solution has? I wasn't able to find any reference documentation pertaining to Umbraco v8. Not sure if we need/want this setting in production. |
Hi @keithlfs It mentions here what the MsgPack change was: https://umbraco.com/blog/umbraco-815-release/ I believe it was the default from 8.15 onwards, so you should be ok to use it as far as I am aware. |
Prerequisites
Description
When using the latest version of Umbraco 8 on SQL Server 2022, there is an error when rebuilding the NuCache database cache when the serializer is set JSON and not MsgPack in the web.config (which older sites most likely will be). This can happen from the Settings > Published Status screen in the back-office or when booting, making the site error completely and never load. If you are able to login to Umbraco the same error can also happen when saving document types.
The following exception is thrown:
This works perfectly fine on SQL Server 2019 but not SQL Server 2022.
<add key="Umbraco.Web.PublishedCache.NuCache.Serializer" value="MsgPack"/>
SQL Server 2019 Express (15.0.4312) - The error does not occur.
SQL Server 2022 Express (16.0.4025) - The error occurs as described above.
I have tested the fix on both SQL Server 2019 and SQL Server 2022 and they both work fine.
There are 3 failing tests but none of them are due to these changes.
This is quite a fundamental issue so I think it really needs merging.