-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix: InvalidOperationException
thrown in QueryAliasIndex
when ISession
is still in "connecting" state
#16069
Comments
Thank you for submitting your first issue, awesome! 🚀 We're thrilled to receive your input. If you haven't completed the template yet, please take a moment to do so. This ensures that we fully understand your feature request or bug report. A core team member will review your issue and get back to you. If you like Orchard Core, please star our repo and join our community channels |
Hmm, curious. Doesn't this look like some YesSql issue @sebastienros? Which OC version are you using? |
OrchardCore 1.8.3 |
Are you using SQL Server? And what's the hosting environment, SQL Azure? |
Sorry, I should have said within my initial report. Azure SQL Server, authenticating using Azure AD. Connection timeout is 30 seconds. MultipleActiveResultSets is set to true. I'm currently running the site on IIS Express, on localhost, in Debug mode (Press Play in VS). But the same issue happens with our internal staging site hosted on IIS, on-prem, in Development environment, and our canary site, hosted on Azure AS, in Production environment. Same issue, same symptoms, same steps. The only change I've made is to update the I'm wondering if it's a clash with Blazor; as a "session" in Blazor is the scope of the SignalR circuit, which is per-user, per-tab. |
The protected override async Task OnInitializedAsync()
{
ContentItem = await Orchard.Content.GetContentItemByAliasAsync(Alias);
if (ContentItem is null) return;
var items = await ParseChildItemsAsync(ContentItem);
MenuItems = items?.ToList();
IsLoading = false;
}
I've tried adding a protected override async Task OnInitializedAsync()
{
await Policy
.Handle<InvalidOperationException>()
.WaitAndRetry(3, _ => TimeSpan.FromMilliseconds(500))
.Execute(async () => ContentItem = await Orchard.Content.GetContentItemByAliasAsync(Alias));
if (ContentItem is null) return;
var items = await ParseChildItemsAsync(ContentItem);
MenuItems = items?.ToList();
IsLoading = false;
} An |
Thanks for the details! This is not a solution, but can help in the interim: did you try SQL-level retries in the style of Also, with 1.8.x you shouldn't need to use MARS. That's only required if the app issues multiple queries in parallel with the same YesSql |
I set MARS to true because it complained when I first set up the site (on 1.18.2). I run multiple queries concurrently, but not specifically in parallel. i.e. The page is made of multiple components; the header grabs the header-menu, and site name, the footer grabs the gutter-menu, the sidebar grabs the header-menu. The main body of the page grabs the content item with the alias equal to the current page URI. Every page grabs the site name for the document title. But none of these things are done by way of Adding |
I have a suspicion that there is a YesSql connection service somewhere set to When I open multiple tabs, it is the older tabs that end up in error, not the new ones. If it was just congestion, or queuing, you would expect the new tabs performance to degrade overtime. Tab 1 starts loading, initialises a connection. That connection gets cached as a static flyweight/singleton. At this point, Tab 1 has a cached connection that it expects to be open, and available, but it's actually only just been initialised by tab 4, and is still connecting, so it throws the expection. Tab 4 knows to wait until the connection is stable, and then renders the page as expected. That would seem to make sense, in this scenario. Maybe a case for |
I have tried disabling MARS; it didn't make any difference. |
I've gone through the application on a I've been able to uncover a different stack trace that seems to say that it is a race condition with the Dapper connection. One scope is caching its connection, while another scope is trying to use that same cache. What I can't tell at the moment, is who is the onus on to ensure scope safety with this? Is it the app-dev (me), the framework (OC), or the data access (YesSql/Dapper)?
|
@ApacheTech it could be something in the framework. Are you by any chance able to upgrade to 2.0? With 2.0 and the YesSql upgrade, there is an option to detect occurrent issue. If you are able to upgrade, you can configure YesSqlOptions by setting EnableThreadSafetyChecks to true. |
I thought OrchardCore only went to 1.8.3 at the moment? After further digging, this is a clash between the Blazor component lifecycle, and whatever Dapper/Yessql/OC is doing behind the scenes. If I push all calls to |
1.8.3 is production ready. 2.0 "which will be released soon", is available using the preview feed. https://docs.orchardcore.net/en/latest/getting-started/preview-package-source/ You can review the release notes and address all the breaking changes |
Well.... that's my Friday sorted. Our GoLive is supposed to be around mid-June, early July. Is there a proposed release date for 2.0? |
There's no planned date but maybe mid-June looks realistic. We'll release once all 2.0 issues are fixed and (due to the huge fundamental changes with migrating to If the open bugs don't affect you, and you don't mind potentially finding new ones, then you can use the preview packages right now. Then, upgrading to the actual released 2.0 version will be seamless for you (unless we add new breaking changes :)). |
You can already try with the main branch or the nuget packages that ship nightly, no need to wait. |
In this case please add a |
Using a Would this be just a quirk of using OrchardCore with Blazor, or is it something that can be addressed at a lower level? If it is something for the app-dev to be aware of, that's fine. I'm seeing more and more people wanting to use Blazor with OrchardCore, so this is something good to know, and pass on to new devs dipping their toes in the water. |
@ApacheTech we welcome any PR that would improve things for Blazor. If you have an improvement, please submit a PR. I think @ns8482e and @agriffard worked with Blazor and OrchardCore. |
And @Skrypt. |
…iasIndex` when `ISession` is still in "connecting" state
Was a fix for this ever added to 2.x? |
No. |
Thank you for your insightful, and detailed answer. What is the expected ETA? |
Please look at the conversation above, and under your PR. This isn't actionable and thus won't be worked on. |
Describe the bug
When loading multiple pages of a site quickly in multiple tabs, a
InvalidOperationException
exception is thrown, due to calling theIOrchardHelper.GetContentItemByAliasAsync()
method.To Reproduce
My specific case uses a Blazor8 de-coupled site, global
InteractiveServer
, and usesGetContentItemByAliasAsync
for menus, and routing.Steps to reproduce the behaviour:
GetContentItemByAliasAsync
for anything such as routing, menus, etc.GetContentItemByAliasAsync
.Internal Server Error
, with a stack-trace similar to above.Expected behaviour
Each tab should load correctly, waiting for the YesSql session to be open and available, before executing the query.
Screenshots
Possible Solution
This method would likely need to be fleshed out to use a retry policy, or wait for the session to be open and available, before querying the database:
https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore.Modules/OrchardCore.Alias/Services/AliasPartContentHandleProvider.cs#L37
The text was updated successfully, but these errors were encountered: