Junior · Explain · Per-aggregate ordering, gaps and poison records

Why does quarantining sequence2 leave sequence3 blocked, and what separate policy is needed before advancing an aggregate?

Think through your answer before opening the explanation.

Production engineering

Reveal answer and reasoning

Ordering requires a named scope and a policy for missing or invalid operations. This consumer stores a last sequence for one aggregate and applies only its next expected sequence. It records duplicate message identity separately and keeps poison observations in a dead-letter table without declaring that their effects succeeded. Consequently a later sequence remains a gap until a valid predecessor is reconciled.

The fixture provisions no broker or universal total order. The companion is a smaller sequential decision model; the external SQL state and messages establish what this chosen aggregate consumer actually accepted.

Putting a message into a dead-letter table is not equivalent to applying it, authorizing a skip or unblocking every later sequence. An automatic advance would encode a different domain rule and could violate aggregate invariants. Conversely, preserving a gap indefinitely requires an operational reconciliation policy or the stream may stop making progress. Message order also does not imply that every aggregate shares one global sequence.

The fixture permits only its named classroom aggregate, so adding tenants or multiple producers needs explicit identity and sequence ownership. Do not claim those broader contracts from an integer last-value field. A quarantined row is an observation available for reconciliation, while the applied-message inbox and aggregate last value determine what the consumer actually accepted.

What a strong answer covers

  • The console prints gap1, applied1, quarantined, gap2 and applied2.
  • Quarantine records failure without advancing the aggregate.
  • Actual duplicate, stale and incompatible-id cases are separate from a valid next sequence.

Common pitfall

Treating dead-letter storage as success or assuming one local sequence establishes a broker-wide total order.

Follow-up questions

  1. Who assigns a sequence when several producers exist?
  2. What evidence and authority should a repair or skip operation require?

Self-review

Choose what to revisit. These marks are your own assessment and are separate from lesson completion.

Primary references

Open lesson and code ↗

← All interview questions