I seeing a very bizarre timeout exception on what seems to be a very lightweight query, and I'm not sure why.
The query looks something like this
var locationId = 9;
var quantities = db.OrderDetails
.Where(d => d.ANullableDate == null
&& d.Order.LocationId == locationId
&& d.AnotherNullabelDate == null
&& d.ABooleanValue)
.Select(d => new { d.SkuId, d.Quantity })
.GroupBy(d => d.SkuId)
.ToList()
.ToDictionary(grp => grp.Key, grp => grp.Sum(x => x.Quantity));
A couple of notes about this:
- This works fine when locationId is not 9
- It worked fine yesterday.
- This works okay on my machine.
- It works okay on my machine when I configure it to use the DB in azure.
- If I pull the raw SQL related to this query from the Azure portal and run it directly against the Azure DB, it works fine.
- This query is significantly simpler, and uses significantly less data than other queries that are not failing.
- I searched for problem events via the query that can be found "https://learn.microsoft.com/en-us/azure/sql-database/sql-database-connectivity-issues" and nothing came up for around the time that the issue was occurring.
- In case you're curious about the
Select
call and theToList
call, they are things I tried after hearing of this issue(they didn't work).
I am totally at a loss as to what can possibly be the problem with this. What should I be looking for?
Update:
It's working now. The last thing I did before It started working again was to downgrade the DB from S4 to S3 (I did this because S4 configuration is in public preview).
Scaling it back up to S4 didn't cause the problem to start happening again, so I can't really assume that the scaling is what fixed it. I still have no idea what was wrong.