DbUpdateException can cause LINQPad to hang (and query everything)
It looks like this old bug has returned in LINQPad9. I've just accidentally reproduced it on LINQPad v9.4.1 (X64)
The old workaround of adding this to MyExtensions still works:
static object ToDump(object input)
{
if (input is IQueryable)
return Util.OnDemand("(IQueryable)", () => input);
return input;
}

Comments
-
Just to be clear, is LINQPad actually hanging?
The output looks healthy (although it could be cleaned up).
-
yeah that's the output after overriding ToDump - before that LINQPad would give the appearance of still executing the query even though the DbException had been thrown already. What it's actually doing is querying all the other tables in the database (each of the "(IQueryable)"'s under Context) which would never finish in this case due to the size of them.
not a hang in the sense that we're not pumping window messages, but hung in that the only way out is to cancel the query.
-
Are you sure it's querying all the tables? They look stubbed to me in the screenshot.
-
I've cleaned up the rendering of that exception in 9.4.4. I still can't find where it would query all tables, though. Let me know if that makes any difference.
-
still repros with 9.4.4, I let it run and just killed each of the queries as they hit the db so I could grab this screenshot maybe it helps reveal what's going on:
it looks like it's definitely this Context property, which shows as collapsed but if I export the results to html I can see that it's definitely had all of its properties fetched (triggering all the queries I was killing)

if I click to expand it pops open immediately and shows the exceptions I caused by killing the underlying queries on the db:

-
one problem maybe is that though it intends to show only the first 1000 items the queries at the database are selecting the entire table (no top/limit, no where clause) and many of them are actually views with many columns so such queries generate large execution plans with excessive memory grants and such, there's a long time-til-first-row delay.
-
Can you provide any other clues? Is it a custom DbContext? Are you using LINQPad's driver? Do you have a ToDump active anywhere (such as in MyExtensions) that could be affecting it?
This is what I see:

-
yeah it's a custom DbContext, the class is like:
public class SowContext : DbContext { public DbSet<SomeEntity> SomeEntity { get; set; } ..etc hundreds more DbSet<T>'s... }it's these properties that appear in the Context property of the DbException's Entries
-
Did you set up SowContext by clicking "Add Connection" and choosing "DataContext from my own assembly"?
-
I was just instantiating it manually with no connection selected in linqpad. I just tried adding it via typed data context and doing it this way does not reproduce the issue.
I see all the same properties but they're green and not expanded automatically

