SQLStreams

the messaging platform that is just Postgres

You last visited on 9999-99-99 Show what's new since then
[SOLVED]

compaction head not found [SQL0066]

Edit this page
code SQL0066 · recovery permanent — an unchanged retry cannot succeed; retry machinery stops immediately
the log line · Report this thread
SQL0066 Permanent error

As it arrives in your log or error chain — example values stand where yours will:

compaction head not found: schema "sqlstreams", stream "orders.created", stream_id 1, message_key "order-214" -- produce under message key "order-214" on stream "orders.created" with CompactionOptions.Enable set [SQL0066]

The key has no materialized compaction head. LockCompactionHead may have created a compaction_head row whose head fields are NULL; ordinary reads deliberately treat that lock-only row like no row. A head exists only once a message produced under the key opts into compaction, so a key that has never been produced under and a key whose messages all left MessageOptions.Compaction unset look the same here.

The second diagnose query tells them apart: rows with a NULL compaction_rank were produced under the key without compaction. Client.Stream(name).Key(key).Messages reads the same rows from Go, and returns them whether or not a head exists.

ACCEPTED ANSWER Posted: 2026-09-09
brandon Site Admin brandon profile Posts: 677

produce under message key "{message_key}" on stream "{stream}" with CompactionOptions.Enable set

brandon Site Admin brandon profile Posts: 677

Helpful info.

  1. the key's compaction_head row, if one exists

    SELECT
    	compaction_key,
    	message_id,
    	schema_version,
    	compaction_rank
    FROM {schema}.compaction_head_{stream_id}
    WHERE compaction_key = '{message_key}';
  2. the messages produced under the key -- a NULL compaction_rank never opted into compaction

    SELECT
    	id,
    	schema_version,
    	compaction_rank,
    	created_at
    FROM {schema}.message_log_{stream_id}
    WHERE message_key = '{message_key}'
    ORDER BY id DESC
    LIMIT 20;
Nothing pasted yet — the queries above show their blanks.

Looking for a different code? Search every thread.