In a distributed microservice ecosystem, independent teams deploy new features at different times. If the Orders team publishes a new event version before the Billing team upgrades its consumer service, or vice-versa, will the pipeline break?
The Confluent Schema Registry prevents catastrophic production outages by enforcing Schema Compatibility Modes. These mathematical evolution rules guarantee that producers and consumers can be upgraded in any order without downtime.
1. The Core Compatibility Modes
A. BACKWARD Compatibility (Default)
- Definition: A new version of a schema is BACKWARD compatible if data serialized with the old schema (version ) can be successfully deserialized by a consumer running the new schema (version ).
- Safe Modifications:
- Deleting an existing field. (The new consumer simply ignores that field in old data).
- Adding an optional field with a
defaultvalue. (When reading old data where the field is missing, the new consumer populates the default value).
- Breaking Modifications:
- Adding a new field without a default value. (The new consumer fails when trying to read old data because the required field is absent).
- Deployment Order: Upgrade CONSUMERS first! Once all consumers can read both new and old schemas, upgrade the producers.
B. FORWARD Compatibility
- Definition: A new version of a schema is FORWARD compatible if data serialized with the new schema () can be successfully deserialized by an existing consumer running the old schema ().
- Safe Modifications:
- Adding a new field. (The old consumer simply drops/ignores the unknown field).
- Deleting a field that had a
defaultvalue.
- Breaking Modifications:
- Deleting a required field that has no default. (The old consumer expects the field, but new producers no longer send it).
- Deployment Order: Upgrade PRODUCERS first! Once all producers emit new data, upgrade the consumers.
C. FULL Compatibility (Bidirectional)
- Definition: A schema change is FULL compatible if it is simultaneously both BACKWARD and FORWARD compatible.
- Safe Modifications:
- Adding optional fields WITH default values.
- Deleting optional fields WITH default values.
- Advantage: Zero deployment coordination required. Teams can upgrade producers and consumers in any order, run canary releases, or roll back services with zero risk of deserialization errors.
2. Transitive Compatibility Modes
By default, standard modes (BACKWARD, FORWARD, FULL) only validate the proposed schema () against the immediately preceding schema version ().
However, in Kafka, log segments on disk may contain historical events written 6 months ago using version .
The Transitive Modes:
BACKWARD_TRANSITIVE: Validates that the new schema can read data written by all previous schema versions ().FORWARD_TRANSITIVE: Validates that all historical consumer schemas can read data written by the new schema.FULL_TRANSITIVE(Gold Standard): Enforces strict bidirectional compatibility across all past and future schema versions.
3. Schema Evolution Rule Matrix
| Schema Change Operation | BACKWARD | FORWARD | FULL |
|---|---|---|---|
Add optional field with default value ("default": "USD") | ✅ Allowed | ✅ Allowed | ✅ Allowed |
| Add required field without default | ❌ Rejected | ✅ Allowed | ❌ Rejected |
| Delete optional field with default value | ✅ Allowed | ✅ Allowed | ✅ Allowed |
| Delete required field without default | ✅ Allowed | ❌ Rejected | ❌ Rejected |
| Rename existing field | ❌ Rejected | ❌ Rejected | ❌ Rejected |
Change field type (e.g. int string) | ❌ Rejected | ❌ Rejected | ❌ Rejected |
[!CAUTION] Renaming a field is always treated as a Delete + Add operation. In Avro, you can safely rename fields without breaking compatibility by using the
"aliases"attribute:{"name": "user_id", "type": "string", "aliases": ["userId", "customer_id"]}
4. Automated CI/CD Schema Validation Pipeline
Never rely on manual developer discipline to enforce schema rules. Incorporate automated Schema Registry compatibility verification directly into your Git pull request checks:
5. Summary & Deployment Rules of Thumb
- Adopt
FULL_TRANSITIVEfor Core Enterprise Topics: This allows decoupled microservice teams to release independently without coordinating deployment calendars. - Always Provide Default Values: Whenever adding new fields to an Avro or Protobuf schema, always supply a sensible default value or declare the field nullable (
["null", "string"]). - Use Avro Aliases for Renaming: Never delete a field and create a new one when renaming; use
aliasesto preserve backward and forward readability.