{"record":{"id":"594ebdea05402161","repo":"jaegertracing/jaeger","slug":"failed-to-exec-query-s-w","errorCode":null,"errorMessage":"failed to Exec query '%s': %w","messagePattern":"failed to Exec query '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/cassandra/metrics/table.go","lineNumber":40,"sourceCode":"\n// NewTable takes a metrics scope and creates a table metrics struct\nfunc NewTable(factory metrics.Factory, tableName string) *Table {\n\tt := spanstoremetrics.WriteMetrics{}\n\tmetrics.Init(&t, factory.Namespace(metrics.NSOptions{Name: \"\", Tags: map[string]string{\"table\": tableName}}), nil)\n\treturn &Table{t}\n}\n\n// Exec executes an update query and reports metrics/logs about it.\nfunc (t *Table) Exec(query cassandra.UpdateQuery, logger *zap.Logger) error {\n\tstart := time.Now()\n\terr := query.Exec()\n\tt.Emit(err, time.Since(start))\n\tif err != nil {\n\t\tqueryString := query.String()\n\t\tif logger != nil {\n\t\t\tlogger.Error(\"Failed to exec query\", zap.String(\"query\", queryString), zap.Error(err))\n\t\t}\n\t\treturn fmt.Errorf(\"failed to Exec query '%s': %w\", queryString, err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":22,"sourceCodeEnd":44,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/cassandra/metrics/table.go#L22-L44","documentation":"Table.Exec wraps a failed Cassandra CQL write (query.Exec()) with the query text and the underlying driver error. It exists so callers get metrics emitted plus a single error that names exactly which statement failed. The %w wrapping preserves the original driver error for errors.Is/As inspection.","triggerScenarios":"Any Insert/Update/Upsert statement executed through metrics.Table.Exec fails at the Cassandra driver level: connection loss, cluster down, timeout, query syntax error, schema/table missing, or write consistency issues.","commonSituations":"Cassandra node restart or network partition during a span/dependency write; keyspace or table dropped; invalid CQL after a schema migration; Cassandra unreachable at startup; tombstone/timeout errors under heavy write load.","solutions":["Read the wrapped driver error after 'failed to Exec query ...' to get the root cause (use %v of the full chain or errors.Unwrap).","Verify Cassandra connectivity and that the target keyspace/table exist (run jaeger's init/schema job).","Check the logged 'Failed to exec query' zap entry for the exact CQL statement and fix the statement or data.","Inspect Cassandra server logs / nodetool status for cluster health if errors are transient.","Upgrade driver/retry policies if timeouts occur under load; add retries with backoff around Exec."],"exampleFix":"// before\nerr := table.Exec(query, logger)\nif err != nil {\n    return err // opaque\n}\n// after\nerr := table.Exec(query, logger)\nif err != nil {\n    var cerr *gocql.Error\n    if errors.As(err, &cerr) {\n        logger.Warn(\"cassandra write failed\", zap.Int32(\"code\", cerr.Code), zap.Error(cerr))\n    }\n    return fmt.Errorf(\"writing spans: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// precondition: verify Cassandra is reachable before writes\nif err := session.Ping(); err != nil {\n    return fmt.Errorf(\"cassandra unavailable before write: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := table.Exec(query, logger); err != nil {\n    var driverErr error\n    if unwrapped := errors.Unwrap(err); unwrapped != nil {\n        driverErr = unwrapped\n    }\n    log.Printf(\"cassandra write failed: %v (driver: %v)\", err, driverErr)\n    // retry transient errors only\n    return retryTransient(driverErr)\n}","preventionTips":["Run Jaeger's Cassandra schema init before starting writers.","Monitor cluster health and add driver retry policies for transient failures.","Log the query string (the error includes it) to catch schema drift early.","Use readiness probes that check Cassandra connectivity before accepting traffic."],"tags":["cassandra","storage","write-failure","error-wrapping"],"backgroundTag":"cassandra-query-failed","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}