Custom timeout: is there a way to find out which line of code is being executed?

(which line of code is executing in binary in production and not in Visual Studio)

First, a little frame for my problem: I have an error that is very difficult to track down because it happens randomly. Dapper hangs indefinitely on this error . Eliminate timeout, nothing. Only one request that runs endlessly. Probably an "unpleasant case of deadlock," as Mark Gravell responded in the comments.

To narrow down the problem, I created this timeout function:

/// <summary>
/// Usage:
/// var myResult = GetResultWithTimeout(() => MyFunction());
/// </summary>
public static TResult GetResultWithTimeout<TResult>(Func<TResult> func)
{
    var task = Task.Run(func);
    if (task.Wait(TimeSpan.FromSeconds(TimeoutInSeconds)))
        return task.Result;
    else
        throw new Exception($"Function timed out: {func.ToString()}");
}

      

I plan to wrap all mine _db.Query

and _db.Execute

(quite a few) with this function. I can't track the error when debugging because it occurs once every 1000 (?) Executions with no visible pattern. This is why I need to add this wrapper to my code in production, and hopefully the additional information I am catching helps me pinpoint the problem.

Now it would be much better to know exactly which operation is blocked by Dapper, so the title of the question is: Is there a way to find out which line of code is executing when a timeout occurs? If I could write this information to my exception it will give me information about where the deadlock is happening in Dapper.

0
c # dapper


source to share


No one has answered this question yet

See similar questions:

3
Dapper type display hangs on Windows 10 for large queries

or similar:

733
Best way to parse command line arguments in C #?
448
How To: Execute command line in C #, get STD OUT results
205
What's the fastest way to read a text file one at a time?
1
Getting product id from nopcommerce IConsumer <EntityFinalised <Product> Event
1
An error occurred while executing command definition - WCF
1
Eliminating weird entity entities
0
Entity Framework ExecuteStoreCommands exception in FirstOrDefault method
0
SQL Server 2014 + Entity Framework Command Timeout
0
Linq IEnumerable Error thrown spontaneously



All Articles
Loading...
X
Show
Funny
Dev
Pics