【发布时间】:2013-03-12 16:30:33
【问题描述】:
我有一个 MVC3 应用程序,它使用 nHibernate 和 memcached 作为二级缓存提供程序。我们间歇性地(但最近更频繁地)遇到奇怪的铸造问题。它是随机发生的,使 memcached 缓存失效将暂时解决问题。
它只发生在我们的 生产 环境中,因为我们不在其他环境中运行 memcached。但是,我在本地运行 memcached 并试图让这在本地发生,但没有运气。
我们在 Windows 上使用 memcached 1.2.6。这是堆栈跟踪。我知道这不会是足够的信息来确定任何事情,但如果有人对我如何调试它有任何想法,我将不胜感激。我正在尝试在我们的生产机器上进行远程调试,但这是一年中的一个忙碌时期并且有风险。
Unable to cast object of type 'System.Int32' to type 'System.String'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'.]
(Object , Object[] , SetterCallback ) +4270
NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValuesWithOptimizer(Object entity, Object[] values) +80
[PropertyAccessException: Invalid Cast (check your mapping for property type mismatches); setter of MyApplication.Business.Data.Program]
NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValuesWithOptimizer(Object entity, Object[] values) +207
NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValues(Object entity, Object[] values) +97
NHibernate.Cache.Entry.CacheEntry.Assemble(Object[] values, Object result, Object id, IEntityPersister persister, IInterceptor interceptor, ISessionImplementor session) +306
NHibernate.Cache.Entry.CacheEntry.Assemble(Object instance, Object id, IEntityPersister persister, IInterceptor interceptor, ISessionImplementor session) +147
NHibernate.Event.Default.DefaultLoadEventListener.AssembleCacheEntry(CacheEntry entry, Object id, IEntityPersister persister, LoadEvent event) +434
NHibernate.Event.Default.DefaultLoadEventListener.LoadFromSecondLevelCache(LoadEvent event, IEntityPersister persister, LoadType options) +800
NHibernate.Event.Default.DefaultLoadEventListener.DoLoad(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) +560
NHibernate.Event.Default.DefaultLoadEventListener.Load(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) +229
NHibernate.Event.Default.DefaultLoadEventListener.ProxyOrLoad(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) +438
NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType) +943
NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType) +99
NHibernate.Impl.SessionImpl.Get(String entityName, Object id) +117
NHibernate.Impl.SessionImpl.Get(Object id) +70
MyApplication.Business.Repositories.Repository`1.Get(Object id) +148
【问题讨论】:
-
什么是 MyApplication.Business.Data.Program ?它总是相同的异常吗? String=>Int32 让我(随机)想到 Enum,或者 query.substitutions,隐式转换……
-
总是同样的例外。程序是 nHibernate 实体。一旦错误开始,它就会一直存在,直到缓存失效。然而,最初的错误似乎是随机发生的。
-
您能详细说明一下您的设置吗?什么版本的nHibernate?哪个缓存提供者? memcached有哪些配置?等
-
如果没有更多细节,我认为您将很难在这里找到解决方案。
-
我只能说,我们已经在一个非常繁忙的生产环境中运行来自couchbase.com/download 的 1.8.1 发行版已经有一段时间了,并且从未遇到过问题。
标签: asp.net-mvc-3 nhibernate caching memcached