Issue with saving content

When saving content in the Umbraco 13.10.0 backoffice (locally and on Azure app service), we see this error (nothing is logged weirdly) on every other save until we try an save again after seeing it:

An error occurred

Cannot save a non-current version.

Exception Details
System.InvalidOperationException, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e: Cannot save a non-current version.
Stacktrace
at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.DocumentRepository.PersistUpdatedItem(IContent entity)
   at Umbraco.Cms.Core.Cache.DefaultRepositoryCachePolicy`2.Update(TEntity entity, Action`1 persistUpdated)
   at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.EntityRepositoryBase`2.Save(TEntity entity)
   at Umbraco.Cms.Core.Services.ContentService.<>c__DisplayClass66_0.<CommitDocumentChangesInternal>g__SaveDocument|2(IContent c)
   at Umbraco.Cms.Core.Services.ContentService.CommitDocumentChangesInternal(ICoreScope scope, IContent content, EventMessages eventMessages, IReadOnlyCollection`1 allLangs, IDictionary`2 notificationState, Int32 userId, Boolean branchOne, Boolean branchRoot)
   at Umbraco.Cms.Core.Services.ContentService.SaveAndPublish(IContent content, String culture, Int32 userId)
   at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.PublishInternal(ContentItemSave contentItem, String defaultCulture, String cultureForInvariantErrors, Boolean& wasCancelled, String[]& successfulCultures)
   at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.PostSaveInternal[TVariant](ContentItemSave contentItem, Func`3 saveMethod, Func`2 mapToDisplay)
   at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.PostSave(ContentItemSave contentItem)
   at lambda_method1867(Closure, Object)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

Saving before this error is “successful” but no changes are visible on the website. Saving after this error is correctly successful and changes are represented.

There are no notification handlers nor custom programmatic content creation. I have tried clearing caches and deleting temp files. I have set content version cleanup to “0” on all counts (not sure if versions can be mass deleted?).

This is happening on two internal sites we have built, but doesn’t seem to be an issue on a third client site. It also feels like this is a recent issue since upgrading to newer version of Umbraco 13.

Any suggestions?

1 Like

Fixed! Looks like this was due to having the (fantastic) Maintenance Mode package use the database storage mode in appSettings.json, but I was running this in a non-load balanced setup:

"MaintenanceMode": {
	"StorageMode": "Database"
}

While this worked fine on our load balanced app, I guess this doesn’t perform as expected on a standard app.

super weird :frowning: - We will take a look at that, I can’t even remember writing the DB provider :slight_smile: - but looking at the code, can’t see anything other than we could probably cache it a bit. which might help as it hits the db to load config when you save.

1 Like

I expect I am probably not using it as intended? Caching may improve it, but so far I have not seen any issues using the db storage mode in load balancing.

Hi,

Fixed this in next release

Despite it’s version this will still work on v13

Basically the provider wasn’t handling the scope correctly (and not using CreateCoreScope because it was so old! .

Works now. doesn’t throw the error.

And the default provider stuff has changed so the default is “Auto” which will mean the file provider is used when you are on a single umbraco site, and the Database Provider is used when the site is running load balanced.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.