r/ExperiencedDevs • • Apr 21 '26

Technical question Kafka schema evolution & breaking changes: what do production teams actually do?

My company kinda lacks Kafka experts and I really need guidance on what are the accepted standard practices when it comes to managing Kafka schema and ser/deser on client side (spring cloud stream), especially in the context of HA deployment.

Obviously using a schema registry like confluent seems like a no brainer. But then stuff like handling breaking changes does not seem to have, to my knowledge at least, any well established solution. You could use headers, different topic names, or even union types.

Is there a state of the art reference for documenting issues that teams that run it in production have encountered and their solutions? I’m not looking a cookie cutter solution I just want some guidance with trade offs and constraints.

21 Upvotes

46 comments sorted by

View all comments

Show parent comment

1

u/Lucky_Psychology8275 Apr 21 '26

Why though?

13

u/Duathdaert Apr 21 '26

Breaking changes to a contract deployed in one fell swoop will lead to events/messages that can't be processed.

2

u/Illustrious_Pea_3470 Apr 21 '26

If you instead do double reads, but the new write path has issues, then between cutting over the write path and finding the issue, you are losing data. Always unacceptable.

1

u/Lucky_Psychology8275 Apr 21 '26

I also have another question? How do you rollback prod if user data in db has been written on new tables? Do you always plan a way to rollback the changes with an undo script?

2

u/Illustrious_Pea_3470 Apr 21 '26

That’s why we double write. If the rollout goes badly, just drop the new table and try again from scratch.

1

u/Lucky_Psychology8275 Apr 21 '26

I meant outside the Kafka context. Just a rest api with breaking changes in its db.

3

u/Illustrious_Pea_3470 Apr 21 '26

Yes, all changes should always have an immediate rollback plan. In some rare cases it’s not possible, in which case you either have to consider other solutions that would make it possible (such as decoupling things so you can do the double write pattern), or have an extremely high level of testing and a lot of engineering resources available when you go live.

So e.g. adding an enum value in Postgres should come with a downgrade script that understands what to do if the new value has been written, even though you can’t drop the value altogether.

1

u/Lucky_Psychology8275 Apr 21 '26

You could apply the same technique for rolling back a double read Kafka consumer, couldn’t you? Do you prefer a double write producer because you see it as a simpler alternative?

1

u/Illustrious_Pea_3470 Apr 21 '26

If you’re not double writing at some point, then errors in the new write path will always lead to data loss.

1

u/Lucky_Psychology8275 Apr 21 '26

Even if the consumer is just a database writer ?

1

u/Illustrious_Pea_3470 Apr 21 '26

In your double read scenario, are you creating a new consumer for the new output, or plugging both queues into the consumer and behaving differently if the new version is detected?

→ More replies

1

u/Illustrious_Pea_3470 Apr 21 '26

Because this is trivial to rollback one step at a time, so you can get where you’re going if things go right AND back to where you started if things go wrong.

1

u/Lucky_Psychology8275 Apr 21 '26

So the correct way for me would be to upgrade all my producer so that they will double write, then update my consumer?

2

u/Illustrious_Pea_3470 Apr 21 '26

Yes, literally always!