Upgrading Azure Search SDK from v.5.0.3 to v.9. Search call hangs

拥有回忆 提交于 2019-12-19 10:17:47

问题


After upgrading the .net Azure Search SDK to version 9, I am unable to search. The call just hangs on:

    azureSearchIndexClient.Documents.Search(query, parameters);

I don't receive an error, everything was working on 5.0.3, I can still create, populate, and delete indexes in version 9. Without any response, I have little to go on...


回答1:


This is a bug in version 9.0.0 of the SDK, tracked here: https://github.com/Azure/azure-sdk-for-net/issues/6254 It has since been fixed in version 9.0.1, now available for download on NuGet. Version 8.0.0-preview is still affected by this bug as of the time of this writing.

The cause is a missing call to ConfigureAwait(false), which results in deadlock when calling the SDK in the context of an ASP.NET classic app.

The bug only affects the code path used for sending POST requests. That’s why setting UseHttpGetForQueries to true is an effective workaround. However, this should only be used as a temporary solution until the fix is available, especially if your application sends very large queries that might not fit on the URL query string.

Also note that the deadlock only occurs when blocking on a Task returned from an async method. The synchronous methods of the SDK do this internally. It is recommended practice in ASP.NET to make your controller methods async, as well as all methods that they call that can potentially do I/O, including the methods of the Azure Search SDK. This prevents OS threads from blocking, which greatly increases the scalability of your app. It also avoids issues with potential deadlock due to missing calls to ConfigureAwait(false).




回答2:


Setting the SearchIndexClient.UseHttpGetForQueries = true, gave me an error back to work from, without that the call just hung.



来源:https://stackoverflow.com/questions/56119762/upgrading-azure-search-sdk-from-v-5-0-3-to-v-9-search-call-hangs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!