Data Consistency and Distributed Transactions Questions

Maintaining correctness of state across services and replicas: eventual consistency, conflict resolution (last-write-wins, CRDTs, vector clocks), the saga pattern, two-phase commit, and idempotency keys for exactly-once effects. Covers when to trade strict consistency for availability and how to reason about read-your-writes and monotonic guarantees. Focuses on the application/service layer rather than storage-engine internals.

HardTechnical
37 practiced

Given this naive message handler pseudocode: 'def handle_message(msg): try: db.execute("INSERT INTO processed_messages(id) VALUES (%s)", msg.id) except UniqueViolation: return process_already_done(); process_side_effects(msg)', identify race conditions or failure modes that could still cause duplicate side effects or lost processing. Propose corrected code-level fixes using SQL constraints, explicit transactions, status fields, or the transactional outbox pattern and provide corrected Python/SQL pseudocode.

HardTechnical
37 practiced

Implement (or sketch) a simplified transactional outbox poller in Python pseudocode that: 1) runs as a separate process, 2) reads pending outbox rows atomically, 3) publishes messages to Kafka, and 4) marks rows as published in a durable way. Include error handling for partial publishes, retries, idempotency considerations, and how the poller coordinates with application transactions.

MediumTechnical
37 practiced

Compare last-writer-wins (LWW) conflict resolution against CRDTs for achieving eventual consistency. In what scenarios is LWW acceptable, and when do CRDTs become the better fit? What operational costs does adopting CRDTs add (metadata growth, merge cost)?

HardTechnical
38 practiced

Design an algorithm to compact vector clocks or CRDT deltas in a long-running distributed system so their metadata doesn't grow unbounded, while preserving eventual convergence. What heuristics would you use, what trade-offs do they introduce in causality precision, and how would you recover or reconcile after a compaction?

EasyTechnical
32 practiced

For a high-throughput streaming ETL ingesting user events, what metadata would you record to enable efficient deduplication of events within a time window? Explain how fields such as event_id, user_id, event_time, ingestion_time, and partition offsets are used during processing, and the retention implications of keeping that metadata. Then list the common deduplication approaches available (producer-side dedupe, consumer-side dedupe using state, dedupe tables or upserts, watermark/window compaction) and give one advantage and one drawback of each.

Unlock Full Question Bank

Get access to all Data Consistency and Distributed Transactions interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.