Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michael Nielsen 154 posts 811 karma points
    Oct 20, 2022 @ 12:03
    Michael Nielsen
    0

    SQLite does not support ALTER TABLE operations

    When cloning down an Umbraco Cloud project, building it and running it locally, it will not start, I get an error saying: SQLite does not support ALTER TABLE operations (full error below).

    I've tested this on multiple machines, so it shouldn't be anything related to that.

    The project is using these versions of Umbraco and Vendr

    • Umbraco 10.2.1 (started as v9.0.1)
    • Vendr 2.3.1 (started as v2.0.3)

    I've tested it out with another project, which runs fine, and that is using

    • Umbraco 10.1.0 (started as v10.1.0)
    • Vendr 2.3.4 (started as v2.3.4)

    Since SQLite was added for Umbraco 10, I'm wondering if it might be related to that the project started as a v9 project, and was then upgraded.

    Not really sure on what to do to get the site up and running locally.

    System.NotSupportedException: SQLite does not support ALTER TABLE operations. Instead you will have to:
    1. Create a temp table.
    2. Copy data from existing table into the temp table.
    3. Delete the existing table.
    4. Create a new table with the name of the table you're trying to alter, but with a new signature
    5. Copy data from the temp table into the new table.
    6. Delete the temp table.
       at Umbraco.Cms.Infrastructure.Migrations.Expressions.Alter.Table.AlterTableBuilder.Do()
       at Vendr.Umbraco.Migrations.V_1_0_0.CreateStoreTableConstraints.DoMigrate()
       at Vendr.Umbraco.Migrations.VendrMigrationBase.Migrate()
       at Umbraco.Cms.Infrastructure.Migrations.MigrationBase.Run()
       at Umbraco.Cms.Infrastructure.Migrations.MigrationPlanExecutor.Execute(MigrationPlan plan, String fromState)
       at Umbraco.Cms.Infrastructure.Migrations.Upgrade.Upgrader.Execute(IMigrationPlanExecutor migrationPlanExecutor, ICoreScopeProvider scopeProvider, IKeyValueService keyValueService)
       at Umbraco.Cms.Infrastructure.Migrations.Upgrade.Upgrader.Execute(IMigrationPlanExecutor migrationPlanExecutor, IScopeProvider scopeProvider, IKeyValueService keyValueService)
       at Vendr.Umbraco.Events.Notification.Handlers.RunVendrMigrations.Handle(UmbracoApplicationStartingNotification notification)
       at Umbraco.Cms.Core.Events.NotificationHandlerWrapperImpl`1.<>c__DisplayClass0_0.<Handle>b__1(INotification theNotification)
       at Umbraco.Cms.Core.Events.EventAggregator.PublishCore(IEnumerable`1 allHandlers, INotification notification)
       at Umbraco.Cms.Core.Events.NotificationHandlerWrapperImpl`1.Handle(INotification notification, ServiceFactory serviceFactory, Action`2 publish)
       at Umbraco.Cms.Core.Events.EventAggregator.PublishNotification(INotification notification)
       at Umbraco.Cms.Core.Events.EventAggregator.PublishAsync[TNotification](TNotification notification, CancellationToken cancellationToken)
       at Umbraco.Cms.Infrastructure.Runtime.CoreRuntime.StartAsync(CancellationToken cancellationToken, Boolean isRestarting)
       at Umbraco.Cms.Infrastructure.Runtime.CoreRuntime.StartAsync(CancellationToken cancellationToken)
       at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
       at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
       at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
       at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
       at Program.Main(String[] args) in C:\Work\{ProjectPath}\Program.cs:line 9
    
  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Oct 20, 2022 @ 12:18
    Matt Brailsford
    0

    Hmm, I think your SQLite version might be an old one as SQLite does support ALTER TABLE for adding columns which is what that migration does.

    I'd check what version of Microsoft.Data.Sqlite you have installed and see if can be upgraded.

  • Michael Nielsen 154 posts 811 karma points
    Oct 20, 2022 @ 12:27
    Michael Nielsen
    0

    Microsoft.Data.Sqlite is v6.0.5 on both projects

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Oct 20, 2022 @ 12:28
    Matt Brailsford
    0

    What does your connection string in appsettings look like?

  • Michael Nielsen 154 posts 811 karma points
    Oct 20, 2022 @ 12:31
    Michael Nielsen
    0
    "ConnectionStrings": {
         "umbracoDbDSN": ""
    },
    

    Again, on both projects

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Oct 20, 2022 @ 12:39
    Matt Brailsford
    0

    I'm not quite sure what to suggest as to me it just sounds like the wrong SQLite version, so whether it's loading in a different version I'm not sure. Either that or Umbraco migrations didn't support SQLite alter table statements at that point, but then it's weird it would work on 10.1.0 and not 10.2.0.

    Only other option I could suggest would be to upgrade to Vendr 3.0.0 where the persistence layer and migrations no longer use Umbraco's built in API and so there would be more control over fixing the issue if it's then still relevant.

  • Michael Nielsen 154 posts 811 karma points
    Oct 20, 2022 @ 12:55
    Michael Nielsen
    0

    After upgrading Vendr to v3, the site still does not run, I get this error:

    ApplicationException: Unable to run migrations as no upgrade engine found for the configured provider: Microsoft.Data.Sqlite 
    
  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Oct 20, 2022 @ 13:20
    Matt Brailsford
    0

    Yup, in v3 SQLite support is optional see here to add it https://vendr.net/docs/core/3.0.0/how-to-guides/configuring-sqlite-support/

  • Michael Nielsen 154 posts 811 karma points
    Oct 20, 2022 @ 13:34
    Michael Nielsen
    0

    Ok, but is the documentation complete? It seems something is missing or not right? enter image description here

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Oct 20, 2022 @ 13:42
    Matt Brailsford
    0

    Do you have a using Vendr.Extensions?

    UPDATE Actually, I think this suggests your code isn't fully updated. Have you updated Vendr to v3 in all your projects?

  • Michael Nielsen 154 posts 811 karma points
    Oct 21, 2022 @ 07:19
    Michael Nielsen
    0

    You're right, I think that all pending changes must have been lost or discarded in git, because all packages had reverted back somehow🤷‍♂️

    And after ensuring all packages are upgraded, the error is gone, and the sites starts up, so far so good👏

    However, it does not finish with restoring , after a little while, I get an error saying:

    `The source environment has thrown a Microsoft.Data.Sqlite.SqliteException with message: SQLite Error 6: 'database table is locked'.`
    

    I can log into Umbraco, but no doctypes or template are there, the log gives me the full error

    Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 6: 'database table is locked'.
       at Vendr.Infrastructure.Resiliency.PollyExecutionStrategyBase.Execute[TResult](Func`1 operation, Func`1 verifySucceeded)
       at Vendr.Core.VendrUnitOfWorkProvider.Execute[T](IUnitOfWorkOptions options, Func`2 action)
       at Vendr.Core.VendrUnitOfWorkProvider.Execute[T](Boolean autoComplete, Func`2 action)
       at Vendr.Core.Services.CountryService.PerformGetAllCountryStates(Guid[] ids)
       at Vendr.Core.Cache.FullDataSetEntityStatePolicyCache`2.DoGetAll(Func`2 performGetAll)
       at Vendr.Core.Cache.FullDataSetEntityStatePolicyCache`2.Get(TId id, Func`2 performGet, Func`2 performGetAll)
       at Vendr.Core.Services.CountryService.GetCountryState(Guid id)
       at Vendr.Core.Services.CountryService.GetCountry(Guid id)
       at Vendr.Core.Api.CoreVendrApi.GetCountry(Guid id)
       at Vendr.Deploy.Connectors.ServiceConnectors.VendrCountryServiceConnector.GetEntity(Guid id)
       at Vendr.Deploy.Connectors.ServiceConnectors.VendrEntityServiceConnectorBase`2.GetArtifact(GuidUdi udi)
       at Umbraco.Deploy.Infrastructure.Connectors.ServiceConnectors.ServiceConnectorBase`3.Umbraco.Cms.Core.Deploy.IServiceConnector.GetArtifact(Udi udi)
       at Umbraco.Deploy.Infrastructure.Environments.CurrentEnvironment.GetSignatures(IEnumerable`1 udis, CancellationToken token)
       at Umbraco.Deploy.Infrastructure.Environments.CurrentEnvironment.ReviewManifest(Guid sessionId, Manifest manifest)
       at Umbraco.Deploy.Infrastructure.Environments.CurrentEnvironment.ReviewManifestAsync(Guid sessionId, Manifest manifest, CancellationToken token)
       at Umbraco.Deploy.Infrastructure.Work.WorkItems.DiskReadWorkItem.Proceed(List`1 artifacts, Manifest manifest)
       at Umbraco.Deploy.Infrastructure.Work.WorkItems.DiskReadWorkItem.ExecuteAsyncSub(IWorkContext context, List`1 resume, CancellationToken token)
       at Umbraco.Deploy.Infrastructure.Work.WorkItems.DiskReadWorkItem.ExecuteAsync(IWorkContext context, CancellationToken token)
    
  • Benji Peck 8 posts 98 karma points
    Oct 28, 2022 @ 09:52
    Benji Peck
    0

    Hi Michael,

    Did you find a solution for this issue?

    I'm getting the similar one, seams an issue with Countries

    Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 6: 'database table is locked'.
       at Vendr.Infrastructure.Resiliency.PollyExecutionStrategyBase.Execute[TResult](Func`1 operation, Func`1 verifySucceeded) at Vendr.Core.VendrUnitOfWorkProvider.Execute[T](Boolean autoComplete, Func`2 action)
       at Vendr.Core.Cache.FullDataSetEntityStatePolicyCache`2.DoGetAll(Func`2 performGetAll)
       at Vendr.Core.Cache.FullDataSetEntityStatePolicyCache`2.Get(TId id, Func`2 performGet, Func`2 performGetAll)
       at Vendr.Core.Services.CountryService.GetCountry(Guid id)
       at Vendr.Deploy.Connectors.ServiceConnectors.VendrEntityServiceConnectorBase`2.GetArtifact(GuidUdi udi)
       at Umbraco.Deploy.Infrastructure.Connectors.ServiceConnectors.ServiceConnectorBase`3.Umbraco.Cms.Core.Deploy.IServiceConnector.GetArtifact(Udi udi)
       at Umbraco.Deploy.Infrastructure.Environments.CurrentEnvironment.GetSignatures(IEnumerable`1 udis, IContextCache contextCache, CancellationToken token)
       at Umbraco.Deploy.Infrastructure.Environments.CurrentEnvironment.ReviewManifest(Guid sessionId, Manifest manifest)
       at Umbraco.Deploy.Infrastructure.Work.WorkItems.DiskReadWorkItem.Proceed(List`1 artifacts, Manifest manifest)
       at Umbraco.Deploy.Infrastructure.Work.WorkItems.DiskReadWorkItem.ExecuteAsyncSub(IWorkContext context, List`1 resume, CancellationToken token)
       at Umbraco.Deploy.Infrastructure.Work.WorkItems.DiskReadWorkItem.ExecuteAsync(IWorkContext context, CancellationToken token)
    
  • Michael Nielsen 154 posts 811 karma points
    Nov 01, 2022 @ 14:20
    Michael Nielsen
    0

    Hi Benji

    Unfortunately no, I'm still stuck with this issue.

    @Matt Brailsford any insight to this and how we may resolve this issue?

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Nov 01, 2022 @ 15:02
    Matt Brailsford
    0

    Hmmm, I'm not quite sure. I guess I'll have to setup a cloud environment with a store and see if I can replicate it restoring locally.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Nov 01, 2022 @ 15:04
    Matt Brailsford
    0

    How many countries are setup in your store?

  • Benji Peck 8 posts 98 karma points
    Nov 01, 2022 @ 15:06
    Benji Peck
    0

    Just 1 that was created United Kingdom

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Nov 01, 2022 @ 15:34
    Matt Brailsford
    0

    Ok, so yea, I can replicate this now.

    I'll have to dig into it and see what's going on 👍

  • Benji Peck 8 posts 98 karma points
    Nov 01, 2022 @ 15:35
    Benji Peck
    0

    Great, thanks.

    hopefully it's an easy fix

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Nov 01, 2022 @ 16:21
    Matt Brailsford
    0

    Ok, so it's not looking like a simple fix.

    When I debug into Vendr's code it seems to stem from the point we try to begin a transaction on the database. This ultimately times out with the table lock error. I've checked what I can and I can't see anything in our code that could be causing multiple connections on that table (only one request to connect to the DB is ever made, and that times out).

    My guess then is that within Umbraco Deploy they already have a transaction open on the database and so us attempting to make our own connection to the DB is failing.

    I'll need to check with Andy at HQ what happens inside deploy and see if he can suggest anything.

    Unfortunately I don't have a work around at this moment in time.

  • Benji Peck 8 posts 98 karma points
    Nov 01, 2022 @ 16:26
    Benji Peck
    0

    Damn, okay. Thanks for the quick update though.

  • Michael Nielsen 154 posts 811 karma points
    Nov 02, 2022 @ 07:32
    Michael Nielsen
    0

    @Matt Brailsford

    Thanks for the speedy response 👍

    I've created an issue here https://github.com/vendrhub/vendr/issues/394 mostly just for tracking, so I'll know as soon as there's a fix or workaround to it.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Nov 02, 2022 @ 08:42
    Matt Brailsford
    100

    Perfect! Thanks Michael. I'll post further updates on the issue 👍

  • Michael Nielsen 154 posts 811 karma points
    Nov 07, 2022 @ 11:28
    Michael Nielsen
    0

    To anyone else, a relatively simple workaround to the SQLite Error 6: 'database table is locked is to modify appsettings.Development.json and add this just after the Umbraco block.

    "ConnectionStrings": {
        "vendrDbDSN": "Data Source=|DataDirectory|/Vendr.sqlite.db;Mode=ReadWrite;Foreign Keys=True;Pooling=True",
        "vendrDbDSN_ProviderName": "Microsoft.Data.SQLite"
    }
    

    Then in appsettings.Production.json and appsettings.Staging.json you can set those to blank values

    "ConnectionStrings": {
        "vendrDbDSN": "",
        "vendrDbDSN_ProviderName": ""
    }
    

    This will create a separate SQLite DB for Vendr locally, and the locking issue can be avoided.

    Thanks to @Matt for that solution, which can be found here. https://github.com/vendrhub/vendr/issues/394#issuecomment-1301837359

Please Sign in or register to post replies

Write your reply to:

Draft