Unable to view SQL on SQL Tab when using transactions #772

Closed
shady14u opened this Issue Mar 31, 2014 · 20 comments

Projects

None yet

9 participants

@shady14u

When wrapping the DB context with a transaction per request the SQL tab will not show SQL and throws:

System.NullReferenceException: Object reference not set to an instance of an object. at Glimpse.Ado.Model.ConnectionMetadata.RegiserTransactionStart(TransactionMetadata transaction) at
Glimpse.Ado.Model.MessageAggregator.AggregateTransactionBegan() at 
Glimpse.Ado.Model.MessageAggregator.Aggregate() at Glimpse.Ado.Tab.SQL.GetData(ITabContext context) at 
Glimpse.Core.Framework.GlimpseRuntime.ExecuteTabs(RuntimeEvent runtimeEvent)

If I comment out the transaction.BeginTransaction() and the Commit. then the SQL Tab displays fine.

I am using MVC5 and EF 6.0.2 and wrap my requests like the following

on Application_BeginRequest I create a transaction and put it in the HttpContext Items collection

on Application_EndRequest I look for any errors and commit or roll back the transaction

@kriskater

I get a similar exception! In my situation there is no command in the Commands structure.

@avanderhoorn
Member

I'm going to look into this, but just to make sure, are you able to update to all the latest packages and make sure that the issue still exists?

@vadimi
vadimi commented Jul 1, 2014

I just was able to reproduce this issue. The error happens in ConnectionMetadata class in RegiserTransactionStart method when Commands dictionary is empty. Simple null check helps:

var command = Commands.FirstOrDefault(x => x.Value.Offset >= transaction.Offset);
if (command.Value != null)
{
    command.Value.HeadTransaction = transaction;
}
@avanderhoorn
Member

Arr makes sense... under what case would you have a transaction but no commands? I guess maybe if you start a transaction but the logic path in a given case avoids creating any commands?

@vadimi
vadimi commented Jul 2, 2014

Yes, I have a scenario when there are no db queries at all on several pages, but I use one transaction per request anyways.

@robdmoore

Any eta on when this might be fixed?

Thanks

@avanderhoorn
Member

@robdmoore Thanks for the poke. Currently working on some other bits at the moment. As pointed out the fix is quite simple, would you like to give it a go and send it in as a PR?

@robdmoore

Sorry, I've been flat out. Will do if I get a chance, not likely for a while though sorry.

@avanderhoorn avanderhoorn added this to the vNext milestone Jan 16, 2015
@avanderhoorn
Member

@robdmoore would be great if you can give it a crack, would love to get the fix into the next release.

@robdmoore

Nice - looks like someone else did this :)

When is the next release coming out?

Thanks mate

@NotMyself

Looks like I just ran into this bug with version 1.7.3. Has 1.7.4 shipped yet? or soon?

@avanderhoorn
Member

I'm going to try and get a release out early next week.

@avanderhoorn
Member

This is just waiting on one feature (keyboard shortcuts) to get in and then we will release.

@NotMyself

any updates @avanderhoorn ?

@NotMyself

Any updates @avanderhoorn ?

@avanderhoorn
Member

@NotMyself Thanks for pining me. Let me sync with the rest of the team and I'll get back to you next week.

@kedde
kedde commented Feb 1, 2016

Have 1.7.4 been released on nuget? Or will this issue only be addressed in asp.net core version? I'll see the vNext Milestone tag.

@jusefb
jusefb commented Apr 19, 2016

Hi,

Will this be fixed any time soon?

@feitzi
feitzi commented Sep 21, 2016

Why is this issue closed? There is now version released that fix this bug. Please release 1.7.4

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