SDKits / ExamineX

Issue tracker for ExamineX
https://examinex.online
5 stars 0 forks source link

Documents failing to be deleted from index #82

Closed stevetemple closed 1 year ago

stevetemple commented 1 year ago

I'm getting an issue on a site where it's trying to delete documents but failing. This has been giving us some errors as now the nucache and examine are out of date.

Spotted these exceptions in the logs

Umbraco version: 8.18.7 ExamineX version: 2.0.10

{"@t":"2023-05-09T14:29:17.1987678Z","@mt":"(PerformDeleteFromIndexInternal) Max retries hit, giving up on batch","@l":"Error","@x":"Azure.RequestFailedException: The request is invalid. Details: actions : No indexing actions found in the request. Please include between 1 and 32000 indexing actions in your request.\r\nStatus: 400 (Bad Request)\r\nErrorCode: MissingRequiredParameter\r\n\r\nContent:\r\n{\"error\":{\"code\":\"MissingRequiredParameter\",\"message\":\"The request is invalid. Details: actions : No indexing actions found in the request. Please include between 1 and 32000 indexing actions in your request.\",\"details\":[{\"code\":\"MissingIndexDocumentsActions\",\"message\":\"No indexing actions found in the request. Please include between 1 and 32000 indexing actions in your request. Parameters: actions\"}]}}\r\n\r\nHeaders:\r\nPragma: no-cache\r\nContent-Language: REDACTED\r\nclient-request-id: 00d2e124-4d52-46dc-ac0f-3658b1db4652\r\nx-ms-client-request-id: 00d2e124-4d52-46dc-ac0f-3658b1db4652\r\nrequest-id: 00d2e124-4d52-46dc-ac0f-3658b1db4652\r\nelapsed-time: 16\r\nPreference-Applied: REDACTED\r\nStrict-Transport-Security: REDACTED\r\nContent-Length: 406\r\nCache-Control: no-cache\r\nContent-Type: application/json; charset=utf-8\r\nDate: Tue, 09 May 2023 14:29:16 GMT\r\nExpires: -1\r\n\r\n   at Azure.Search.Documents.SearchClient.<IndexDocumentsInternal>d__461.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Azure.Search.Documents.SearchClient.IndexDocuments[T](IndexDocumentsBatch``1 batch, IndexDocumentsOptions options, CancellationToken cancellationToken)\r\n   at ExamineX.AzureSearch.AzureSearchIndex.A[A,a](IEnumerable1 , Func`2 , Func`3 , CancellationToken , String callerMember)","SourceContext":"ExamineX.AzureSearch.AzureSearchIndex","ProcessId":9560,"ProcessName":"w3wp","ThreadId":549,"AppDomainId":3,"AppDomainAppId":"xxx","MachineName":"xxx","Log4NetLevel":"ERROR"}
Shazwazza commented 1 year ago

Thanks for reporting @stevetemple. I'll look into that error to see if I can replicate. It looks to be trying to send a request to Azure Search with no actions, so potentially something is filtering out all intended actions before being sent.

When/how does this occur? Is it every time you delete a content item or something else?

Shazwazza commented 1 year ago

Turning on Debug level logging may also yield more information. You can also enable debug level logging in the Umbraco config for just the namespace "ExamineX.AzureSearch"

Shazwazza commented 1 year ago

Hi @stevetemple I was able to determine that in some cases when items are deleted, that an empty array of Ids may be passed in (this is based on code that needs to delete by path, taking into account the recycle bin, etc...). This was causing the error you saw, but there's also an exponential back off retry policy for Azure Search errors (in accordance with their docs). So this would be retried several times even though the request should have never been sent in the first place since it's empty.

I've just pushed version 2.0.12 to resolve this. Please let me know if that gets your further.

stevetemple commented 1 year ago

Thanks @Shazwazza

Super fast work! I'll see if I can reproduce the issue locally and then apply this and check it fixes it