question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deadlocks occur when querying table storage many times concurrently (.NET Core 1.1.0)

See original GitHub issue

I’m having trouble with some deadlocks when querying table storage many times simultaneously. This happens whether I call cloudTable.ExistsAsync() and cloudTable.ExecuteQuerySegmentedAsync().

Having downloaded the source code for 8.1.1, I can see that the root of the issue seems to be in TableOperationHttpResponseParsers.cs. The problem is that instances of ODataReader are calling the Read() method when they should be taking advantage of the available ReadAsync() method.

Are these issues going to be fixed in the 8.2.0 release? My problem could be related to https://github.com/Azure/azure-storage-net/issues/431

The scenario can be reproduced with a simple Console Application (.NET Core 1.1.0) and using the following code sample:

private const string connectionString = "...";
private const string tableName = "...";

public static void Main(string[] args)
{
    Task.Run(async () =>
    {
        await MainAsync(args);
    }).GetAwaiter().GetResult();
}

static async Task MainAsync(string[] args)
{
    Console.WriteLine("Hello World!");
            
    var cloudStorageAccount = CloudStorageAccount.Parse(connectionString);
            
    // run the query many times simultaneously to produce the thread lock issue
    await Task.WhenAll(Enumerable.Range(0, 100).Select(m =>
    {
        return Query(cloudStorageAccount);
    }));

    Console.WriteLine(string.Format("We never get here..."));

    Console.ReadLine();
}

private static async Task<bool> Query(CloudStorageAccount cloudStorageAccount)
{
    var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
    var cloudTable = cloudTableClient.GetTableReference(tableName);

    Console.WriteLine(string.Format("Exists query started"));

    // threadlock occurs here when calling table.ExistsAsync() or table.ExecuteQuerySegmentedAsync()
    var result = await cloudTable.ExistsAsync();

    Console.WriteLine(string.Format("Exists query finished"));

    return result;
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
unaizorrillacommented, Dec 1, 2017

+1 here… any update about this issue

3reactions
benhardencommented, May 30, 2017

I’ve tried increasing the threadpool size by adding the following to the my project’s csproj:

<ThreadPoolMinThreads>4</ThreadPoolMinThreads>
<ThreadPoolMaxThreads>25</ThreadPoolMaxThreads>

This hasn’t made any discernible difference and still threadlocks. Am I doing this correctly?

Is there any other way I can use the azure-storage-net table library and not have it lock up on me? This is causing us a real headache on our production system and it seems ridiculous that we can’t make 100 calls to the server without it locking up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FIX: Deadlocks may occur when multiple concurrent query ...
FIX: Deadlocks may occur when multiple concurrent query notification subscriptions are fired on same objects in SQL Server 2005 or in SQL Server...
Read more >
Azure Table Storage multi row query performance
So most efficient way to get number of rows with partition and row keys known is to do them all with separate async...
Read more >
https://raw.githubusercontent.com/dotnet/samples/m...
When I get 3-5 days without failure I'll update this PR. ... Net [ManagedHandler] Investigate other options for concurrent connection limits and allocations ......
Read more >
TIBCO Data Virtualization User Guide
Displays and lets you set the number of times a trigger can be queued simultaneously before duplicates are dropped.
Read more >
Spring Boot Actuator Web API Documentation
The endpoint uses query parameters to limit the events that it returns. The following table shows the supported query parameters: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found