This project is read-only.

Working with multi-tenant?

Dec 10, 2011 at 12:47 AM

We're trying to use this module in a multi-tenant situation.  Both tenants have the module installed.  But when both tenants have the module enabled, we get a runtime exception.

 

[IndexOutOfRangeException: Index was outside the bounds of the array.]
   NHibernate.Type.TypeFactory.Assemble(Object[] row, ICacheAssembler[] types, ISessionImplementor session, Object owner) +160
   NHibernate.Cache.Entry.CacheEntry.Assemble(Object[] values, Object result, Object id, IEntityPersister persister, IInterceptor interceptor, ISessionImplementor session) +70
   NHibernate.Event.Default.DefaultLoadEventListener.AssembleCacheEntry(CacheEntry entry, Object id, IEntityPersister persister, LoadEvent event) +545
   NHibernate.Event.Default.DefaultLoadEventListener.LoadFromSecondLevelCache(LoadEvent event, IEntityPersister persister, LoadType options) +880
   NHibernate.Event.Default.DefaultLoadEventListener.DoLoad(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) +513
   NHibernate.Event.Default.DefaultLoadEventListener.Load(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) +181
   Orchard.Contrib.Modules.NHibSecondLevelCache.Data.Providers.OrchardLoadEventListener.OnLoad(LoadEvent event, LoadType loadType) +461
   NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType) +403
   NHibernate.Impl.SessionImpl.Get(String entityName, Object id) +449
   NHibernate.Impl.SessionImpl.Get(Type entityClass, Object id) +374
   NHibernate.Impl.SessionImpl.Get(Object id) +391
   Orchard.Data.Repository`1.Get(Int32 id) in e:\Builds\1\PurchasEdge\Phoenix.Integration\Sources\Orchard\src\Orchard\Data\Repository.cs:87
   Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options) in e:\Builds\1\PurchasEdge\Phoenix.Integration\Sources\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:131
   Orchard.ContentManagement.ContentGetExtensions.Get(IContentManager manager, Int32 id) in e:\Builds\1\PurchasEdge\Phoenix.Integration\Sources\Orchard\src\Orchard\ContentManagement\ContentExtensions.cs:146
   Orchard.Settings.CurrentSiteWorkContext.Get(String name) in e:\Builds\1\PurchasEdge\Phoenix.Integration\Sources\Orchard\src\Orchard\Settings\CurrentSiteWorkContext.cs:13
   System.Linq.WhereSelectArrayIterator`2.MoveNext() +110
   System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +200
   Orchard.Environment.WorkContextImplementation.FindResolverForState(String name) in e:\Builds\1\PurchasEdge\Phoenix.Integration\Sources\Orchard\src\Orchard\Environment\WorkContextImplementation.cs:32
   System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +83
   Orchard.Environment.WorkContextImplementation.GetState(String name) in e:\Builds\1\PurchasEdge\Phoenix.Integration\Sources\Orchard\src\Orchard\Environment\WorkContextImplementation.cs:28
   Orchard.Localization.Services.SiteCultureSelector.GetCulture(HttpContextBase context) in e:\Builds\1\PurchasEdge\Phoenix.Integration\Sources\Orchard\src\Orchard\Localization\Services\SiteCultureSelector.cs:13
   System.Linq.WhereSelectArrayIterator`2.MoveNext() +110
   System.Linq.WhereEnumerableIterator`1.MoveNext() +196
   System.Linq.Buffer`1..ctor(IEnumerable`1 source) +488
   System.Linq.<GetEnumerator>d__0.MoveNext() +146
   System.Linq.Enumerable.Count(IEnumerable`1 source) +267
   Orchard.Localization.Services.DefaultCultureManager.GetCurrentCulture(HttpContextBase requestContext) in e:\Builds\1\PurchasEdge\Phoenix.Integration\Sources\Orchard\src\Orchard\Localization\Services\DefaultCultureManager.cs:58
   Orchard.Localization.Services.CurrentCultureWorkContext.<Get>b__0(WorkContext ctx) in e:\Builds\1\PurchasEdge\Phoenix.Integration\Sources\Orchard\src\Orchard\Localization\Services\CurrentCultureWorkContext.cs:13
   Orchard.Environment.<>c__DisplayClass7`1.<FindResolverForState>b__5() in e:\Builds\1\PurchasEdge\Phoenix.Integration\Sources\Orchard\src\Orchard\Environment\WorkContextImplementation.cs:37
   Orchard.Environment.WorkContextImplementation.GetState(String name) in e:\Builds\1\PurchasEdge\Phoenix.Integration\Sources\Orchard\src\Orchard\Environment\WorkContextImplementation.cs:28
   Orchard.Localization.Text.Get(String textHint, Object[] args) in e:\Builds\1\PurchasEdge\Phoenix.Integration\Sources\Orchard\src\Orchard\Localization\Text.cs:29
   Orchard.Users.Security.FrontEndFilter.OnAuthorization(AuthorizationContext filterContext) +616
   System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor) +156
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +691
   System.Web.Mvc.Controller.ExecuteCore() +162
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +305
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in e:\Builds\1\PurchasEdge\Phoenix.Integration\Sources\Orchard\src\Orchard\Mvc\Routes\ShellRoute.cs:148
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
Coordinator
Dec 13, 2011 at 3:14 PM

I have not tried this with multiple tenants, but I believe you're probably correct.  I've opened a work item on it, but no guarantees on when I'll be able to get to it.  Feel free to submit a patch if you find a workaround yourself.

Jan 13, 2012 at 11:52 PM

I just created a fork that uses a simple int counter to differentiate the SessionFactories; with this change, MultiTenancy is working for us.

Randon Spackman