{"record":{"id":"2df8fcaa049756f7","repo":"jaegertracing/jaeger","slug":"failed-to-check-index-existence-w","errorCode":null,"errorMessage":"failed to check index existence: %w","messagePattern":"failed to check index existence: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v1/elasticsearch/samplingstore/storage.go","lineNumber":171,"sourceCode":"\nfunc (s *SamplingStore) writeProbabilitiesAndQPS(indexName string, ts time.Time, pandqps dbmodel.ProbabilitiesAndQPS) error {\n\t// context.Background: see InsertThroughput.\n\treturn s.batchWriter.WriteBatch(context.Background(), []esclient.BulkItem{{\n\t\tIndex: indexName,\n\t\tBody: &dbmodel.TimeProbabilitiesAndQPS{\n\t\t\tTimestamp:           ts,\n\t\t\tProbabilitiesAndQPS: pandqps,\n\t\t},\n\t}})\n}\n\nfunc (s *SamplingStore) getLatestIndex(ctx context.Context) (string, error) {\n\tnow := s.now().UTC()\n\tcandidates := s.rotation.ReadTargets(now.Add(-s.lookback), now)\n\tfor _, idx := range candidates {\n\t\texists, err := s.indexClient.IndexExists(ctx, idx)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to check index existence: %w\", err)\n\t\t}\n\t\tif exists {\n\t\t\treturn idx, nil\n\t\t}\n\t}\n\treturn \"\", errors.New(\"failed to find latest index\")\n}\n\nfunc buildTSQuery(start, end time.Time) query.Query {\n\treturn query.NewRangeQuery(\"timestamp\").Gte(start).Lte(end)\n}\n","sourceCodeStart":153,"sourceCodeEnd":183,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v1/elasticsearch/samplingstore/storage.go#L153-L183","documentation":"getLatestIndex checks IndexExists for each rotation candidate within the lookback window; a failure of the existence check itself is wrapped as 'failed to check index existence'. Distinct from the sentinel 'failed to find latest index' which means the checks succeeded but no index exists.","triggerScenarios":"Calling GetLatestProbabilities when the ES IndicesExists API call errors — cluster unreachable, authentication rejected, malformed index name pattern, or client misconfiguration.","commonSituations":"ES credentials rotated or revoked; wrong URL scheme/port in storage config; DNS or firewall issues; ES client version incompatible with the cluster's API.","solutions":["Check the wrapped cause and test the same IndexExists call manually against the cluster.","Fix connectivity: addresses, TLS, credentials in the ES storage configuration.","Verify the index-name prefix/rotation produces valid index names for the cluster.","If the cause is 'failed to find latest index' instead, no fix to connectivity is needed — data simply hasn't been written."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"probs, err := store.GetLatestProbabilities()\nif err != nil {\n  if strings.Contains(err.Error(), \"failed to check index existence\") {\n    // ES client/connectivity problem — surface it\n  } else if strings.Contains(err.Error(), \"failed to find latest index\") {\n    // benign: no data yet — use defaults\n  }\n}","preventionTips":["Validate ES addresses/TLS/credentials at startup.","Ping the cluster (IndexExists or health) before relying on sampling reads.","Distinguish the two wrapped causes by unwrapping the error."],"tags":["elasticsearch","index","network"],"backgroundTag":"index-not-found","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}