{"record":{"id":"72ce5868ad3e2b49","repo":"openzipkin/zipkin","slug":"failed-to-execute-s-s","errorCode":null,"errorMessage":"Failed to execute [%s]: %s","messagePattern":"Failed to execute \\[(.+?)\\]: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/Schema.java","lineNumber":201,"sourceCode":"\n  static boolean hasUpgrade2_remoteService(KeyspaceMetadata keyspaceMetadata) {\n    return keyspaceMetadata.getTable(TABLE_SERVICE_REMOTE_SERVICES).isPresent();\n  }\n\n  static void applyCqlFile(Version version, String keyspace, CqlSession session, String resource) {\n    for (String cmd : resourceToString(resource).split(\";\", 100)) {\n      cmd = cmd.trim().replace(\" \" + DEFAULT_KEYSPACE, \" \" + keyspace);\n      if (cmd.isEmpty()) continue;\n      cmd = reviseCQL(version, cmd);\n      try {\n        session.execute(cmd);\n      } catch (InvalidQueryException e) {\n        // Add context so it is obvious which line was wrong\n        String message = \"Failed to execute [%s]: %s\".formatted(cmd, e.getMessage());\n        // Ensure we can look at logs to see the problem. Otherwise, it may only\n        // be visible in API error responses, such as /health or /api/v2/traces.\n        LOG.error(message);\n        throw new RuntimeException(message, e);\n      }\n    }\n  }\n\n  static String reviseCQL(Version version, String cql) {\n    if (version.getMajor() >= 4) {\n      // read_repair_chance options were removed and make Cassandra crash starting in v4\n      // See https://cassandra.apache.org/doc/latest/operating/read_repair.html#background-read-repair\n      cql = cql.replaceAll(\" *AND [^\\\\s]*read_repair_chance = 0\\n\", \"\");\n    }\n    return cql;\n  }\n\n  Schema() {\n  }\n}\n","sourceCodeStart":183,"sourceCodeEnd":218,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/Schema.java#L183-L218","documentation":"Thrown while applying a schema cql file when session.execute(cmd) raises InvalidQueryException. The error wraps the exact CQL statement and the server's message so it is obvious which line of the resource failed. It is logged at ERROR before rethrowing so it appears in server logs, not only in API responses.","triggerScenarios":"Running Schema.ensure/applyCqlFile with ensureSchema=true against a Cassandra version whose syntax differs (e.g. read_repair_chance on Cassandra 4 handled by reviseCQL, other drift on other versions), insufficient permissions to create tables, or a keyspace name substitution mismatch.","commonSituations":"Schema install against a newer/older Cassandra than supported; a restricted Cassandra user without CREATE privileges; partially-applied schema from a previous failed attempt.","solutions":["Read the wrapped CQL statement and server message in the error to identify the failing line.","Verify the Cassandra user has CREATE TABLE / INDEX / TYPE privileges on the keyspace.","Confirm the Cassandra version is supported (>= 3.11.3) and matches the schema expectations; if a partial schema exists, drop the keyspace and retry a clean install."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (RuntimeException e) { log.error(\"Schema apply failed at statement: {}\", e.getMessage(), e); if (e.getCause() instanceof InvalidQueryException iqe && iqe.getMessage().contains(\"Permission\")) escalateToDba(); }","preventionTips":["Pre-verify the Cassandra user can CREATE in the target keyspace before enabling ensureSchema.","Match the schema cql version to your Cassandra major version."],"tags":["cassandra","zipkin","schema","cql","permissions"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}