Q&A-2Choose a Schema Registry compatibility mode.
Answer
Core answer. Assume Confluent Schema Registry, Avro/Protobuf/JSON Schema subjects, and that you can choose the deploy order. The mode is not a preference: it is the direction of schema change you must survive, and that direction is fixed by two facts: which side you can upgrade first, and how far back your readers replay. The registry default is BACKWARD. Pick it when consumers can ship before producers. Pick FORWARD when producers must ship first (external producers, or a team you cannot coordinate with). Pick FULL when you cannot guarantee either order. Add the _TRANSITIVE variant when readers can be pinned to versions older than the latest: long retention, batch jobs, offline clients.
| Mode | Registry accepts a new schema if | Deploy order it implies |
|---|---|---|
BACKWARD (default) | it can read data written by the previous version | consumers first |
BACKWARD_TRANSITIVE | it can read data written by every previous version | consumers first |
FORWARD | the previous version can read data written by it | producers first |
FORWARD_TRANSITIVE | every previous version can read data written by it | producers first |
FULL | both directions, against the previous version | either, but both sides must ship |
FULL_TRANSITIVE | both directions, against every previous version | either |
NONE | always | none enforced |
Non-transitive checks compare only against the latest registered version. That is the trap: a change can pass the check and still break a consumer that is two versions behind.
Worked trace (Avro). Start with Order{orderId: string, amountCents: long}.
- Add
currency: stringwithdefault: "USD". New reader reads old data (default fills in); old reader ignores the unknown field. PassesBACKWARDandFORWARD→FULL. - Remove
amountCents. New reader ignores it, soBACKWARDpasses. Old reader now expects a field the writer no longer emits and has no default →FORWARDfails. - Add
region: stringwith no default. New reader cannot read old data that lacksregion→BACKWARDfails.
So "add an optional field" is the only one of the three that is safe in both directions. Protobuf behaves similarly: a new field with a fresh tag number is compatible both ways; changing a field to a different wire type is not. JSON Schema: adding an optional property is backward compatible, adding a required one is not.
Failure modes.
BACKWARD(non-transitive) with a consumer pinned to v1 while the producer moves to v3. Registering v3 checks only against v2 and passes. The v1 consumer throws an Avro deserialization error on the first v3 record. Detection: consumer deserialization error rate and DLQ depth, both of which jump within one produce-to-consume cycle. Cost: the consumer stops advancing and lag grows until you roll the producer back or upgrade the consumer.FORWARDwith a producer that adds a required field. Old consumers fail immediately after the producer deploy. Same detection signal, but it appears in the same deploy window as the change, so attribution is easy.NONE. An incompatible schema registers cleanly and nothing fails until a consumer reads a record written with it. Detection is read-time only. Cost: the failure is decoupled from the change, so the deploy that caused it is no longer in the window when you are debugging.FULL_TRANSITIVEcost. It blocks removing a field nobody reads, because removal is not forward compatible. You keep the field forever or fork the subject.
The pre-deploy signal is the registry returning HTTP 409 with an incompatible-schema error on register; check before you register with POST /compatibility/subjects/<subject>/versions/latest. The post-deploy signal is consumer-side deserialization exceptions.
Scope and change control. Compatibility is per subject; the default subject is <topic>-value under TopicNameStrategy, so a key schema and a value schema are checked independently. Override the global level with PUT /config/<subject>. Setting a subject to NONE disables the check for every later registration on it, so treat it as a time-boxed change with a ticket and an expiry, not a default.
What would change the decision. A 30-day replay window or an offline consumer makes non-transitive unsafe: move to _TRANSITIVE. If you cannot coordinate deploys at all, FULL. If you own both ends and ship them atomically, NONE is defensible for the duration of that release.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.