BACKWARD vs FORWARD compatibility when adding a required Avro field without default under zero-downtime deployment
0 reputation · 25 May 2023, 09:56 UTC
0 reputation · 25 May 2023, 09:56 UTC
A team must add a required field to an Avro schema used by Kafka producers and consumers. The deployment must be zero-downtime: producers and consumers cannot be upgraded in a coordinated cutover. Confluent Schema Registry enforces compatibility at registration time, and the default TRANSITIVE validates against all prior versions.
The new field cannot have a default value because business logic requires explicit producer input. BACKWARD compatibility (consumers upgraded first) fails because old records lack the field, causing deserialization errors in new consumers. FORWARD compatibility (producers upgraded first) fails because old producers cannot serialize records that satisfy the new required field. FULL (BACKWARD+FORWARD) rejects the change outright.
The two-step pattern — first add the field as optional with a default (compatible both ways), deploy all consumers, then make the field required in a second schema change (BACKWARD only) — is widely documented but doubles registry entries and relies on operational discipline to complete the second step.
FULL compatibility, does the subsequent required-field registration pass TRANSITIVE validation against the original schema, or must compatibility be relaxed temporarily?A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.