Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tomillie opened this issue May 13, 2019 · 5 comments · Fixed by #6298
Assignees
Labels

Comments

@tomillie
Copy link

tomillie commented May 13, 2019

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
@triage-new-issues triage-new-issues bot added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label May 13, 2019
@brjohnstmsft brjohnstmsft self-assigned this May 14, 2019
@brjohnstmsft
Copy link
Member

Thanks for reporting this. We're aware of the issue and are looking into it.

@brjohnstmsft
Copy link
Member

@tomillie The code you pointed out hasn't changed since 5.0.3. There is a missing ConfigureAwait(false), but I don't think it's there.

I have a few questions that will help confirm my hypothesis:

  1. Can you confirm whether the other methods block too, or is it only Search?
  2. If you set UseHttpGetForQueries to true, does the issue go away?

@tomillie
Copy link
Author

Hi, sorry for the delay...

  1. I tried the methods I mentioned in the first comment and they don't deadlock. So it seems only Search() is affected.
  2. Yes, that helped.

By the way, we had no problem with the version 5.0.3, only 9.0.0 seems faulty.

@brjohnstmsft
Copy link
Member

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

@brjohnstmsft
Copy link
Member

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

@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants