📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

A team makes what looks like a small change in one service, and three other services start failing in production within an hour. How do you diagnose it, find the hidden coupling (shared database, shared library, synchronous call chains, shared message contracts), and stop it happening again?

Diagnosing a change in one microservice that breaks others: using traces, deployment markers and dependency maps to find hidden coupling through shared databases, shared NuGet libraries, synchronous call chains and message contracts, then mitigating and removing it.

Senior Debugging Advanced coupling debugging distributed-systems distributed-tracing incident-response microservices

🎯 Key points

  • Mitigate first: roll back the changed service (or flip its feature flag) and confirm the others recover
  • Observability is the prerequisite: deployment markers, per-service error and latency metrics, structured logs with correlation ids and OpenTelemetry traces
  • Follow distributed traces and the application map (Application Insights, Jaeger) from failing calls back to the changed service
  • Shared database: SQL logins and Query Store show other services reading or writing the changed tables or columns
  • Shared library: a common NuGet package changed serialisation, validation or behaviour; shared packages should hold plumbing only, never DTOs or domain models
  • Synchronous chains: latency or errors propagate A → B → C; per-attempt and total timeouts within the caller's budget plus circuit breakers stop the cascade
  • Message contracts: renamed fields or new enum values break consumers silently or fill dead-letter queues; consumer-driven contract tests (Pact) catch them in the provider's CI
  • Prevention: contract tests, data ownership, plumbing-only shared libraries, async boundaries, trace-generated dependency map

⏱ 30-second answer

First mitigate: roll back the changed service or turn off its feature flag and confirm the others recover; that also proves the link. Then find how they are coupled. Line up deployment markers with the error spikes, follow distributed traces and the application map from the failing services, and check the four usual hidden couplings: a shared database (others read the changed columns), a shared library (a common NuGet package changed behaviour), synchronous call chains (one slow service times out everything upstream) and message contracts (a renamed field, a new enum value, DLQs filling). The real fix removes the coupling: contract tests, one data owner, thin shared libraries, asynchronous boundaries and timeouts with circuit breakers. The trade-off: decoupling costs effort, so fix the couplings that actually bite first.

🗣 Full answer (senior)

How I would answer this in an interview

"When a change in one service breaks three others, my first job is stopping the damage, not finding the cause. I roll back the changed service, or turn off the feature flag if the change is behind one, and watch whether the other three recover. If they do, I've both mitigated and confirmed the link, and I can investigate without customers waiting.

For example, at [company], a [customer] service released a change that [renamed a column / tightened validation], and within [40 minutes] the [orders, billing and notifications] services were throwing errors. We rolled back and they recovered in [minutes]. Then I put the deployment markers next to the error rates in Application Insights, and followed failing traces back. It turned out to be [two couplings at once]: billing read the customer table directly, and orders and notifications used a shared Company.Common NuGet package whose new version changed [a JSON serialiser setting]. Neither showed up in any API contract, which is why nobody saw it coming.

So I always check four places. Is there a shared database, and does anyone else read the tables that changed? Is there a shared library, and did its version move? Is there a synchronous chain, where the changed service got slower and everything upstream timed out because nobody had sensible timeouts or circuit breakers? And is there a message contract, where a field was renamed or an enum value added and consumers fail or dead-letter? The lasting fix is removing the coupling, not just being more careful: contract tests, one owner per table, shared libraries limited to plumbing, and timeouts and breakers on every call. The mistake I see is treating it as a one-off bad deploy; three services breaking means the architecture has a hidden dependency."


The four hidden couplings

Coupling How it breaks How you see it Lasting fix
Shared database Column renamed, type changed, rows locked SQL errors in other services; Query Store / sys.dm_exec_sessions by login or Application Name One owner; others use API, events or read model
Shared library (NuGet) Behaviour change in serialisation, validation, auth or retry defaults Failures start when consumers redeploy with new package; diff of package versions Thin libraries (plumbing only), semantic versioning, no domain logic shared
Synchronous chain Changed service slower or erroring; callers time out, thread pools and connections exhaust Traces show long spans downstream; rising latency then errors upstream Timeouts, circuit breakers, fallbacks, async messaging, caching
Message contract Field renamed, enum added, meaning changed Deserialisation errors, nulls, DLQ growth Contract tests, tolerant readers, versioned events

Others worth checking: shared configuration (one Key Vault secret or App Configuration key used by many), shared infrastructure (a Redis key format, a cache all services use), and shared identity (a token audience or scope change).

Diagnosis order

  1. Mitigate: rollback or feature flag; confirm recovery.
  2. Correlate: deployment markers, release notes, package diffs, migration scripts.
  3. Trace: application map and end-to-end transactions from a failing request.
  4. Classify: which of the four couplings (or more than one).
  5. Fix forward: make the change backward compatible (expand and contract), then redeploy.
  6. Remove the coupling and add a guard (test, alert, ownership rule).

Production example

A change in a [customer] service caused errors in three services for 35 minutes; ~4% of checkouts failed. After rollback, the cause was a shared table read by billing and a shared NuGet package that switched PropertyNamingPolicy. Moving billing to a CustomerUpdated read model and stripping the shared package down to logging and telemetry setup removed both couplings; the next six customer-service schema changes shipped with no cross-service impact.

🔍 What the interviewer is checking

Checks structured incident handling and the ability to find coupling that isn't visible in APIs.

Green flags

  • Mitigates before diagnosing
  • Uses deployment markers, traces and the application map
  • Checks shared DB, shared libraries, sync chains and message contracts
  • Proposes structural fixes and guards, not just "be careful"

Red flags

  • Starts reading code while production is down
  • Blames the team that changed the service
  • No mention of timeouts, contracts or data ownership

📚 Learn in depth

1. Why couplings stay hidden

APIs are visible: they have routes, OpenAPI documents and maybe contract tests. Hidden couplings don't. A SELECT from another service's table, a shared DLL, a shared Redis key or a timeout chain only shows up at runtime. The changing team can't see them in their own repo, so they ship confidently.

2. The failure, drawn

            deploy v2 of Customer service (renames column, bumps Common 3.0)
                                  |
     +----------------------------+-------------------------------+
     | shared DB                  | shared NuGet                  | sync chain
     v                            v                               v
Billing: SELECT FullName    Orders/Notifications:         Checkout -> Customer (now 800 ms)
  -> SqlException            Common 3.0 serialises           -> 2 s timeout x retries
     "Invalid column"        camelCase -> others expect       -> thread pool and connection
                             PascalCase -> nulls              pool exhaustion -> 5xx

3. Tools and what each shows

  • Deployment markers / release annotations (Azure DevOps, GitHub Actions to Application Insights): when the errors started relative to which deploy.
  • Application map and end-to-end transaction view (Application Insights) or Jaeger/Tempo: which calls fail, where latency grows, which service is the origin.
  • Exceptions grouped by type: SqlException number 207 (invalid column) points to the database; JsonException or unexpected nulls to contracts or libraries; TaskCanceledException / TimeoutRejectedException to sync chains.
  • SQL Server: sys.dm_exec_sessions with program_name (from Application Name), Query Store by query text to find who reads a table.
  • Package diffs: dotnet list package --include-transitive before and after; lock files (packages.lock.json) make this exact.
  • Service Bus / Kafka: DLQ counts, dead-letter reasons, consumer error logs.
  • dotnet-counters: thread pool queue length and connection counts in the callers during a sync-chain failure.

4. Removing each coupling

Shared database: assign an owner, give other services their own identity with no access, replace reads with events into a local read model or an API (see database per service).

Shared library: keep shared packages to cross-cutting plumbing (logging setup, telemetry, auth handler configuration). Never share domain models or DTOs between services as a library; each consumer defines its own DTO for what it reads. Version with SemVer and treat behaviour changes as major.

Synchronous chains: every outbound call gets a timeout shorter than the caller's own budget, a circuit breaker and a fallback where possible (AddStandardResilienceHandler). Move non-essential work to messages so a slow service doesn't block the request.

Message contracts: contract tests or schema registry checks; additive changes only; tolerant readers.

5. Making couplings visible

  • A dependency map in the service catalogue, generated from traces, not hand-drawn.
  • Architecture tests that stop references to another service's packages.
  • Database permissions that make cross-service access impossible rather than discouraged.

Try it yourself

  1. Add Application Name=<service> to connection strings and list which services touch each table using sys.dm_exec_sessions and Query Store.
  2. Run dotnet list package --include-transitive across your services and find which share an internal package and at which versions.
  3. In a test environment, add 1 second of latency to one service (Azure Chaos Studio or a fault-injection middleware) and watch which callers fail.
  4. Rename a field in a message in a branch and check whether any test catches it.

💻 Code

Two of the fixes: each consumer owns its DTO instead of sharing a library type, and every outbound call has a timeout and a circuit breaker.

// Before: Orders and Notifications both referenced Company.Common.Contracts.CustomerDto from a shared NuGet package.
// A serialiser change in that package broke both at once.

// After: each consumer declares only the fields it reads, with its own serialiser options.
namespace Orders.Integration;

using System.Text.Json;
using Microsoft.Extensions.Http.Resilience;

public sealed record CustomerSummary(Guid Id, string DisplayName, string? Email);

public sealed class CustomerClient(HttpClient http)
{
    private static readonly JsonSerializerOptions Json = new(JsonSerializerDefaults.Web); // explicit, not inherited

    public Task<CustomerSummary?> GetAsync(Guid id, CancellationToken ct) =>
        http.GetFromJsonAsync<CustomerSummary>($"/customers/{id}", Json, ct);
}

public static class CustomerClientRegistration
{
    public static IServiceCollection AddCustomerClient(this IServiceCollection services)
    {
        services.AddHttpClient<CustomerClient>(c => c.BaseAddress = new Uri("https+http://customer"))
            .AddServiceDiscovery()
            .AddStandardResilienceHandler(o =>
            {
                // Our own request budget is 2 s, so the dependency gets less than that in total.
                o.AttemptTimeout.Timeout = TimeSpan.FromMilliseconds(500);
                o.TotalRequestTimeout.Timeout = TimeSpan.FromSeconds(1.5);
                o.CircuitBreaker.FailureRatio = 0.2; // open quickly instead of piling up requests
            });
        return services;
    }
}
-- Who else reads the table we want to change? Run while the system is under normal load.
SELECT s.program_name, s.login_name, COUNT(*) AS sessions
FROM sys.dm_exec_sessions AS s
WHERE s.is_user_process = 1
GROUP BY s.program_name, s.login_name;

-- And which queries mention the column (Query Store):
SELECT TOP (20) q.query_id, t.query_sql_text
FROM sys.query_store_query AS q
JOIN sys.query_store_query_text AS t ON t.query_text_id = q.query_text_id
WHERE t.query_sql_text LIKE N'%FullName%';

⚠ Common mistakes

  • Mistake: Debugging in production while customers are failing. Why it is wrong: prolongs the outage. Instead: roll back or flag off first, then investigate.
  • Mistake: Calling it "a bad deploy" and moving on. Why it is wrong: the coupling remains and the next change breaks things again. Instead: name the coupling and remove it.
  • Mistake: Sharing DTOs or domain models through a common NuGet package. Why it is wrong: one package change ripples into every consumer on their next build. Instead: each consumer owns its DTOs; shared packages only for plumbing.
  • Mistake: Letting other services read your tables "just for reporting". Why it is wrong: every schema change becomes a cross-team change. Instead: events, an API or a reporting copy.
  • Mistake: Outbound calls without explicit timeouts or circuit breakers. Why it is wrong: one slow service exhausts callers' threads and connections. Instead: timeouts within the caller's budget, breakers and fallbacks.
  • Mistake: Renaming or repurposing fields in events. Why it is wrong: consumers fail silently or dead-letter. Instead: additive changes, versioning, contract tests.
  • Mistake: Relying on a hand-drawn architecture diagram to find dependencies. Why it is wrong: it's out of date. Instead: dependency maps from traces and database session data.

🏛 Senior insight: trade-offs

A cascading break from a small change is a symptom of a distributed monolith: services that deploy separately but are coupled at runtime or through shared artefacts. The senior response is two-speed: fast mitigation and a blameless review, then a prioritised plan to remove the couplings that cause the most incidents, rather than a rewrite.

Coupling Cheapest guard Proper fix When it's acceptable
Shared database Separate logins, alerts on foreign access Data ownership + events/read models Temporary, during a migration, with an owner and end date
Shared library Lock files, SemVer, changelog Plumbing-only packages, own DTOs Logging/telemetry/auth setup
Sync chain Timeouts + breakers Async messaging, caching, fewer hops Calls that truly need a live answer
Message contract Contract tests / schema registry Versioned, additive events —

Measure: incidents caused by changes in another service, number of services reading each table, and the depth of synchronous call chains in traces.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate finds a shared database Why: Checks they can plan a safe move to database per service.
    How to answer

    Sharing tables couples services through the schema: renaming a column needs both teams to release together, business rules are enforced in two codebases and drift apart, and one service's long transaction or bad query blocks the other. You also lose independent scaling and failover. With database per service, each service is the only writer of its data and others use its API, events or a local read model. To migrate: choose an owner, make the other service read-only with its own login, replace its reads with an API or events, then move and separate the data with expand-and-contract steps. The trade-off: you give up cross-service joins and atomic transactions in exchange for independent change.

  2. When: Candidate mentions contract or message changes Why: Checks contract testing and compatibility rules.
    How to answer

    Use consumer-driven contract tests: each consumer writes a test that records the requests it makes and only the fields it relies on, producing a pact file (PactNet 5.x, Pact specification v4). The provider's pipeline replays every consumer's pact against the real service, and the Pact Broker's can-i-deploy blocks a release that would break a consumer in that environment. Unlike end-to-end tests, they run in seconds per service without deploying everything. Pair them with compatibility rules: additive changes only (new optional fields, new endpoints), tolerant readers that ignore unknown fields, and a new version plus a deprecation period for anything breaking. The trade-off: contract tests catch shape and semantics you encode, not every behaviour, so keep a few journey-level smoke tests.

  3. When: Candidate mentions shared NuGet libraries Why: Checks how shared libraries and versioning quietly couple deployables.
    How to answer

    A logical boundary decides what code may depend on: a module, an assembly, a namespace, a database schema. A deployment boundary decides what ships and runs together: one App Service, one container, one Function app.

    They don't have to match. A modular monolith has many logical boundaries in one deployable. Microservices add deployment boundaries so units can be deployed independently, which only works if contracts stay backward compatible.

    The quiet killer is shared libraries: a NuGet package with shared domain models or contracts that every service must upgrade together turns separate deployables back into a distributed monolith.

    Monorepo vs polyrepo is about workflow, not architecture: a monorepo makes cross-cutting changes easy; a polyrepo forces versioning. The trade-off is coordination cost vs isolation.

🛠 Real-world problems: how you handle them

A customer-service release broke orders, billing and notifications
Situation
A [customer] service released [a column rename and a shared package upgrade] during business hours; [orders, billing and notifications] depended on it in different ways. Checkout handled [~200] orders per minute.
Signals
Error-rate alerts on three services within 40 minutes of the release; `SqlException` 207 (invalid column name) in billing; nulls in customer names in notifications; checkout p95 rising from 300 ms to 2 s with timeouts; ~4% of checkouts failing.
Investigation
Rolled back and confirmed recovery; compared deployment markers with error spikes in Application Insights; followed end-to-end transactions in the application map; queried `sys.dm_exec_sessions` and Query Store and found billing selecting from the customer table; diffed `packages.lock.json` and found `Company.Common` 2.x → 3.0 with a serialiser naming change.
Resolution
Immediate: rollback, then a fix-forward that kept the old column alongside the new one and pinned the old package. Real fix: billing moved to a `CustomerUpdated` read model; shared DTOs removed from the common package; timeouts and circuit breakers added to checkout's customer client.
Prevention
Database permissions removing cross-service access; contract tests for customer API and events; a rule that shared packages contain plumbing only; trace-generated dependency map in the catalogue; chaos test adding latency to the customer service in staging.

How to tell it (STAR)

**S:** At [company], a release of the [customer] service broke [three] other services within [40 minutes], and about [4%] of checkouts failed. **T:** I was incident lead and then owned the follow-up. **A:** I had the team roll back first, which restored everything and confirmed the link. Then I lined up deployment markers with the errors, followed traces, and checked database sessions and package diffs. We found two hidden couplings: billing read the customer table directly, and two services shared DTOs through a common package whose new version changed JSON naming. I led the fixes: a read model for billing, consumer-owned DTOs, and timeouts and breakers on checkout's calls. **R:** The next [six] customer-service schema changes shipped with no impact on other services, and change-related cross-service incidents dropped [from about one a month to none that quarter].

More in Microservices

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me