Scrivio Interview library
ScenarioIntermediate6 min read · updated 13 November 2026

Version 42 of an order service added a status, PARTIALLY_SHIPPED, and wrote it to the database and a Kafka topic. It then showed a memory leak, so the team rolled back to version 41, which failed at once on orders with the new status, and two consumers crashed on the events.

Why did the rollback make things worse, and what rules would make releases like this safely reversible?

The rollback made things worse because version 41 could not read data that version 42 had already written: the PARTIALLY_SHIPPED value in the database and the events was unknown to it, and mapping an unknown enum value throws, so every read of those orders and every such event failed. Releases stay reversible when reading a new value ships one release before writing it, readers tolerate unknown values and fields, schema changes follow expand and contract, event compatibility is enforced by a schema registry, and the rollback path is tested before each release.

Why this question is asked

We usually treat rollback as the safe button: when a release misbehaves, go back to the last good version. This incident shows the hidden assumption behind that button, that the old version can understand everything the new version has done. Interviewers ask it because it tests whether we think about data and messages, not only code, when we plan a release. In this answer, we will reproduce why version 41 failed, then build the rules that keep releases reversible: read before write, tolerant readers, expand and contract, compatibility checks, and testing the rollback. We will finish with what to do during an incident like this one.

1A Quick Recap: Code Rolls Back, Data Does Not

Rolling back replaces the running code. It does not undo the rows that version 42 wrote to the database or the events it published to Kafka. Those stay, and version 41 now has to read them. While version 42 was live, some orders moved to PARTIALLY_SHIPPED, and events carrying that status were published to a topic that two other services consume.

So the question for any release is not just whether the new version can read old data, which we usually test, but also whether the old version can read new data, which we usually do not.

2Why Version 41 Failed

In version 41, OrderStatus is an enum without PARTIALLY_SHIPPED. Wherever the code turns a stored string into that enum, it fails.

Java
enum OrderStatus { CREATED, PAID, SHIPPED, DELIVERED, CANCELLED } // version 41
OrderStatus.valueOf("PARTIALLY_SHIPPED");
// IllegalArgumentException: No enum constant OrderStatus.PARTIALLY_SHIPPED
// JPA with @Enumerated(EnumType.STRING) does the same valueOf when it loads the row
// Jackson, reading the Kafka event with default settings:
mapper.readValue("{\"status\":\"PARTIALLY_SHIPPED\"}", OrderEvent.class);
// InvalidFormatException: Cannot deserialize value of type OrderStatus from String "PARTIALLY_SHIPPED"

So every request that loaded one of those orders failed, and the two consumers threw on the events. A consumer that throws on a record usually retries it, and with default settings it can keep failing on the same record, blocking everything behind it in that partition; some setups crash the process. That is how a memory leak, a slow problem, became an immediate outage after the rollback.

3Rule 1: Read Before Write, One Release Apart

The core rule is to split reading a new value from writing it across two releases. Release A teaches the code to read PARTIALLY_SHIPPED and handle it correctly, but never writes it. Release B, or a flag turned on later, starts writing it. Now at every moment the previous version can read what the current version writes: if B is rolled back to A, A already understands the new status.

The same rule applies to new event fields, new columns and new message types. It costs one extra release, which in a team that deploys daily is a day of delay, and buys a rollback that always works.

Splitting a new status across releases
ReleaseReads PARTIALLY_SHIPPEDWrites itSafe to roll back to previous?
41 (old)NoNo-
42 as shippedYesYesNo: 41 cannot read the new data
42a: read onlyYesNoYes: nothing new was written
42b: write behind a flagYesYes, when the flag is onYes: 42a reads it; or turn the flag off

4Rule 2: Make Readers Tolerant

Even with careful releases, we want readers that do not crash on something unexpected. For JSON, Jackson can map unknown enum values to a default and ignore unknown fields.

Java
enum OrderStatus { CREATED, PAID, SHIPPED, DELIVERED, CANCELLED, @JsonEnumDefaultValue UNKNOWN }
ObjectMapper mapper = JsonMapper.builder()
.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.build();
mapper.readValue("{\"status\":\"PARTIALLY_SHIPPED\"}", OrderEvent.class).status(); // UNKNOWN

This is the Jackson 2 configuration; Jackson 3 changed some defaults and package names, so check your version. Spring Boot already disables FAIL_ON_UNKNOWN_PROPERTIES in its auto-configured mapper. For the database, an AttributeConverter can map unknown strings to UNKNOWN instead of throwing. The code must then decide what UNKNOWN means for each use: show the order as in progress, skip it in a report, or park the event for later rather than guessing.

For Kafka events, a schema registry such as Confluent Schema Registry or Apicurio can enforce compatibility. In BACKWARD mode new consumers can read old events; in FULL mode old consumers can also read new events, which is what a rollback needs. In Avro, adding a symbol to an enum is only safe for old readers if the enum declares a default symbol, so the registry catches this exact change before it is published.

5Rule 3: Expand and Contract, and Test the Rollback

Schema changes in the database follow expand and contract. First expand: add the new column or allow the new value, in a way old code ignores. Then migrate code and data. Only much later contract: remove what is no longer used, once no running or rollback-target version needs it. A check constraint listing allowed statuses, for example, is widened first and narrowed last.

Finally, rollback must be tested, not assumed. Before deploying version N, the pipeline runs version N-1's tests or a smoke suite against data and events written by version N. In this incident, that test would have failed within minutes in staging.

6What to Do During the Incident

Once new data exists, rolling back is often the riskier choice. Rolling forward was safer here: either ship a fix for the memory leak, or, if that would take hours, restart pods on a schedule to contain the leak while the fix is prepared. If the new status itself were the problem, a flag that stops writing it, plus a release of 41 that can read it, would also have been safe. The consumers needed the same treatment: deploy a tolerant version, or temporarily route the poison events to a dead-letter topic so the rest of each partition keeps flowing.

7Follow-up questions

How many releases must data stay readable by older versions?

At least as far back as any version we might roll back to, which for most teams is one release, N-1. If several services or mobile clients read the same data, the window is longer: old mobile app versions stay in use for months, so data and events they read must stay compatible for that long. Many teams state the rule explicitly, for example that every release must be readable by the previous two, and test against it.

Is it ever right to roll back after new data was written?

Yes, when the old version can safely read the new data, which is exactly what the read-before-write rule guarantees. Without that guarantee, rolling back may still be right if we first convert the new data, for example by updating PARTIALLY_SHIPPED rows to SHIPPED with a note, but that is a data migration under pressure and should be the last option.

What happens to the Kafka events already published with the new status?

They stay in the topic until retention removes them. Consumers will meet them again whenever they read that part of the log, including on replay. So the consumers must become tolerant, or the events must be handled through a dead-letter topic and reprocessed once the consumers understand the new value.

8Conclusion

In this answer, we saw that a rollback replaces code but not data. Version 42 wrote PARTIALLY_SHIPPED to the database and to Kafka, and version 41 and the consumers failed because mapping an unknown enum value throws. Releases stay reversible when reading a new value ships before writing it, readers map unknown values to a default and ignore unknown fields, a schema registry enforces compatibility, database changes follow expand and contract, and the rollback path is tested before each release. During the incident itself, rolling forward was the safer move.

What to say in the interviewAbout 70 seconds aloud

Open with

The rollback failed because version 41 could not read what version 42 had already written. Rolling back changes the code, not the data, so the orders with PARTIALLY_SHIPPED in the database and the events in Kafka were still there, and turning that unknown string into the enum, with valueOf, JPA or default Jackson, throws.

Then, if they want more

So every read of those orders failed and the consumers crashed on the events. To make releases reversible I would split reading from writing: first a release that can read the new status but never writes it, and only later, or behind a flag, a release that writes it, so the previous version can always read the current version's data.

I would make readers tolerant: an UNKNOWN default with READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE in Jackson 2, ignoring unknown fields, and a schema registry in full compatibility mode for events. Database changes follow expand and contract. And the pipeline tests rollback, running version N-1 against data written by version N.

During the incident, once new data existed, I would roll forward with a leak fix or a flag rather than roll back.

About this answer

Last updated
13 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 official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
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 "Why did the rollback make things worse, and what rules would make releases like this...": https://scrivio-interview-library.netlify.app/architecture/high-availability/c25d637ea7/