FM-039 Distributed Systems and Data Consistency

Out-of-Order Event and State Transition Failures

An order cancellation event arrives before the order-created event; without sequence checks the resource moves into an invalid state.

Failure explanation

Events are delivered or processed in an order different from their causal order, and consumers apply them without checking sequence, version, or current state. This can regress a resource to an earlier state or create impossible transitions. This differs from duplicate webhook delivery: the central issue is whether the business state remains correct when event order changes.

Example

An order is created, shipped, then delivered. Due to queue delays, the consumer processes DELIVERED before SHIPPED; later it applies the older shipped event and changes the order back to SHIPPED.

How to test

  • Generate event sequences and deliberately reorder or delay them.
  • Test sequence numbers, aggregate versions, timestamps, and state-transition rules.
  • Deliver stale events after newer state has been applied.
  • Verify replay and reconciliation behavior.

Expected behavior

Consumers detect stale or out-of-order events and apply a documented ordering, versioning, buffering, or reconciliation policy. Invalid transitions must not silently corrupt current state.

Runnable examples

Each example includes a broken server, a fixed server, an OpenAPI spec, and a clrsig scenario that detects the failure.