Scrivio Interview library
ScenarioAdvanced7 min read · updated 12 November 2026

After a shared library upgrade, 15 services start throwing ConcurrentModificationException at a low rate in production. You are leading the incident. Describe your actions during the incident and afterwards.

During the incident, confirm the common factor quickly by comparing stack traces across the 15 services and correlating the start with the library version rollout, then mitigate first by rolling back or pinning the previous library version instead of debugging in production. With the services stable, find the cause in the library's diff, typically a method that now returns a live internal collection or iterates shared state without protection. Afterwards, add a concurrent iteration test to the library, document the thread-safety of returned collections, stage future library rollouts and write up the incident so other library owners learn the pattern.

Why this question is asked

Incidents that hit many services at once can create confusion fast: fifteen teams each see errors in their own service, each starts debugging, and the actual cause sits in a shared dependency none of them owns. Interviewers ask this scenario to see how we lead: how we establish the common factor, how we choose mitigation over diagnosis, and what we change so the same class of failure cannot reach production again. In this answer, we will go through the first minutes, the mitigation, the root cause search and the follow-up work, with the reasoning behind each step.

1The First Minutes: Find the Common Factor

The first job of the incident lead is to stop fifteen parallel investigations and start one. We open a single incident channel, assign roles, a lead, a communications owner and one or two investigators, and ask each affected team for one thing only: a stack trace of the exception and the time it started.

Two comparisons usually settle the question within minutes. First, the stack traces: if all fifteen show the exception coming from an iterator over a collection that originates inside the same library class, the library is the common factor. Second, the timeline: if each service's error rate rose when that service deployed the new library version, and services still on the old version are clean, the correlation is strong. A deployment dashboard and an error-tracking tool grouped by library version make this a quick query rather than a debate.

Step throughIncident path from alert to follow-up
  1. Errors in 15 servicesone incident channel, one lead
  2. Compare stack traces and rollout timessame library frames, starts at upgrade
  3. Common factor confirmed?
    YesRoll back or pin the previous versionNoKeep narrowing: infra, data, traffic
  4. Watch error rates return to baselineincident mitigated
  5. Find the cause in the library diffreproduce with a test
  6. Fix, test, staged rollout, write-upprevent the class of failure

6 steps in order. Play them, or step through them one at a time.

Mitigation comes before root cause; the cause is found on a stable system.

2Mitigate First: Roll Back the Library

Once the library is the likely cause, the fastest safe mitigation is to undo the change: roll each affected service back to its previous build, or, if that build contains other needed changes, pin the library to the previous version and redeploy. For many teams a dependency management platform or a shared bill of materials makes the pin a one-line change.

The reason to mitigate before understanding is that the cost of the incident grows with time, while the value of debugging in production is small. A low-rate ConcurrentModificationException means some requests or jobs fail now, and, as we will see, possibly some data is wrong silently. A rollback is reversible and well understood. Debugging in production with extra logging is slow and risky. We can find the cause calmly afterwards from the library's diff and a test, with the services back to normal. We confirm mitigation by watching the error rates return to their old baseline in each service.

3Finding the Cause in the Library

With the services stable, the library owners read the diff between the two versions, guided by the stack traces. ConcurrentModificationException in callers after a library upgrade has a few typical causes. A method that used to return a copy now returns the live internal collection, often as an innocent performance optimisation that removed a List.copyOf. A collection that used to be concurrent was changed to a plain ArrayList or HashMap. Or new code iterates shared state, such as a registry or cache, from a background thread without the lock the rest of the class uses.

Java
// version 2.3 (before)
public List<Route> routes() { return List.copyOf(routes); }
// version 2.4 (after): "avoid a copy on every call"
public List<Route> routes() { return Collections.unmodifiableList(routes); }
// unmodifiable, but a live view: callers iterate while the refresh thread writes -> CME

The fix is then confirmed with a test that reproduces the exception against the 2.4 code, a background thread updating while several threads iterate the returned collection, and passes against the fixed code. Note that the exception rate is only the visible part. Because the underlying problem is an unsynchronized race, we also check whether callers could have read inconsistent data during the incident window, and tell the affected teams if any data needs checking.

4Afterwards: Make the Class of Failure Hard to Repeat

The follow-up work aims at the class of failure, not just this bug. In the library, we add the concurrent iteration test permanently to its suite, so any future change that returns a live collection fails the build. We document the thread-safety of every returned collection in the Javadoc: immutable snapshot, thread-safe view or not thread-safe. And we review other public methods in the library for the same pattern.

In the release process, we stage library rollouts. A new version of a widely used library goes first to one or two canary services, runs there for a day with error rates watched, and only then is offered to the rest. That would have turned fifteen affected services into one. We also make sure each service can pin a library version quickly, since that was our mitigation.

5Writing It Up So Others Learn

Finally, the write-up. A blameless post-incident review describes what happened, how we detected the common factor, why we rolled back first, the root cause with the code diff, and the follow-up actions with owners and dates. The reason to share it beyond the library team is that the pattern, returning a live collection from a shared API that another thread updates, is common, and other library owners can check their own APIs in an afternoon.

As the lead I would also note what went well and what slowed us down, for example how long it took to see which services ran which library version. That kind of gap is often worth more to fix than the bug itself.

6Follow-up questions

What if rolling back is not possible because the new version fixed a security issue?

Then we pick the narrowest mitigation that keeps the security fix: a patch release of the library that reverts only the collection change, or a hotfix in the callers that copies the result before iterating. The security fix stays, and the risky change is backed out.

How do we know it is the library and not traffic or infrastructure?

The two comparisons do this. If the errors started at different times in different services, each time matching that service's library upgrade, and services on the old version show nothing, infrastructure or traffic would not explain the pattern. If instead all services started failing at the same minute regardless of version, we would look at shared infrastructure first.

Should every library change be canaried?

Proportionally. A patch to a leaf utility used by two services needs little ceremony. A change to a library that dozens of services load at startup deserves a canary, because its blast radius is the whole platform.

7Conclusion

In this answer, we led the incident by first confirming the common factor from stack traces and rollout times, then mitigating by rolling back or pinning the previous library version rather than debugging in production. With the services stable, we found the cause in the library diff, a method that now returned a live collection, confirmed it with a concurrent test and checked for silent data errors. Afterwards we kept that test, documented the thread-safety of returned collections, staged future library rollouts through canaries and shared the write-up with other library owners.

What to say in the interviewAbout 100 seconds aloud

Open with

First I'd make it one incident instead of fifteen: one channel, one lead, a communications owner, and I'd ask each team for a stack trace and the time errors began.

Then, if they want more

Then I'd confirm the common factor quickly. If the stack traces all go through the same library class, and each service's errors start when that service picked up the new library version while services on the old version are clean, that's strong evidence.

At that point I'd mitigate before diagnosing: roll back the affected services or pin the previous library version and redeploy, and watch error rates return to baseline. Debugging a race in production is slow and risky, and a rollback is safe and reversible. Once things are stable, the library owners read the diff with the stack traces in hand.

For CME after an upgrade, the usual cause is a method that now returns a live internal collection, for example someone replaced List.copyOf with an unmodifiable view to save a copy, or new code iterating shared state without the class's lock.

We'd reproduce it with a test where a background thread updates while others iterate, fix it, and check whether any data could have been read inconsistently during the window. Afterwards I'd keep that concurrency test in the library, document the thread-safety of every returned collection, and stage library rollouts through one or two canary services before the rest.

And I'd write a blameless review and share it with other library owners, because returning live collections from shared APIs is a pattern they can check for in an afternoon.

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.
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 "After a shared library upgrade, 15 services start throwing...": https://scrivio-interview-library.netlify.app/java/iteration/7d069f4b5f/