Try
↑ ↓ move↵ openesc close

Curriculum · Module 08, Distributed Transactions

Lesson 3 · 7 topics · 33 min · Intermediate · 0/7 done

Idempotency keys and the outbox

Retries cause duplicates, and a database write plus a publish can lose a message. Keys make requests safe to repeat, and an outbox makes the write and the event one transaction.

What each topic covers

  • A client that gets no reply sends the request again. The first one may have worked, so the retry makes a duplicate.
  • The client names the operation with a key. The service stores the key with the result and answers a repeat from the store.
  • Take orders from retrying clients, publish an event for each, and compare a dual write with the outbox, with and without keys.
  • A key table cannot grow forever. A retry that arrives after its key was forgotten looks like a new request.
  • Updating a database and a broker with two calls cannot be made safe. The outbox makes it one transaction.
  • The relay publishes, then marks the row. A crash between them repeats the event. The consumer must make repeats harmless.
  • Three quick checks on idempotency keys, the outbox and the relay, with the sources behind the lesson.

Topics

  1. 1The retry that charges twice3 min
  2. 2Keys and the dedup table4 min
  3. 3Retry, crash and publish8 min
  4. 4Keys that expire5 min
  5. 5Two writes and a crash between them5 min
  6. 6Publishing twice on purpose5 min
  7. 7Keys, the outbox and repeats3 min

Practise this lesson

8 interview questions on idempotency and the outbox, with worked answers and sources.

Practise these

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms