Duplicate Customers After an Ingestion Retry

SQL · reliability · Intermediate · about 20 minutes

Impact

The customer table grew overnight and some customers received the same marketing email two or three times.

Symptoms

Evidence

Ingestion log

02:00:04 ingest_customers attempt=1  ERROR connection reset after partial commit
02:03:10 ingest_customers attempt=2  ERROR connection reset after partial commit
02:06:15 ingest_customers attempt=3  status=SUCCESS

Row counts after the run

measurevalue
rows in customers8
distinct (customer_name, email, phone)5

customers, selected rows

customer_idcustomer_nameemailphone
101Alicealice@mail.com555-3311
103Alicealice@mail.com555-3311
106Alicealice@mail.com555-3311
107Dandan@mail.com555-3344
108Dandan@mail.com555-3399

customers schema

columntypenote
customer_idINTprimary key, assigned on every insert
customer_nameVARCHAR
emailVARCHAR
phoneVARCHAR

Investigation task

Return one row per real customer, keeping the original record (the one with the smallest customer_id): customer_id, customer_name, email, phone, ordered by customer_id.

The fix is written and graded in the regular challenge editor. The postmortem unlocks once the incident is resolved.

All production incidents