Umbraco 17.5.3 hosted on Azure PaaS

getting this error every 5 seconds in Production - any help on resolving this error is greatly appreciated.

System.InvalidOperationException: This SqlTransaction has completed; it is no longer usable.
at Umbraco.Extensions.NPocoDatabaseExtensions.GetCurrentTransactionIsolationLevel(IDatabase database)
at System.Runtime.ExceptionServices.InternalCalls.<RhpSfiNext>g____PInvoke|1_0(StackFrameIterator* __pThis_native, UInt32* __uExCollideClauseIdx_native, Boolean* __fUnwoundReversePInvoke_native, Boolean* __fIsExceptionIntercepted_native)
at Umbraco.Cms.Infrastructure.Scoping.Scope.get_Database()
at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.DistributedJobRepository.GetAll()
at Umbraco.Cms.Infrastructure.Services.Implement.DistributedJobService.TryTakeRunnableAsync()
at Umbraco.Cms.Infrastructure.BackgroundJobs.DistributedBackgroundJobHostedService.RunRunnableJob(CancellationToken stoppingToken)
at Umbraco.Cms.Infrastructure.BackgroundJobs.DistributedBackgroundJobHostedService.ExecuteAsync(CancellationToken stoppingToken)

Hi @srikanth-orbit

Are you running in a load balanced setup and did this only happen after updating to a certain version?

Justin

Hi Justin, thank you for reaching out. No, this is not a load balanced setup - this error in Logs has started appearing only after we upgraded from Version 13 to Version 17 recently. thanks

Hi @srikanth-orbit

Thanks for confirming.

That error comes from a background job runner that’s new in v17, so it wouldn’t have existed on 13. Looks like the upgrade didn’t fully apply to the database and it’s failing on the first poll after startup, then repeating every 5 seconds.

Can you check the Umbraco logs to see if you have any other errors, especially from when you migrated (if you still have them).

Also, can you run this SQL to see if you have the distributed jobs table:

SELECT name FROM sys.tables WHERE name LIKE 'umbraco%Job%'

You may also be able to change the logging for the Umbraco.Cms.Infrastructure.BackgroundJobs and Umbraco.Cms.Infrastructure.Scoping namespaces to Debug to see if you get any further information in the logs.

Justin

Thank you for your detailed response. Yes, there’s a ‘umbracoDistributedJob’ table - the logviewer has only this particular error appearing every 5 seconds - no other error reported.

thanks

Hi @srikanth-orbit

If you change the log levels to Debug for these two namespaces, do you see anything else that would help diagnose the issue?

Umbraco.Cms.Infrastructure.BackgroundJobs

Umbraco.Cms.Infrastructure.Scoping

Justin

Hi Justin, how can i selectively assign log level to ‘Debug’ for the 2 namespaces ? please clarify. thanks.

Hi @srikanth-orbit

In appSettings.json:

"Serilog": {
  "MinimumLevel": {
    "Default": "Information",
    "Override": {
      "Microsoft": "Warning",
      "System": "Warning",
      "Umbraco.Cms.Infrastructure.BackgroundJobs": "Debug",
      "Umbraco.Cms.Infrastructure.Scoping": "Debug"
    }
  }
}

Justin

thanks, Justin. I just applied the ‘Debug’ setting for the namespaces. One of the errors i’m seeing in logs now is

System.InvalidOperationException: 

This SqlTransaction has completed; it is no longer usable.
   at Microsoft.Data.SqlClient.SqlTransaction.ZombieCheck()
   at StackExchange.Profiling.Data.ProfiledDbTransaction.get_IsolationLevel() in C:\projects\dotnet\src\MiniProfiler.Shared\Data\ProfiledDbTransaction.cs:line 36
   at Umbraco.Cms.Infrastructure.Scoping.Scope.get_Database()
   at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.DistributedJobRepository.GetAll()
   at Umbraco.Cms.Infrastructure.Services.Implement.DistributedJobService.TryTakeRunnableAsync()
   at Umbraco.Cms.Infrastructure.BackgroundJobs.DistributedBackgroundJobHostedService.RunRunnableJob(CancellationToken stoppingToken)
   at Umbraco.Cms.Infrastructure.BackgroundJobs.DistributedBackgroundJobHostedService.ExecuteAsync(CancellationToken stoppingToken)


@justin-nevitech

I’m not sure if that will work as intended…

Serilog’s MinimumLevel.Default acts as a global floor for event creation. An override can only raise the restriction (e.g., from Information up to Warning or Error to quiet things down). It cannot promote a namespace’s logging level lower than the default floor. Because your default is set to Information, Serilog drops Debug events before they are ever generated, meaning your Umbraco background job and scoping Debug overrides will be completely ignored.

@srikanth-orbit was that new log entry actually tagged as debug ?

I have the feeling you need…

"Serilog": {
  "MinimumLevel": {
    "Default": "Debug",
    "Override": {
      "Microsoft": "Warning",
      "System": "Warning",
      "Microsoft.AspNetCore": "Warning",
      "Umbraco": "Information",
      "Umbraco.Cms.Infrastructure.BackgroundJobs": "Debug",
      "Umbraco.Cms.Infrastructure.Scoping": "Debug"
    }
  }
}

but you might have to add other namespaces too back to Info/warning if the logs are still too chatty from other debug namespaces.

you also need to watch for minimumlevels set in the sinks as they might also stop output of debug at the sink level.

eg

  "Serilog": {
    "MinimumLevel": {
      "Default": "Information"
    },
    "WriteTo": [
      {
        "Name": "UmbracoFile",
        "Args": {
          "RestrictedToMinimumLevel": "Information"
        }
      }
    ]
  },

Thanks for clarifying @mistyn8 I missed that part.

@srikanth-orbit

Are you able to update to the latest version of v17?

There have been some fixes to isolation scopes since the release you are using which may solve this.

The latest version is currently 17.6.2.

Justin

thanks both. i’ll try to upgrade to latest version and get back to you, thanks

The upgrade from 17.5.3 to 17.6.2 has resolved the Isolation scope error and the other errors related to Distributed Background jobs - CMS errors have reduced drastically. thanks

Hi @srikanth-orbit

That’s great to hear! Thanks for letting us know.

Justin