{"record":{"id":"070f7d62d6c1b701","repo":"jaegertracing/jaeger","slug":"failed-to-delete-indices-w","errorCode":null,"errorMessage":"failed to delete indices: %w","messagePattern":"failed to delete indices: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/elasticsearch/esclient/index_client.go","lineNumber":132,"sourceCode":"\t// A zero master timeout is omitted so the cluster applies its own default\n\t// rather than master_timeout=0s, which asks the master to respond within no\n\t// time and can fail on a transient master delay.\n\tparams := fmt.Sprintf(\"ignore_unavailable=%t\", i.IgnoreUnavailableIndex)\n\tif i.MasterTimeoutSeconds > 0 {\n\t\tparams = fmt.Sprintf(\"master_timeout=%ds&%s\", i.MasterTimeoutSeconds, params)\n\t}\n\t_, err := i.request(ctx, elasticRequest{\n\t\tendpoint: concatIndices + \"?\" + params,\n\t\tmethod:   http.MethodDelete,\n\t})\n\tif err != nil {\n\t\tvar responseError ResponseError\n\t\tif errors.As(err, &responseError) {\n\t\t\tif responseError.StatusCode != http.StatusOK {\n\t\t\t\treturn responseError.prefixMessage(\"failed to delete indices: \" + concatIndices)\n\t\t\t}\n\t\t}\n\t\treturn fmt.Errorf(\"failed to delete indices: %w\", err)\n\t}\n\treturn nil\n}\n\n// DeleteIndices deletes specified set of indices.\nfunc (i *IndicesClient) DeleteIndices(ctx context.Context, indices []Index) error {\n\tconcatIndices := \"\"\n\tfor j, index := range indices {\n\t\t// verify the length of the concatIndices\n\t\t// An HTTP line is should not be larger than 4096 bytes\n\t\t// a line contains other than concatIndices data in the request, ie: master_timeout\n\t\t// for a safer side check the line length should not exceed 4000\n\t\tif (len(concatIndices) + len(index.Index)) > 4000 {\n\t\t\terr := i.indexDeleteRequest(ctx, concatIndices)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tconcatIndices = \"\"","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/elasticsearch/esclient/index_client.go#L114-L150","documentation":"This error is returned by IndicesClient.indexDeleteRequest (used by DeleteAllIndices and DeleteIndices) when the Elasticsearch DELETE request for one or more indices fails for a reason that is not a recognizable HTTP response error with a non-200 status. The underlying cause (network failure, transport error, serialization issue, or an unrecognized error type) is wrapped with %w so callers can errors.Is/As into it. If the server did return a structured ResponseError, a prefixMessage variant with the index list is returned instead.","triggerScenarios":"DELETE <indices>?[master_timeout=..&]ignore_unavailable=.. fails without a parseable ResponseError: connection refused/timeout to ES, TLS handshake failure, context cancellation mid-request, or a non-JSON error body that cannot be wrapped as ResponseError.","commonSituations":"Elasticsearch is down or unreachable when Jaeger tries to purge/delete indices; DNS or port misconfiguration in the ES server addresses; firewall or proxy dropping DELETE requests; tests wiping indices (DeleteAllIndices) against a stopped container.","solutions":["Verify Elasticsearch is reachable at the configured addresses (curl the cluster health endpoint) and fix the server address/TLS config","Retry the delete once the cluster is back — index deletion is idempotent when ignore_unavailable=true","Check context cancellation/deadline: increase the timeout on the context passed to DeleteIndices/DeleteAllIndices","Inspect the wrapped cause with errors.Unwrap/errors.As to identify the transport-level failure"],"exampleFix":"// before\nif err := indicesClient.DeleteAllIndices(ctx); err != nil {\n    return fmt.Errorf(\"purge failed: %w\", err) // opaque\n}\n// after\nvar respErr esclient.ResponseError\nif err := indicesClient.DeleteAllIndices(ctx); err != nil {\n    if errors.As(err, &respErr) {\n        log.Printf(\"ES rejected delete, status=%d\", respErr.StatusCode)\n    } else {\n        log.Printf(\"ES unreachable/transport failure: %v\", err)\n    }\n    return err\n}","handlingStrategy":"retry","validationCode":"// pre-flight: ES reachable?\nresp, err := http.Get(esURL + \"/_cluster/health\")\nif err != nil || resp.StatusCode != 200 {\n    return fmt.Errorf(\"ES not reachable, skipping delete\")\n}","typeGuard":"var respErr esclient.ResponseError\nisESRejection := errors.As(err, &respErr) // false => transport failure, retryable","tryCatchPattern":"if err := client.DeleteAllIndices(ctx); err != nil {\n    var respErr esclient.ResponseError\n    if errors.As(err, &respErr) {\n        return fmt.Errorf(\"ES rejected delete (status %d): %w\", respErr.StatusCode, err)\n    }\n    return retryWithBackoff(err) // transport failure\n}","preventionTips":["Health-check the ES cluster before running purge/delete jobs","Set ignore_unavailable=true so missing indices don't abort bulk deletes","Use a context with a sane timeout and treat DeadlineExceeded as retryable"],"tags":["elasticsearch","network","index-management"],"backgroundTag":"elasticsearch-request-failed","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}