Skip to content
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

Migrations can stuck in a failing state after an import enables multiple features #16354

Open
Piedone opened this issue Jun 20, 2024 · 1 comment
Labels
Milestone

Comments

@Piedone
Copy link
Member

Piedone commented Jun 20, 2024

Describe the bug

When enabling multiple features in an import recipe, if the migrations of one feature fail, the migrations of other features can get stuck and not succeed either.

Orchard Core version

9d79ab5

To Reproduce

Follow the repro steps of #16346. Since that bug is now fixed, you can simulate a similar issue with a migration failing by e.g. changing OrchardCore.Facebook.Widgets.WidgetMigrationsCreateAsync() to this:

        public async Task<int> CreateAsync()
        {
            throw new System.Exception("This is a test.");
        }

Open e.g. /about or /blog/post-1 and note that you'll get the below "no such table: LocalizedContentItemIndex" exception. This is because of the migrations of Localization not running properly. However, there's no issue with those migrations, rather, it got stuck due to the migrations of Meta Social Plugins Widgets failing.

An unhandled exception has occurred while executing the request. Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such table: LocalizedContentItemIndex'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements()+MoveNext()
   at Microsoft.Data.Sqlite.SqliteCommand.GetStatements()+MoveNext()
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Dapper.SqlMapper.QueryAsync[T](IDbConnection cnn, Type effectiveType, CommandDefinition command) in /_/Dapper/SqlMapper.Async.cs:line 434
   at YesSql.Store.<>c__DisplayClass44_0`2.<<ProduceAwaitedAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at YesSql.Data.WorkDispatcher`2.ScheduleAsync[TState](TKey key, TState state, Func`3 valueFactory)
   at YesSql.Store.ProduceAwaitedAsync[T,TState](WorkerQueryKey key, Func`3 work, TState state)
   at YesSql.Services.DefaultQuery.Query`1.ListImpl()
   at YesSql.Services.DefaultQuery.Query`1.ListImpl()
   at OrchardCore.ContentLocalization.Services.LocalizationEntries.InitializeEntriesAsync() in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.ContentLocalization\Services\LocalizationEntries.cs:line 195
   at OrchardCore.ContentLocalization.Services.LocalizationEntries.EnsureInitializedAsync() in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.ContentLocalization\Services\LocalizationEntries.cs:line 71
   at OrchardCore.ContentLocalization.Services.LocalizationEntries.TryGetLocalizationAsync(String contentItemId) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.ContentLocalization\Services\LocalizationEntries.cs:line 37
   at OrchardCore.ContentLocalization.Services.ContentCulturePickerService.GetLocalizationFromRouteAsync(PathString url) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.ContentLocalization\Services\ContentCulturePickerService.cs:line 76
   at OrchardCore.ContentLocalization.ContentRequestCultureProvider.DetermineProviderCultureResult(HttpContext httpContext) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.ContentLocalization\ContentRequestCultureProvider.cs:line 23
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at OrchardCore.Diagnostics.DiagnosticsStartupFilter.<>c__DisplayClass3_0.<<Configure>b__1>d.MoveNext() in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.Diagnostics\DiagnosticsStartupFilter.cs:line 34
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at OrchardCore.ContentPreview.PreviewStartupFilter.<>c.<<Configure>b__0_1>d.MoveNext() in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.ContentPreview\PreviewStartupFilter.cs:line 16
--- End of stack trace from previous location ---
   at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore\Modules\ModularTenantRouterMiddleware.cs:line 47
   at OrchardCore.Modules.ModularTenantContainerMiddleware.<>c__DisplayClass4_0.<<Invoke>b__0>d.MoveNext() in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore\Modules\ModularTenantContainerMiddleware.cs:line 61
--- End of stack trace from previous location ---
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 291
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 295
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 301
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 305
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 305
   at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore\Modules\ModularTenantContainerMiddleware.cs:line 59
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)    at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements()+MoveNext()
   at Microsoft.Data.Sqlite.SqliteCommand.GetStatements()+MoveNext()
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Dapper.SqlMapper.QueryAsync[T](IDbConnection cnn, Type effectiveType, CommandDefinition command) in /_/Dapper/SqlMapper.Async.cs:line 434
   at YesSql.Store.<>c__DisplayClass44_0`2.<<ProduceAwaitedAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at YesSql.Data.WorkDispatcher`2.ScheduleAsync[TState](TKey key, TState state, Func`3 valueFactory)
   at YesSql.Store.ProduceAwaitedAsync[T,TState](WorkerQueryKey key, Func`3 work, TState state)
   at YesSql.Services.DefaultQuery.Query`1.ListImpl()
   at YesSql.Services.DefaultQuery.Query`1.ListImpl()
   at OrchardCore.ContentLocalization.Services.LocalizationEntries.InitializeEntriesAsync() in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.ContentLocalization\Services\LocalizationEntries.cs:line 195
   at OrchardCore.ContentLocalization.Services.LocalizationEntries.EnsureInitializedAsync() in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.ContentLocalization\Services\LocalizationEntries.cs:line 71
   at OrchardCore.ContentLocalization.Services.LocalizationEntries.TryGetLocalizationAsync(String contentItemId) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.ContentLocalization\Services\LocalizationEntries.cs:line 37
   at OrchardCore.ContentLocalization.Services.ContentCulturePickerService.GetLocalizationFromRouteAsync(PathString url) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.ContentLocalization\Services\ContentCulturePickerService.cs:line 76
   at OrchardCore.ContentLocalization.ContentRequestCultureProvider.DetermineProviderCultureResult(HttpContext httpContext) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.ContentLocalization\ContentRequestCultureProvider.cs:line 23
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at OrchardCore.Diagnostics.DiagnosticsStartupFilter.<>c__DisplayClass3_0.<<Configure>b__1>d.MoveNext() in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.Diagnostics\DiagnosticsStartupFilter.cs:line 34
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at OrchardCore.ContentPreview.PreviewStartupFilter.<>c.<<Configure>b__0_1>d.MoveNext() in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore.Modules\OrchardCore.ContentPreview\PreviewStartupFilter.cs:line 16
--- End of stack trace from previous location ---
   at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore\Modules\ModularTenantRouterMiddleware.cs:line 47
   at OrchardCore.Modules.ModularTenantContainerMiddleware.<>c__DisplayClass4_0.<<Invoke>b__0>d.MoveNext() in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore\Modules\ModularTenantContainerMiddleware.cs:line 61
--- End of stack trace from previous location ---
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 291
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 295
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 301
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 305
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 305
   at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext) in E:\Projects\OrchardForks\OrchardCore8\src\OrchardCore\OrchardCore\Modules\ModularTenantContainerMiddleware.cs:line 59
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

Note that only enabling Meta Social Plugins Widgets by hand does NOT cause a similar issue: its migrations will fail, the exception is logged, and everything else works still. I'd expect this to happen when enabling multiple features at once too.

Expected behavior

The offending migrations fail, but the migrations of all other features still run.

Logs and screenshots

See above.

Copy link
Contributor

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants