Quick revision
The short answer
Under BACKWARD compatibility, a new schema must be able to read data written with the previous one. Removing a field is allowed, and adding a field is allowed only with a default, but a plain rename is incompatible, because the new reader cannot find the old name in old data. We handle the rename with an alias in the reader schema, or by adding the new field, populating both for a while and removing the old one later. Under BACKWARD we upgrade the five consumers before the producers, and we let the registry's compatibility check in CI stop incompatible schemas before they are deployed.
What to remember
In this answer, we saw that BACKWARD means the new schema can read data written with the previous one. Removing a field passes, adding one needs a default, and a plain rename fails because old data has no field with the new name. An alias in the reader schema, or a period with both fields followed by removal of the old one, makes the rename safe. Under BACKWARD we upgrade consumers before producers, FORWARD reverses the order and FULL allows either, and a compatibility check in CI stops incompatible schemas before deployment.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Under BACKWARD compatibility, a new schema must be able to read data written with the previous one. Removing a field is allowed, and adding a field is allowed only with a default, but a plain rename is incompatible, because the new reader cannot find the old name in old data. We handle the rename with an alias in the reader schema, or by adding the new field, populating both for a while and removing the old one later. Under BACKWARD we upgrade the five consumers before the producers, and we let the registry's compatibility check in CI stop incompatible schemas before they are deployed.
Why this question is asked
Schema changes are where a shared Kafka topic shows whether it was designed as a contract. One team's harmless-looking rename can stop five other services from reading the topic. Interviewers ask this scenario because it combines Avro's resolution rules, the registry's compatibility modes and a rollout plan across teams. In this answer, we will recap what BACKWARD means, check the field removal, see why a rename fails and how aliases or a two-step change fix it, decide the deployment order, and put the check into CI.
1A Quick Recap of BACKWARD Compatibility
A schema registry checks every new version of a subject against its compatibility mode. BACKWARD, the default in Confluent Schema Registry, means consumers using the new schema can read data written with the previous schema. In Avro terms, the new schema works as a reader schema for old writer data.
Avro resolves a writer schema against a reader schema field by field, by name. A field that the writer has and the reader lacks is skipped. A field that the reader has and the writer lacks is filled from the reader's default value, and if the reader field has no default, resolution fails. Those two rules decide everything in this question.
Note that BACKWARD compares only with the latest registered version. BACKWARD_TRANSITIVE compares with all previous versions, which matters when consumers may read very old data, for example on a replay from the start of a compacted topic.
| Change | Allowed? | Why |
|---|---|---|
| Remove a field | Yes | New reader simply skips it in old data |
| Add a field with a default | Yes | New reader uses the default for old data |
| Add a field without a default | No | New reader has no value for old data |
| Rename a field | No | New name missing in old data, no default |
| Rename with an alias for the old name | Yes | Reader matches the old name through the alias |
2Checking the Field Removal
Suppose version 1 of the Customer schema has the fields id, name, legacyCode and tier, and the team wants to remove legacyCode. The new schema as a reader of old data simply skips legacyCode, so the registry accepts it under BACKWARD.
Accepted does not mean free. Consumers that have not yet upgraded still use version 1 as their reader schema. If a producer starts writing version 2 data without legacyCode, an old consumer looks for legacyCode, does not find it, and needs a default; if version 1 declared legacyCode without a default, those consumers fail. This is exactly why BACKWARD comes with a rule about deployment order, which we will reach shortly. Before removing, it also pays to search the five consumers' code for any use of legacyCode.
3Why a Plain Rename Breaks and How to Fix It
Now the team wants to rename name to fullName. In the new schema there is a field fullName with no default. A consumer using it reads old data, written with name, and finds no fullName and no default, so resolution fails. The registry rejects the schema under BACKWARD. Giving fullName a default would get past the check, but every old record would then read as the default value instead of the real name, which is silent data loss.
The first fix is an alias. Avro lets a reader field declare aliases, other names it should match in the writer schema. With aliases set to name, the new reader finds the old field and copies its value into fullName. Avro's compatibility checker understands field aliases, so the registry accepts the change; it is still worth confirming with a test registration against your registry version.
Notice the last line: aliases work for the new reader, not the old one. So once producers write fullName, every consumer must already be on version 2. The second fix avoids that hard switch. We add fullName as a new field with a default, and producers fill both name and fullName for a period. Consumers move to reading fullName at their own pace. When all five have moved, we remove name in a later version, which is again a removal, allowed under BACKWARD. This takes longer but never breaks a consumer that is a release behind.
4Deployment Order: Consumers First
Under BACKWARD, the new schema is guaranteed to read old data, but nothing guarantees that old schemas can read new data. So the safe order is to upgrade consumers first. Each of the five consumer services deploys with the version 2 reader schema while producers are still writing version 1 data, which the new schema can read. Only when all consumers are upgraded do producers start writing version 2.
FORWARD compatibility is the mirror image: old schemas can read data written with the new one, so producers upgrade first. FULL means both directions hold, so either side can go first in any order, which is the most comfortable for shared topics but allows the fewest changes: in Avro, essentially only adding or removing fields that have defaults.
- Write version 2: drop legacyCode, add aliasor add
fullNamealongside name - CI checks compatibility against the registryfails the build if incompatible
- Deploy the five consumers with version 2they still read version 1 data
- All consumers on version 2?YesDeploy producers writing version 2NoWait; producers stay on version 1
- Monitor deserialization errors and DLTper consumer
- Later: remove the old name fieldonly after the two-field period
6 steps in order. Play them, or step through them one at a time.
5Putting the Check Into CI
Coordination across five teams fails when it depends on people remembering. So the schema lives in a shared repository or the producer's repository, and every change runs the registry's compatibility check in CI before merging. The Confluent Maven plugin offers a test-compatibility goal for this, and the registry's REST API can be called directly from any build.
With auto-registration turned off in production and schemas registered from CI, an incompatible schema can never reach a running producer. The pull request that changes the schema is also the natural place to tag the five consumer teams for review.
6Follow-up questions
Why not just make the topic's compatibility NONE for the change?
Because NONE switches off the safety for everyone. Consumers that have not upgraded would break, and replays of older data might fail. If a change truly cannot be made compatibly, the cleaner path is a new topic or a new subject version line, with consumers migrating explicitly.
Do Java classes generated from the schema need care with aliases?
Yes. The generated class has the new field name, fullName, so the consumer's code changes even though the data does not. Aliases only affect how Avro maps writer fields during reading.
When would you choose BACKWARD_TRANSITIVE?
When consumers may read data written with any older version, for example on topics with long retention, compacted topics, or replays from the beginning. Checking only against the latest version could allow a schema that cannot read version 1 data still sitting in the topic.
7Conclusion
In this answer, we saw that BACKWARD means the new schema can read data written with the previous one. Removing a field passes, adding one needs a default, and a plain rename fails because old data has no field with the new name. An alias in the reader schema, or a period with both fields followed by removal of the old one, makes the rename safe. Under BACKWARD we upgrade consumers before producers, FORWARD reverses the order and FULL allows either, and a compatibility check in CI stops incompatible schemas before deployment.
Open with
BACKWARD means consumers using the new schema can read data written with the previous schema. With Avro's resolution rules, a field the writer has and the reader doesn't is skipped, and a field the reader has but the writer doesn't gets the reader's default.
Then, if they want more
So removing legacyCode is allowed. Adding a field is allowed only with a default. A plain rename is not allowed, because the new reader looks for fullName in old data, doesn't find it, and has no default.
I'd fix that either with an alias, declaring fullName with aliases name, which lets the new reader match the old field, or more gently by adding fullName with a default, having producers populate both, letting the five consumers move over, and removing name later.
The rollout order matters: under BACKWARD the guarantee is new reads old, so I upgrade all consumers first, and only then let producers write the new version. With FORWARD it's the reverse, producers first, and with FULL either order works.
Since five teams are involved, I wouldn't rely on coordination by memory: the schema change goes through CI with the registry's compatibility check, auto-registration is off in production, and the pull request tags the consumer teams.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Kafka documentation, Spring for Apache Kafka reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A team wants to rename a field in an Avro schema used by five consumer services and...": https://scrivio-interview-library.netlify.app/spring-boot/kafka/844a6f8adf/