apache/cassandra · warning · Exception

no tracestate

Error message

no tracestate

What it means

TraceStateJob.runMayThrow throws a plain Exception when Tracing.instance.get(sessionId) returns null, meaning the local TraceState for the session UUID has been dropped (tracing TTL expired) or never existed on this node. The job polls the trace events table for a session whose local state is already gone.

Solutions

  1. Fetch trace events within the tracing TTL window (before state expiry)
  2. Increase tracing_ttl_seconds in cassandra.yaml if traces are read late
  3. Verify the session UUID is correct and was created on this node
  4. Re-run the operation with TRACING ON to generate a fresh session
Defensive patterns

Strategy: try-catch

Validate before calling

TraceState state = Tracing.instance.get(sessionId);
if (state == null) { /* session expired; skip polling */ return; }

Try / catch

try { pollTraces(sessionId); }
catch (Exception e) {
    if ("no tracestate".equals(e.getMessage()))
        logger.warn("Trace session {} expired before events could be read", sessionId);
    else throw e;
}

Prevention

When it happens

Trigger: The trace-watcher thread wakes for sessionId but the TraceState was evicted after query completion before events were fetched; or a session UUID is watched that was never created locally.

Common situations: Inspecting traces of long queries after the tracing TTL elapsed; heavy tracing load evicting states quickly; fetching traces for sessions started on other nodes.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/8e0fba6ae7738ffc. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/repair/RepairCoordinator.java:561

            }
        }

        List<Range<Token>> ranges = new ArrayList<>();
        ranges.add(range);
        neighborRangeList.add(new CommonRange(endpoints, transEndpoints, ranges));
    }

    private Thread createQueryThread(final TimeUUID sessionId)
    {
        return ctx.executorFactory().startThread("Repair-Runnable-" + THREAD_COUNTER.incrementAndGet(), new WrappedRunnable()
        {
            // Query events within a time interval that overlaps the last by one second. Ignore duplicates. Ignore local traces.
            // Wake up upon local trace activity. Query when notified of trace activity with a timeout that doubles every two timeouts.
            public void runMayThrow() throws Exception
            {
                TraceState state = Tracing.instance.get(sessionId);
                if (state == null)
                    throw new Exception("no tracestate");

                String format = "select event_id, source, source_port, activity from %s.%s where session_id = ? and event_id > ? and event_id < ?;";
                String query = String.format(format, SchemaConstants.TRACE_KEYSPACE_NAME, TraceKeyspace.EVENTS);
                SelectStatement statement = (SelectStatement) QueryProcessor.parseStatement(query).prepare(ClientState.forInternalCalls());

                ByteBuffer sessionIdBytes = sessionId.toBytes();
                InetAddressAndPort source = ctx.broadcastAddressAndPort();

                HashSet<UUID>[] seen = new HashSet[]{ new HashSet<>(), new HashSet<>() };
                int si = 0;
                UUID uuid;

                long tlast = ctx.clock().currentTimeMillis(), tcur;

                TraceState.Status status;
                long minWaitMillis = 125;
                long maxWaitMillis = 1000 * 1024L;
                long timeout = minWaitMillis;

View on GitHub (pinned to 88fd0f6a0e)