Symptoms
- Every distributed Connect worker fails at startup. The log shows a
ConfigExceptionsimilar to:Topic 'connect-offsets' supplied via the 'offset.storage.topic' property is required to have 'cleanup.policy=compact' ... but found the topic currently has 'cleanup.policy=delete'. The same check applies to the config and status topics. - Or the workers start, but
GET /connectorsreturns[]. The connectors you had are gone. - Or source connectors start again from the beginning (full re-snapshot, duplicate records) or from "now" (missed records), because their stored offsets have gone.
Connect keeps all cluster state in three Kafka topics: config.storage.topic (connector configs), offset.storage.topic (source connector offsets) and status.storage.topic. They must be compacted. If one is switched to delete, retention eventually removes the records, and Connect rebuilds its state from whatever is left. Sink connectors are less exposed, because they store offsets in normal consumer groups (connect-<connector-name>).
Caution
Do not delete and re-create the internal topics to "reset" the cluster. That wipes every connector config and every source offset at once. Fix the topic in place and save what is still in it first.
1. Find the topic names and what changed
Read the worker config (connect-distributed.properties, Strimzi KafkaConnect spec or Confluent config) for the three names:
grep -E '^(group.id|config.storage.topic|offset.storage.topic|status.storage.topic)' \
/etc/kafka/connect-distributed.properties
Then check each topic's configuration and partition layout:
BS=broker1:9092
for t in connect-configs connect-offsets connect-status; do
echo "== $t"
kafka-configs.sh --bootstrap-server $BS --entity-type topics --entity-name $t --describe
kafka-topics.sh --bootstrap-server $BS --describe --topic $t | head -3
done
| What you see | Cause | Go to |
|---|---|---|
cleanup.policy=delete on a topic, workers refuse to start | Policy changed by hand, by IaC or by a topic-defaults tool | Step 2 |
| Topic missing, then re-created by Connect with no records | Topic deleted | Step 3 (configs) or step 4 (offsets) |
Low retention.ms together with delete, records already gone | Policy changed some time ago | Steps 2, 3 and 4 |
| Config topic has more than one partition | Wrong manual creation; Connect requires one partition | Re-create correctly in a new topic and point workers at it |
2. Restore compaction before anything else
Back up what is still in the topic, then set the policy back:
# Save the remaining records (keys and values) before retention removes more
kafka-console-consumer.sh --bootstrap-server $BS --topic connect-configs \
--from-beginning --timeout-ms 20000 \
--property print.key=true --property key.separator='|' > connect-configs.backup
kafka-console-consumer.sh --bootstrap-server $BS --topic connect-offsets \
--from-beginning --timeout-ms 20000 \
--property print.key=true --property key.separator='|' > connect-offsets.backup
# Put compaction back and remove any time-based retention override
kafka-configs.sh --bootstrap-server $BS --entity-type topics --entity-name connect-offsets \
--alter --add-config cleanup.policy=compact
kafka-configs.sh --bootstrap-server $BS --entity-type topics --entity-name connect-offsets \
--alter --delete-config retention.ms
Repeat for the config and status topics, then restart the workers one at a time. Setting compact again stops further loss but does not bring back records that retention has already deleted.
3. Re-create lost connector configs
If GET /connectors is empty or short, re-apply the configs. Use source control if you have it. If you don't, use the backup file: each connector-<name> record's value is JSON that holds the connector's properties.
CONNECT=http://connect-1:8083
# What the cluster knows now
curl -s "$CONNECT/connectors?expand=status" | jq 'map_values(.status.connector.state)'
# Re-create (PUT is idempotent: creates or updates)
for f in connectors/*.json; do
name=$(basename "$f" .json)
curl -s -X PUT -H 'Content-Type: application/json' \
--data @"$f" "$CONNECT/connectors/$name/config" | jq -r '.name'
done
Warning
Before you re-create a source connector, work out its offsets (step 4). If the offsets are gone, a CDC connector such as Debezium can take a full snapshot or fail with a missing-position error, depending on its
snapshot.mode. To control that, create it in theSTOPPEDstate first. Kafka 3.7+ accepts"initial_state": "STOPPED"in the create request body (POST /connectors).
Secrets that came from config providers (${file:...}, ${vault:...}) are stored as placeholders, so the restored configs resolve them as before. Inline passwords in the backup are in clear text. Handle the file as a secret and delete it when you are done.
4. Fix source connector offsets
Check what each source connector thinks its position is (Kafka 3.6+):
curl -s "$CONNECT/connectors/orders-cdc/offsets" | jq .
If the offsets are missing or wrong, you have three options:
| Option | When | How |
|---|---|---|
| Write offsets back | You have them in the backup, or you know the source position | Stop the connector, PATCH offsets, resume |
| Let it re-snapshot | The source is small and downstream handles duplicates (upserts, idempotent sinks) | Resume and watch the lag |
| Start from now and backfill | The source is large; a gap can be backfilled by a batch job | Change the connector's snapshot or start setting, then backfill the gap |
Writing offsets back needs the connector in the STOPPED state. The partition and offset keys are specific to the connector. Copy their shape from the backup or from GET .../offsets output on a healthy environment.
curl -s -X PUT "$CONNECT/connectors/orders-cdc/stop"
curl -s -X PATCH -H 'Content-Type: application/json' "$CONNECT/connectors/orders-cdc/offsets" \
--data '{"offsets":[{"partition":{"server":"orders"},
"offset":{"lsn":123456789,"txId":98765}}]}'
curl -s -X PUT "$CONNECT/connectors/orders-cdc/resume"
On Kafka versions earlier than 3.6, the REST endpoints don't exist. Instead, stop the connector and produce the saved key/value record from the backup back into the offsets topic with kafka-console-producer.sh --property parse.key=true --property key.separator='|'. Then restart it.
Sink connectors keep their position in consumer group connect-<name>. Check it with:
kafka-consumer-groups.sh --bootstrap-server $BS --describe --group connect-orders-sink
5. Verify
- All workers are running and
GET /connectors?expand=statusshows every connector and taskRUNNING. kafka-configs.sh --describeshowscleanup.policy=compacton all three internal topics.- Source connector offsets match the expected source position, and destination row counts match the source for the incident window.
Prevent it next time
- Keep every connector config in source control and deploy it with
PUT /connectors/<name>/configfrom CI. The config topic should never be your only copy. - Exclude the Connect internal topics from any tool that sets topic defaults or "fixes" retention across the cluster.
- Restrict
AlterConfigsandDeleteon the internal topics with ACLs. The Connect worker principal needsRead,Write,Describe,DescribeConfigsandCreate, notDelete. Test the ACLs in non-production first. - Set
config.storage.replication.factor,offset.storage.replication.factorandstatus.storage.replication.factorto 3 so Connect creates durable topics. - Back up
GET /connectors/<name>/offsetsfor source connectors on a schedule. Then a lost offsets topic becomes a quickPATCHinstead of a full re-snapshot. See the Kafka Connect REST API cheat sheet.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get