Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Table locking between two processes WCF and Website
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Paul  
View profile  
 More options Sep 6 2012, 11:53 pm
From: Paul <shor...@gmail.com>
Date: Thu, 6 Sep 2012 20:53:24 -0700 (PDT)
Local: Thurs, Sep 6 2012 11:53 pm
Subject: Table locking between two processes WCF and Website

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!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul  
View profile  
 More options Sep 7 2012, 1:58 am
From: Paul <shor...@gmail.com>
Date: Thu, 6 Sep 2012 22:58:27 -0700 (PDT)
Local: Fri, Sep 7 2012 1:58 am
Subject: Re: Table locking between two processes WCF and Website

Having had more time to think about this as well as researching the
subject, do I:

- Just want to create a single SessionFactory via a static class that can
be accessed from both the web application and the WCF service?
- If that is the case, how would that work if I had another windows
application that uses the [UnitOfWork] attribute instead of [Transaction]?
 They both have to use different Session storage methods (i.e.
WebSessionStorage and ThreadSessionStorage as I recall during the
NHibernateSession.Init() method

Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul  
View profile  
 More options Sep 9 2012, 12:12 am
From: Paul <shor...@gmail.com>
Date: Sat, 8 Sep 2012 21:12:26 -0700 (PDT)
Local: Sun, Sep 9 2012 12:12 am
Subject: Re: Table locking between two processes WCF and Website

After more research and analysis, the issue boiled down to the isolation
level setting (which I wasn't aware of nor considered at the beginning of
this quest).  All of the transactions were utilizing the READ COMMITTED,
which I changed to READ UNCOMMITTED via the following property setting in
the NHibernate.config:

<property name="connection.isolation">ReadUncommitted</property>

This will allow NHibernate to set the transaction isolation level
accordingly.

Once I added the setting, I could run the WCF service as well as navigate
to areas in the web site that utilized the same tables as the WCF service
without any issues.  I should also mention that any method that performs
reads must have either a [Transaction] or [UnitOfWork] attribute as well.

I hope this helps others who may have come across this issue


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »