Hi Everyone,
I have an issue wherein I have tables being locked. Essentially I have data that I am parsing in my WCF service that is updating a few tables. The method is marked with a [Transaction] attribute. When I login to the site, the pages which use some of the data from these tables is timing out due to the transaction that is running in the WCF service (and the lock I believe it has). The process can be long, so any user who logs in will have to wait until it stops.
I have not set any optimistic or pessimistic locks explicitly in the code for both the WCF and web site. I am not sure at this point what and where I need to set this to avoid this. Any help would be appreciated!
I've tried adding this line to the configuration without any luck (both config files):
<property name="connection.isolation">ReadUncommitted</property>
I found some posts in regards to SessionFactory as well as FluentNHibernate mapping.Optimistic.[type]. I tried the latter, but not the former.
Here is the NHibernate Initializers:
WCF:
public static class NHibernateInitializer
{
public static void Init()
{
if (NHibernateSession.ConfigurationCache == null)
{
NHibernateSession.ConfigurationCache = new NHibernateConfigurationFileCache(new[] { "company.Domain" });
}
if (NHibernateSession.Storage == null)
{
NHibernateSession.Init(new ThreadSessionStorage(),
new[] { System.Web.Hosting.HostingEnvironment.MapPath("~/bin/company.Infrastructure.dll") },
new AutoPersistenceModelGenerator().Generate());
}
}
}
public class ThreadSessionStorage : ISessionStorage
{
[ThreadStatic]
private static ISession _session;
public ISession Session
{
get
{
return _session;
}
set
{
_session = value;
}
}
public ISession GetSessionForKey(string factoryKey)
{
return Session;
}
public void SetSessionForKey(string factoryKey, ISession session)
{
Session = session;
}
public IEnumerable<ISession> GetAllSessions()
{
return new List<ISession>() { Session };
}
}
Web site:
NHibernateSession.ConfigurationCache = new NHibernateConfigurationFileCache(new[] { "company.Domain" });
NHibernateSession.Init(
this.webSessionStorage,
new[] { this.Server.MapPath("~/bin/company.Infrastructure.dll") },
new AutoPersistenceModelGenerator().Generate());
Thanks!