SqlTimeout view sql text

Posts   
 
    
Posts: 1255
Joined: 10-Mar-2006
# Posted on: 12-Mar-2019 14:50:54   

I have an SqlTimeout that is happening. I test what I 'believe' the sql actually is in production and it seems to work fine for me - but I am not quite sure what the actual SQL statement is that is executed. (Parameters and all)

I would like to log that in production. I short when an SqlException is thrown - I would like to be able to access the query text that was executed.

I have tools like RedGate Sql Monitor - but the command is 'canceled' by the client - so does not show up. I also cannot run your profiler in production.

Would like to just catch this exception or turn on some logging for just a single query or really, just be able to log when the exception happens.

Any ideas or thoughts?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 13-Mar-2019 10:33:04   

Do you receive an ORMQueryExecutionException? As that object contains the query as text + the parameters with values. https://www.llblgen.com/Documentation/5.5/ReferenceManuals/LLBLGenProRTF/html/78D52C64.htm

A timeout could happen because the query waits for a rowlock which isn't going to get lifted in time. E.g. you try to select from a row that's also being updated but forgot to add the object through which you select (as you use selfservicing) to the transaction and therefore it creates another connection. As the query originates from the same code/thread it will deadlock in that case and therefore you get the timeout. Running the query after that works fine (as in: it's not too slow to timeout) as there's no lock it has to wait for.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 1255
Joined: 10-Mar-2006
# Posted on: 13-Mar-2019 15:55:47   

That's good info, let me run with that and see what I come up with. Thanks.