CqlSession get() {
    if (session != null) return session;
    synchronized (this) {
      if (session != null) return session; // lost race
      session = sessionFactory.create(storage);

      // If we got this far, the session is healthy. So, everything below only happens once.
      try {
        metadata = ensureSchema.apply(storage, session);
        session.execute("USE " + storage.keyspace);
        Schema.initializeUDTs(session, storage.keyspace);
        healthCheck = session.prepare("SELECT trace_id FROM " + TABLE_SPAN + " limit 1");
      } catch (RuntimeException | Error e) {
        propagateIfFatal(e);
        // An error here was from installing or validating the schema. To ensure we don't repeat
        // failed commands, close, but don't null the session. For example, repeating may look like
        // an upgrade due to the first failure, and distract from the original problem.
        session.close();
      }
    }
    if (session.isClosed()) {
      throw new ClosedComponentException("Session initialization failed. See server logs");
    }
    return session;
  }
Creates a session and ensures schema if configured.
zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/LazySession.java