CREATE TABLE outbox (id UUID PRIMARY KEY DEFAULT gen_random_uuid(), aggregate_...CREATE TABLE saga_instances (id UUID PRIMARY KEY, saga_type TEXT, current_step...CREATE PROCEDURE compensate_payment(p_saga_id UUID) LANGUAGE plpgsql AS $$ BEG...UPDATE saga_instances SET current_step='payment',updated_at=NOW() WHERE id=? A...SELECT * FROM saga_instances WHERE status='running' AND updated_at < NOW()-INT...INSERT INTO outbox(aggregate_type,event_type,payload) VALUES ('payment','Payme...Apex Payments runs a microservices mesh where a single payment touches 5 databases across 3 services. A failed payment mid-flight leaves orders in limbo and inventory double-counted. You must implement the Saga pattern using the Outbox pattern for reliable messaging, design compensating transactions, build a saga orchestrator table, and handle partial failure recovery — including a network partition mid-saga scenario.
-- comment or REPORT statement