Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A task was canceled - what does this mean?

I'm using the Azure Search .Net SDK.

I'm calling a synchronous (NOT ASYNC) function like this:

var searchResults = searchIndexClient.Documents.Search<T>(searchText, searchParameters);

It usually works. I'm not using any async functions, but somehow the error I just got looks like an async error:

System.Threading.Tasks.TaskCanceledException: A task was canceled.

CancellationToken: IsCanceleationRequested=false

Task: Id = 556, Status = Canceled, Method = "{null}", Result = "{Not yet computed}"

StackTrace:

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.Search.DocumentsOperations.<DoContinueSearchWithHttpMessagesAsync>d__153.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.Search.DocumentsOperationsExtensions.<SearchAsync>d__151.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.Azure.Search.DocumentsOperationsExtensions.Search[T](IDocumentsOperations operations, String searchText, SearchParameters searchParameters, SearchRequestOptions searchRequestOptions) at MyApp.AzureSearch.AzureSearchService.PerformSearch[T](String searchText, SearchParameters searchParameters) in c:\Projects\MyAppServer\src\MyApp.AzureSearch\AzureSearchService.cs:line 359 at MyApp.AzureSearch.AzureSearchService.Search[T](String searchText, List1 searchFields, SearchMode searchMode, List1 select, Nullable1 skip, Nullable1 top, String filter, Boolean includeTotalResultCount, List1 orderBy) in c:\Projects\MyAppServer\src\MyApp.AzureSearch\AzureSearchService.cs:line 262 at MyApp.AzureSearch.AzureSearchService.SearchEmails(Guid userId, String origin, String searchText, Nullable1 skip, Nullable1 top, Boolean includeTotalResultCount, Boolean includeHtmlBody, Boolean orderByProcessedAscending, String interactionStatus) in c:\Projects\MyAppServer\src\MyApp.AzureSearch\AzureSearchService.cs:line 167 at MyApp.Domain.MyAppMessages.Command.MyAppMessagesAllNoticedUpdater.Handle(VisitorSession userSession, NoticeAllMyAppMessages processCommand) in c:\Projects\MyAppServer\src\MyApp.Domain\MyAppMessages\Command\MyAppMessagesAllNoticedUpdater.cs:line 30

like image 749
richard Avatar asked Nov 07 '16 07:11

richard


People also ask

Which object do you inspect to determine if a long running task will be Cancelled?

For canceling, we use CancellationTokenSource object.

How do you abort a task?

You can "abort" a task by running it on a thread you control and aborting that thread. This causes the task to complete in a faulted state with a ThreadAbortException . You can control thread creation with a custom task scheduler, as described in this answer.

How do I cancel a task on Ifall?

To cancel, call tcs. SetResult(Nothing). This will fire your Task.


Video Answer


1 Answers

Most likely, the client timeout expired before the search has completed. Are you seeing this error when you submit a particularly complex query? If needed, you can look at the search performance in your service using search traffic analytics.

The reason you're seeing an "asynchronous" exception is that the synchronous version of the API is just a wrapper over asynchronous primitives.

like image 168
Eugene Shvets Avatar answered Oct 11 '22 17:10

Eugene Shvets