CSE Roadmap

Specialist tier · about 2 hours · 5 parts

Part 5 of 5 · 4 min read

Exercises

Easy

Easy 1: Define a distributed transaction (15 minutes)

State what makes a transaction a distributed transaction.

Done when: a transaction whose operations span more than one node, requiring all of them to agree on one outcome, is correctly described.

Hint

A transaction whose operations span more than one node, requiring all of them to agree on the same commit-or-abort outcome.

Easy 2: Name the two phases of two-phase commit (15 minutes)

Name the two phases of two-phase commit, in order.

Done when: the prepare phase followed by the commit phase is correctly named, in that order.

Hint

The prepare phase, followed by the commit phase.

Easy 3: State what a prepared node must do before the coordinator's decision (15 minutes)

State whether a node that has responded yes during prepare can commit on its own before hearing the coordinator's decision.

Done when: no is correctly stated, with the node required to wait for the coordinator's final commit-or-abort decision instead.

Hint

No, it must wait for the coordinator's final commit-or-abort decision before proceeding.

Medium

Medium 1: Trace a successful two-phase commit (25 minutes)

Two nodes both respond yes during prepare. Describe what the coordinator does next, and what each node then does.

Done when: the coordinator sending a commit decision to both nodes, and each node then actually committing its part, is correctly described.

Hint

The coordinator sends a commit decision to both nodes, and each node commits its part for real.

Medium 2: Trace an aborted two-phase commit (25 minutes)

One of two nodes responds no during prepare. Describe what the coordinator does next, and what each node then does.

Done when: the coordinator sending an abort decision to both nodes, including the one that responded yes, and both nodes then aborting their part, is correctly described.

Hint

The coordinator sends an abort decision to both nodes, including the one that said yes, and both abort.

Medium 3: Identify the blocked state (30 minutes)

Both nodes respond yes, but the coordinator crashes before sending any decision. Describe the state each node is in.

Done when: both nodes being blocked, holding their prepared changes without committing or aborting, until the coordinator recovers and sends a decision, is correctly described.

Hint

Both nodes are blocked, holding their prepared changes without committing or aborting, until the coordinator recovers and sends its decision.

Hard

Hard 1: Explain why a prepared node cannot guess the coordinator's decision (30 minutes)

Explain why a node that has responded yes cannot safely assume the coordinator intended to commit, and proceed to commit on its own, after the coordinator becomes unreachable.

Done when: the explanation correctly notes that the coordinator could have received a no from a different node and been about to send an abort decision when it crashed, so a node guessing commit on its own risks disagreeing with a decision the coordinator had already made, breaking the all-or-nothing guarantee.

Hint

The coordinator could have already decided to abort based on a no from elsewhere; a node guessing commit on its own risks contradicting that decision and breaking the all-or-nothing guarantee.

Hard 2: Explain why single-node atomicity does not simply extend to multiple nodes (35 minutes)

Explain why a single node's own write-ahead-log-based atomicity guarantee, covered in the transactions level, is not sufficient on its own to guarantee atomicity across multiple nodes.

Done when: the explanation correctly notes that each node's write-ahead log only guarantees atomicity for that node's own local operations, with no node able to see or control another node's internal commit decision directly, which is exactly why an explicit cross-node coordination protocol such as two-phase commit is needed on top of each node's own local guarantee.

Hint

Each node's write-ahead log only guarantees atomicity for its own local operations; no node can see or control another node's commit decision, so an explicit cross-node protocol like two-phase commit is needed on top.

Hard 3: Propose a practical mitigation for the coordinator single point of failure (40 minutes)

Two-phase commit's coordinator is a single point of failure. Propose one practical way a real system could reduce the impact of a coordinator crash, and explain what limitation remains even with your proposal.

Done when: a reasonable mitigation is proposed, such as the coordinator durably persisting its decision to stable storage before crashing so it can resume correctly on recovery, or replicating the coordinator role itself, with the explanation correctly noting that prepared nodes can still be blocked for some period until the coordinator, or its replacement, actually recovers and communicates the decision.

Hint

Persisting the coordinator's decision to stable storage, or replicating the coordinator, helps it recover correctly; prepared nodes can still be blocked for some period until that recovery or replacement actually happens.