Monedula

Scenario 25.1.10 · A producer deploy is rejected as incompatible

Kafka producer schema rejected as incompatible (409)

Schema registry · Intermediate · about 3 min · Apache Kafka 4.4 · Confluent Platform feature

Under backward mode a producer deploys a field without a default: the registry refuses v2, the send fails and nothing reaches Kafka. Adding the default fixes it.

Run this scenario in the playground

v2 rejected · 409. t+1.600s

On the send of O2 the serializer registers v2 and the registry leader checks it against v1 under BACKWARD: incompatible. It answers HTTP 409 and the send throws a SerializationException. O2 never reaches Kafka, the subject stays at v1, and the consumer is unaffected: it read O1 and waits for more.

Open at this step: step 4, v2 rejected · 409

What you start with

A Confluent serializer registers its schema on the first send (auto.register.schemas=true). The registry leader checks the new version against the subject's compatibility mode before it stores it. Here the subject is under BACKWARD, the default, and the producer's new version adds a field without a default.

Step by step

  1. v1 · backward mode t+0.000s orders-value holds v1 (schema id 1) under BACKWARD, the default. The producer and the consumer both have id 1 cached; three Schema Registry instances, sr-1 leads. Open at this step: step 1, v1 · backward mode
  2. O1 written with v1 t+0.900s O1 goes out with schema id 1 and the consumer reads it. Nothing has changed yet. Open at this step: step 2, O1 written with v1
  3. v2 deployed: a field without a default t+1.100s The team deploys the producer with v2, which adds a field without a default. Old readers can still read v2 records (forward), but a reader on v2 cannot read v1 records, since the new field has no value to fall back to (not backward). The producer restarts with a cold schema cache. Open at this step: step 3, v2 deployed: a field without a default
  4. v2 rejected · 409 t+1.600s On the send of O2 the serializer registers v2 and the registry leader checks it against v1 under BACKWARD: incompatible. It answers HTTP 409 and the send throws a SerializationException. O2 never reaches Kafka, the subject stays at v1, and the consumer is unaffected: it read O1 and waits for more. Open at this step: step 4, v2 rejected · 409
  5. v2 redeployed with a default t+2.100s The fix goes into the schema, not the registry: the new field gets a default. Records without it now read fine with v2, so the change is compatible both ways. Open at this step: step 5, v2 redeployed with a default
  6. v2 registered · O3 consumed t+2.800s The serializer registers the corrected schema as v2 with schema id 2; the rejected attempt never existed in the registry, so the version number is unchanged. O3 reaches Kafka and the consumer looks id 2 up and reads it. Open at this step: step 6, v2 registered · O3 consumed

The takeaway

Under BACKWARD a new field needs a default, or consumers upgraded to the new schema could not read the records already on the topic. The registry refuses such a version with HTTP 409 and the producer's send fails before anything reaches Kafka; consumers never see a bad record. The fix is in the schema, not the registry: give the field a default and redeploy.

Embed this scenario

Paste this into a blog post, a course page or your team's docs. The scenario plays inside your page, and the link under it points readers to this walkthrough.

<iframe src="https://monedula.dev/kafka-simulator/embed/?scenario=25.1.10" title="Kafka Simulator: A producer deploy is rejected as incompatible" width="100%" height="520" style="border:1px solid #d0d0d0;border-radius:8px" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
<p><a href="https://monedula.dev/kafka-simulator/scenarios/producer-schema-incompatible/">Kafka producer schema rejected as incompatible (409)</a></p>

Further reading

Confluent documentation

Troubleshooting

More in Schema registry

All scenarios