Wrox Programmer Forums
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 25th, 2007, 08:38 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default SQL Server session state latency

I've encountered a very interesting problem with ASP.NET SQL Server based session state.

I have an application using ASP.NET session configured to use SQL server. The application has an entry point page which takes some data on the query string, does some magic to the data and stores an object in session. After that the page redirects the browser to a new page containing a frame set with 2 frames. Then each frame loads another ASPX.

What's happening is that the entry page loads and does it's thing just fine. Then one frame will load fine, but the other will delivery a server runtime error that the value is not in session. Refresh that error page and it goes away. Sometimes the error will occur on the OTHER frame. The pattern seems to be that the error will occur intermittently on either frame on initial load, but never have I seen it happen on BOTH frames at the same time. And after the first loading of the framed pages the error goes away.

What I'm observing seems to be some kind of latency issue with SQL session state. Almost as if the first page pushes the data off to the session manager but the data isn't making it into SQL server before one of the framed pages loads.

I find it remarkable that this could be the case, but I can't explain it any other way. It also seems like this is some anomaly that results from framed pages. I have worked with SQL server session state in the past on web farms and haven't seem this behavior. My past experience has been in .NET 1.1 scenarios (not 2.0) however that really shouldn't make a difference.

I can not use In-Proc state management (which I believe has proven to fix the problem in testing) because the application is on a server farm.

We have worked around the problem by changing out the frame set for some other layout techniques, but it's not an ideal fix.

Anybody encountered this before or have any ideas?

To pre-answer the obvious questions:
- Yes, state is enabled on the pages that need it.
- Yes, cookies are enabled in my browser.
- Yes, I have properly configured and am connecting to the ASPstate database.
- Yes, my monitor is plugged in and turned on.
- and Yes, my coffee mug holder is retracted and stowed in it's upright and locked position.

-Peter
__________________
-Peter
compiledthoughts.com
twitter/peterlanoie
 
Old June 26th, 2007, 07:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hey there.. interesting issue.. just to ask something (because I don't have a clue), maybe one page is served from a Pc, and the other one is served from another Pc and that crash the SQL??

do you have the same problem when you call it from several clients at the same time???

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old June 26th, 2007, 12:42 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

It's very likely that one page is being served by one server and the other by another in the server farm. However, once the first page writes the data to the session the data should be there. But it clearly is not there for one page, but is for the other. Both applications are configured the same to use SQL session state and are accessing the same database.

-Peter
 
Old June 26th, 2007, 12:44 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Oh and I can't answer your second question. I haven't done any load testing. I won't bother to until I can get one user session to behave properly.

-Peter
 
Old July 18th, 2007, 09:47 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I might have discovered the culprit of this problem.

I my architecture, I am loading the session data fairly soon in the page lifecycle (probably during page load). It happens on-demand so each page could be different. I am saving the session data in an override of the Page.OnUnload() method in a page super class.

In the case where this problem was occurring, I have a site entry page that receives a hand off from another application. The hand off is processed and some data is put into session that is required by all subsequent pages. The page then redirects to the first viewable page.

Page.Render gets called before OnUnload. Presumably, the last step of the render method is to flush the Response buffer.

It occurred to me that perhaps the response output gets to the browser with the redirect instruction while that page thread is finishing execution. Then the browser requests the next page which starts processing on another page thread (either another thread on the same machine or another machine in the farm). This could happen before the previous page thread had completed the write to session.

In most cases I was able to refresh the browser and the error would go away. This evidence supports the theory. Any subsequent page requests would then load properly because the data was now in session state.

I'm skeptical that a small write to SQL could take longer than a round trip between the web server and the browser but I suppose it is within the realm of possibility.

I moved the code that writes to session to the beginning of Page.Render() and this seemed to fix the problem. We have had it reoccur but it has been the result of other issues. (Apparently I.E. does not like to send cookies to a page in a frame that comes from another host.)

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Session State with SQL Server Express 2005 toddw607 SQL Server 2005 1 December 18th, 2007 06:12 PM
SQL Session State & Object Array jlrolin ASP.NET 2.0 Professional 4 June 20th, 2007 12:49 PM
Session State Problem? caterpillar ASP.NET 1.0 and 1.1 Basics 8 August 17th, 2006 03:08 PM
Session State|View State|Do I have other options? rockon ASP.NET 1.x and 2.0 Application Design 2 October 5th, 2005 07:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.