{"record":{"id":"3071da1a1da7a6a7","repo":"openzipkin/zipkin","slug":"session-initialization-failed-see-server-logs","errorCode":null,"errorMessage":"Session initialization failed. See server logs","messagePattern":"Session initialization failed\\. See server logs","errorType":"exception","errorClass":"ClosedComponentException","httpStatus":null,"severity":"critical","filePath":"zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/LazySession.java","lineNumber":54,"sourceCode":"      if (session != null) return session; // lost race\n      session = sessionFactory.create(storage);\n\n      // If we got this far, the session is healthy. So, everything below only happens once.\n      try {\n        metadata = ensureSchema.apply(storage, session);\n        session.execute(\"USE \" + storage.keyspace);\n        Schema.initializeUDTs(session, storage.keyspace);\n        healthCheck = session.prepare(\"SELECT trace_id FROM \" + TABLE_SPAN + \" limit 1\");\n      } catch (RuntimeException | Error e) {\n        propagateIfFatal(e);\n        // An error here was from installing or validating the schema. To ensure we don't repeat\n        // failed commands, close, but don't null the session. For example, repeating may look like\n        // an upgrade due to the first failure, and distract from the original problem.\n        session.close();\n      }\n    }\n    if (session.isClosed()) {\n      throw new ClosedComponentException(\"Session initialization failed. See server logs\");\n    }\n    return session;\n  }\n\n  Schema.Metadata metadata() {\n    get();\n    return metadata;\n  }\n\n  void healthCheck() {\n    get();\n    session.execute(healthCheck.bind());\n  }\n\n  void close() {\n    CqlSession maybeSession = session;\n    if (maybeSession != null) {\n      session.close();","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/LazySession.java#L36-L72","documentation":"LazySession.get() throws ClosedComponentException('Session initialization failed. See server logs') when the Cassandra session ends up closed after the initialization block (USE keyspace, UDT registration, health-check preparation, or schema ensure/validate) failed. The code deliberately closes the session on failure and does not retry, so any later get() sees session.isClosed() and throws this.","triggerScenarios":"Schema install/validation throwing during LazySession init (bad contact points, auth failure, missing schema with ensureSchema=false, unreachable keyspace); any subsequent storage call (span store, health check) then hits this exception.","commonSituations":"Server starts before Cassandra is reachable; CASSANDRA_ENSURE_SCHEMA=false against a fresh cluster with no schema; wrong credentials or keyspace; the original root cause is only in the logs because the exception itself is swallowed after session.close().","solutions":["Check the server logs for the ORIGINAL error thrown during initialization — this exception only tells you init failed earlier.","Verify Cassandra contact points, port, credentials, and network connectivity, then restart the process so LazySession can initialize cleanly.","If the schema is missing, either apply the schema cql files manually or set CASSANDRA_ENSURE_SCHEMA=true."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Probe connectivity before building storage\ntry (CqlSession probe = CqlSession.builder().addContactPoint(contactPoint).build()) {\n  probe.execute(\"SELECT release_version FROM system.local\");\n} catch (AllNodesFailedException e) { throw new IllegalStateException(\"Cassandra unreachable\", e); }","typeGuard":null,"tryCatchPattern":"catch (ClosedComponentException e) { log.error(\"Cassandra session init failed; inspect earlier startup logs for the root cause\", e); scheduleRestartWithBackoff(); }","preventionTips":["Order startup so Cassandra is healthy before Zipkin starts (health-check dependency in compose/k8s).","Always read the first ERROR log line during init — this exception is only a symptom."],"tags":["cassandra","zipkin","session","startup","schema","connection"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}