RemoteRecipeExecutor GetShellContext() sometimes returns null.

Dec 15, 2014 at 8:07 PM

We are running a multi-tenant instance of Orchard CMS 1.8.1 with the RemoteRecipeExecutor and have been experiencing an intermittent issue that effects some of the tenants. We are noticing that for some reason when we are attempting to execute code against a particular tenant that on occasion GetShellContext() returns null. Of course this method returning null causes the next line of code (LifeTimeScope) to raise an exception of object reference not found. Since this only occurs in our production environment, we can’t say for 100% certainty that GetShellContext is the culprit without adding tracing logic to the code and rolling that out to production which we prefer not to do. It should also be known that the tenant site itself as well as the admin site will still be running with no problems. It’s just any API calls that need to grab context that have this failure and again just for that particular tenant.

We are wondering if you could share any thoughts on why this problem might be occurring. To date, the only way we have found to resolve the issue is to restart the Application Pool which of course effects all tenants. Below is a quick screen shot of one instance of code that we use in our API calls. Any guidance on this matter is greatly appreciated. (Our sites are running in IIS 7)

``` Specifically, have you ever encountered situations in your production sites where line 47 of RecipeExecutor.cs...
var shellContext = _orchardHost.GetShellContext(new ShellSettings { Name = recipe.TenantName }); ...
returns a null when it shouldn't.


Dec 15, 2014 at 10:25 PM

GetShellContext() returns null if the tenant doesn't exist or is not running. So there should be something going on with that specific tenant.
Dec 16, 2014 at 4:56 PM
Edited Dec 16, 2014 at 4:57 PM
Thanks for responding. However, the interesting thing about this particular issue is that the tenant’s site seems to be unaffected and you can navigate to various pages (including the admin site) with no issues. It’s only when we attempt to call the RecipeRemoteExecutor that this failure occurs. So the tenant is running and not disabled but the RecipeRemoteExecutor seems unable to load the shellContext. It is really weird.

The only fix at this point is to recycle the app pool. And also when it happens it is not all the tenants...only one (or a few maybe) is behaving this way.

Have you ever seen this kind of behavior? Would you have recommendation on how to setup logging to give us more information and insight into the cause?

Could caching effect this?


Dec 16, 2014 at 8:54 PM
You could enable logging for DefaultOrchardHost to see when tenants actually start and the like.

Unless you're running multiple server nodes this doesn't have to do anything with caching AFAIK. If you have multiple servers you can run into this though when the tenant is not running on that server node, despite running on others.
May 19, 2015 at 5:42 AM

This is the issue in the Orchard itself. This issue is in cache of shell context. To fix this issue we need to add extra check after shell context. I spend 3 full days to fix this issue.