New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glimpse failing to load when opening connection to Access database #214

Closed
ghost opened this Issue Dec 20, 2012 · 13 comments

Comments

Projects
None yet
2 participants
@ghost
Copy link

ghost commented Dec 20, 2012

Hi guys,

Glimpse fails to load when I open a connection to a Access database. Here is my connection string: http://pastebin.com/4tWJvm2g

It's fine when I create a OleDbConnection instance. Glimpse fails where I open the connection. Chrome Javascript console error message here: http://pastebin.com/xL0bYqxV

Edit

I forgot to mention that this is a issue with RC-1

@avanderhoorn

This comment has been minimized.

Copy link
Member

avanderhoorn commented Dec 20, 2012

Just wondering if you can turn on logging and see what is going on. To turn logging on update your config to the following:

  <glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
    <logging level="Trace" />
  </glimpse>
@nikmd23

This comment has been minimized.

Copy link
Member

nikmd23 commented Dec 20, 2012

Also, @VimKin is it safe to assume that your connection code (below) is called in a controller action?

m_dbConnection = new OleDbConnection(
                "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + 
                AppDomain.CurrentDomain.BaseDirectory + 
                "bin\\AccessDb\\ExternalData.mdb");
@ghost

This comment has been minimized.

Copy link

ghost commented Dec 20, 2012

Edit

Log http://pastebin.com/PUnYQY9Y
@nikmd23 : The connection string is called at controller invoke. The "m_dbConnection.Open()" is called in a controller action. It's the Open-operation which makes Glimse fail to load.

@avanderhoorn

This comment has been minimized.

Copy link
Member

avanderhoorn commented Dec 20, 2012

Looking over this the only direct problem I can see is that the config tab will probably show an exception instead of the config data, but your saying Glimpse isn't showing at all. Is that correct? Also can you ensure that the cookie is set and that you can get to /glimpse.axd.

@ghost

This comment has been minimized.

Copy link

ghost commented Dec 20, 2012

That's right. Neither the glimpse icon or the "console" is showing. Both the glimpseId and glimpsePolicy is set and yes, I'm able to get to /glimpse.axd. Glimpse works for every Action on every controller except these two that opens a connection to the OleDbConnection.

I'll try to reconstruct the error and try to get back to you with additional info.

Edit

I tried to connecto a Access database in a new project. Like earlier, glimpse works fine with all other Actions. Here is some sample code: http://pastebin.com/0GJwf3Xj

I'll attach an image from the chrome debugging tool
glimpse

@nikmd23

This comment has been minimized.

Copy link
Member

nikmd23 commented Dec 21, 2012

I have a replication of the issue on my end, and I'm working on fixing the problem. I'll get a fix out ASAP, but may be delayed due to the holidays.

@ghost ghost assigned nikmd23 Dec 21, 2012

@nikmd23

This comment has been minimized.

Copy link
Member

nikmd23 commented Dec 21, 2012

I've spent all day pulling my hair out with this issue.

Here's what I know:

  1. Glimpse works as it should for the initial request to the controller that contains the data access code. Glimpse collects and persists the all request data.
  2. For some reason the current app domain is unloaded! This only happens when the oledbconnection is opened which of course flushes away the in memory persistence store for Glimpse.
  3. The browser makes a request for the saved data because of the script tags. This re-init's ASP.NET & Glimpse - but there is no data in the newly created persistence store which is why you see a 404 in Chrome's debugger.
  4. The client does have a bug in which it should render with a "data missing" message that I've already discussed with @avanderhoorn, but that still doesn't solve the problem of the app domain being unloaded.

I've tried uninstalling Glimpse to see if Glimpse was causing the problem somehow, but the app domain is unloaded even without Glimpse in the mix. I validated this by creating a separate HTTP Module that simply watches App Domain Unloads. You can browse around a site perfectly fine without unloads - but as soon as you hit the data access code it tanks.

I really am stumped right now. Anyone got any ideas about this?

@nikmd23

This comment has been minimized.

Copy link
Member

nikmd23 commented Dec 21, 2012

While investigating this, I can across a few improvements that could be made to Glimpse in general, which I will outline now and open issues for later:

  1. Glimpse client should render a "data missing" or "loading" message until the data is received from the server. Now issue #217.
  2. All status code resource results should be passing back a message to the client describing the status code. Now issue #218.
  3. There is a possible threading issue in the GetRuntime method in Glimpse.AspNet.HttpModule that needs to be fixed. Now issue #216.
@avanderhoorn

This comment has been minimized.

Copy link
Member

avanderhoorn commented Dec 26, 2012

I think it could be time to get some outside help on this one. Maybe we can put together a question and put in on StackOverflow - even set a bounty if it doesn't get much attention. I'm guessing the question will look something like the below:

Opening OleDbConnection kills App Domain

When I open a OleDbConnection, for some reason the current app domain is unloaded. As you might imagine, this is causing several issues. I validated this by creating a separate HTTP Module that simply watches App Domain Unloads. You can browse around a site perfectly fine without unloads - but as soon as you hit the data access code it tanks.

I really am stumped right now. Anyone got any ideas about this?

@nikmd23

This comment has been minimized.

Copy link
Member

nikmd23 commented Jan 4, 2013

@VimKin and @avanderhoorn,

I solved this issue today!

It was tough to track down, but in the end it's a really simple, and old, problem. I bet @VimKin has had this problem for awhile, but didn't realize it - Glimpse not appearing actually shed light on the underlying problem.

The underlying problem is the way that AppDomain's work in ASP.NET. You're probably aware that changing web.config causes the AppDomain (aka App Pool) to recycle. The truth is, that's an over simplification of the behavior. As of ASP.NET 2.0 touching/changing any file in the web root directory will trigger the file watcher and thus an AppDomain recycle. Opening an OleDBConnection to the .mdb file counts as a file touch, and as such the AppDomain is unloaded. @VimKin, this means that you are losing any in memory caches, session state and application state - which is what Glimpse uses under the covers by default - any time you open that connection.

That means that this isn't really a Glimpse issue. @VimKin, the simple fix is to simply move your .mdb file outside of the web root. I've confirmed this fixes the problem with a simple test on my machine. If you cannot move that file for some reason, it looks like there is a registry change you can make to change the default behavior of ASP.NET.

That said, I am going to make a change to Glimpse to help debug similar issues in the future. I will make sure that Glimpse logs all AppDomain Unload events. In addition, I will also create the three issues mentioned above.

This issue will be closed with the commit that does the actual logging.

Thanks for your help and support @VimKin - this was an excellent bug to track down and will result in many small improvements to Glimpse.

@nikmd23 nikmd23 closed this in a2a988e Jan 4, 2013

@avanderhoorn

This comment has been minimized.

Copy link
Member

avanderhoorn commented Jan 4, 2013

Fantastic work mate! Also interesting fact to boot.

I will also add those changes to the client to support the data payload not being there. Just a thought though. It would be good that if the payload resource detects that the data store is empty maybe it could report this to the client in the payload message (a message with a different structure). We could also make this message support the case where the cache isn't empty but your request wasn't found.

On 05/01/2013, at 9:33 AM, Nik Molnar notifications@github.com wrote:

@VimKin and @avanderhoorn,

I solved this issue today!

It was tough to track down, but in the end it's a really simple, and old, problem. I bet @VimKin has had this problem for awhile, but didn't realize it - Glimpse not appearing actually shed light on the underlying problem.

The underlying problem is the way that AppDomain's work in ASP.NET. You're probably aware that changing web.config causes the AppDomain (aka App Pool) to recycle. The truth is, that's an over simplification of the behavior. As of ASP.NET 2.0 touching/changing any file in the web root directory will trigger the file watcher and thus an AppDomain recycle. Opening an OleDBConnection to the .mdb file counts as a file touch, and as such the AppDomain is unloaded. @VimKin, this means that you are losing any in memory caches, session state and application state - which is what Glimpse uses under the covers by default - any time you open that connection.

That means that this isn't really a Glimpse issue. @VimKin, the simple fix is to simply move your .mdb file outside of the web root. I've confirmed this fixes the problem with a simple test on my machine. If you cannot move that file for some reason, it looks like there is a registry change you can make to change the default behavior of ASP.NET.

That said, I am going to make a change to Glimpse to help debug similar issues in the future. I will make sure that Glimpse logs all AppDomain Unload events. In addition, I will also create the three issues mentioned above.

This issue will be closed with the commit that does the actual logging.

Thanks for your help and support @VimKin - this was an excellent bug to track down and will result in many small improvements to Glimpse.


Reply to this email directly or view it on GitHub.

@nikmd23

This comment has been minimized.

Copy link
Member

nikmd23 commented Jan 5, 2013

@avanderhoorn See issue #218 for this!

@avanderhoorn

This comment has been minimized.

Copy link
Member

avanderhoorn commented Jan 5, 2013

Great!

nikmd23 added a commit that referenced this issue Jan 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment