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.

[BUG] Azure Search: Deadlock searching for documents with DocumentsOperationsExtensions.Search()

See original GitHub issue

Describe the bug We’ve upgraded our existing Azure Search implementation to use the newest 9.0.0 version of .NET SDK, resolved all breaking changes, but the synchronous search methods seem to deadlock.

Stack Trace

mscorlib.dll!System.Threading.ManualResetEventSlim.Wait(int millisecondsTimeout = -1, System.Threading.CancellationToken cancellationToken)
mscorlib.dll!System.Threading.Tasks.Task.SpinThenBlockingWait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken)
mscorlib.dll!System.Threading.Tasks.Task.InternalWait(int millisecondsTimeout = -1, System.Threading.CancellationToken cancellationToken)
mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task task = Id = 2351, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}")
Microsoft.Azure.Search.Data.dll!Microsoft.Azure.Search.DocumentsOperationsExtensions.Search(Microsoft.Azure.Search.IDocumentsOperations operations, string searchText, Microsoft.Azure.Search.Models.SearchParameters searchParameters, Microsoft.Azure.Search.Models.SearchRequestOptions searchRequestOptions)
CMSApp.dll!CMSWebParts_DancingGoat_Samples_DancingGoatSmartSearchAzure.Page_Load(object sender = CMSAbstractWebPart("SampleDancingGoat_SmartSearchAzure"), System.EventArgs e = {System.EventArgs})
....

Code Snippet

result = searchIndexClient.Documents.Search(searchString, searchParams);

It seems the following code in DocumentsOperationsExtensions.cs is missing a ConfigureAwait(false) before synchronously waiting for the result.

public static DocumentSearchResult<Document> Search(
            this IDocumentsOperations operations,
            string searchText,
            SearchParameters searchParameters = null,
            SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
        {
            return operations.SearchAsync(searchText, searchParameters, searchRequestOptions).GetAwaiter().GetResult();
}

Similar methods possibly with the same issue: Microsoft.Azure.Search.DocumentsOperationsExtensions.Search(...) Microsoft.Azure.Search.DocumentsOperationsExtensions.Search\<T\>(...) Microsoft.Azure.Search.DocumentsOperationsExtensions.Count(...) Microsoft.Azure.Search.DocumentsOperationsExtensions.Autocomplete(...) etc.

Expected behavior No deadlock. Synchronous search is possible.

Setup (please complete the following information):

  • Azure Search .NET SDK version 9

Additional context I can see the JSON response in Fiddler, but the method doesn’t return anything.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [ x ] Bug Description Added
  • [ x ] Repro Steps Added
  • [ x ] Setup information Added

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
brjohnstmsftcommented, May 16, 2019

Version 9.0.1, which includes this fix, is now available on NuGet.

0reactions
brjohnstmsftcommented, May 16, 2019

@tomillie Thanks for confirming. I have a PR out for the fix and I hope to be able to push it to NuGet today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DocumentsOperationsExtensions Class
Retrieves the next page of search results from the search index. https://docs.microsoft.com/rest/api/searchservice/Search-Documents.
Read more >
Analyze and prevent deadlocks - Azure SQL Database
This article teaches you how to identify deadlocks in Azure SQL Database, use deadlock graphs and Query Store to identify the queries in...
Read more >
Upgrade to Azure Cognitive Search .NET SDK version 11
Migrate your search application code from older SDK versions to the Azure Cognitive Search .NET SDK version 11.
Read more >
Monitoring Deadlocks in Azure SQL Managed Instance
You have a couple different ways to monitor them in Azure SQL Managed Instance. Let's review those together. What is a deadlock?
Read more >
DocumentsOperationsExtensions.SearchAsync Method
SearchAsync(IDocumentsOperations, String, SearchParameters, SearchRequestOptions, CancellationToken). Searches for documents in the search index. https://docs.
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