Catalogue / mailchimp-2019-mandrill-xid-wraparound

The hottest shard of Mandrill's Postgres key-value store stopped taking writes for more than a day when transaction ID wraparound protection triggered

Mailchimp, 2019. Mandrill sharded Postgres key-value store.

Organisation
Mailchimp
Evidence
Incident report
System
Mandrill sharded Postgres key-value store
Setup
Sharded

Near: act as a unified K/V store sharded by

As of
2019-02
Source
What We Learned from the Recent Mandrill Outage

Mailchimp, published 2019-03-26 (Read from the Internet Archive copy captured on 2026-11-19; the live site could not be reached.)

Architecture

Mandrill has a set of distinct Postgres databases that act as one key/value store, sharded by key through a hashing algorithm. Jobs write rows to the shards as part of their execution, and one shard also held the tables that track a few of the job queues. Jobs that cannot write queue on disk on the Mandrill app servers.

Section: Wraparound Protection Triggered | Section: Worst Case Scenario

Figures, as the source states them

FigureAs statedNoteWhere
Share of queued emails sent during the outage80 percentOnlyNear: we were sending only 80% of queued emails
Highest estimate of the full vacuum's runtime40 daysThe team's highest estimate, not a measured timeNear: Our highest estimate was 40 days
Default age threshold for deleting queued mail48 hoursBy default; mail older than this is deletedNear: deletes queued mail older than 48 hours

Records

Failure#f1

The shard favoured by the hashing algorithm reached the transaction ID limit and shut down to protect against wraparound

mailchimp-2019-mandrill-xid-wraparound#f1 at corpus version 26a1b3a7e3dd
Trigger

At 05:35 UTC on February 4 shard4's transaction ID reached its upper limit, and Postgres put that database into its safety shutdown mode.

Section: Wraparound Protection Triggered

How it failed

The hashing algorithm that balances load favoured shard4, making it hotter than the others with a higher write load. Its autovacuum likely fell behind under that load, though it may have failed outright; the team cannot tell which. Once it stopped taking writes, jobs that had to write to shard4 failed and queued on disk on the app servers; those jobs and the logs of their failures ran disk space low on every app server, and retries of failed writes raised the load on shard4.

Section: Wraparound Protection Triggered | Section: Worst Case Scenario

Why defences did not hold

In November of 2018 engineers saw the transaction IDs climbing to approximately half their limit at peak load, judged wraparound not an immediate threat, and put a ticket for more monitoring in the backlog. The first exception was drowned out in centralized reporting by unrelated ones. The review also lists factors that slowed the response: knowledge of and access to Mandrill concentrated in few people, logging that needs a locally writable disk, and limited visibility into job health.

Section: A Potential Problem | Section: Wraparound Protection Triggered | Section: What We Learned

Impact

From 05:35 UTC on February 4 until the issue was announced resolved at 22:09 UTC on February 5, the ability to send emails was impaired, and only 80% of queued emails were being sent; some users saw residual effects after that. Affected users got refunds for what they had bought from Mandrill from January 1, 2019 to February 13, 2019, and credits of Mandrill blocks for future purchases in February.

Near: The outage began at 05:35 UTC on February | Section: Making Good

Fix

The Search and Url tables were truncated at 19:12 UTC on February 5 and the vacuum completed roughly an hour later; sending from the backlog began at 21:36 UTC. New alerting for XID wraparound was in place by 22:40 UTC, and the queues were down by 01:00 UTC on February 6. Storage for the app server instances was expanded quickly. In progress, as of the account of the outage: a separate track of work to replace storage volumes across the app servers.

Section: Getting Creative | Section: What We Learned | Near: replace storage volumes across app servers

Decision#d1

Truncate the two terabyte-scale tables on the locked shard so the vacuum could finish

mailchimp-2019-mandrill-xid-wraparound#d1 at corpus version 26a1b3a7e3dd
Chosen

At a meeting at 16:30 UTC on February 5 to assess more radical options, the team decided to truncate the Search and Url tables of the locked database, having first verified that doing so frees the transaction IDs tied to them. It ran the truncation at 19:12 UTC.

Section: Getting Creative

Rejected

Keep waiting for the full vacuum in standalone mode, which was already running. Even restarted with configuration tweaks that sped it up significantly, its runtime was put at days or even weeks, 40 days at the highest estimate, which was far too long.

Near: Our highest estimate was 40 days

Keep waiting for the dump and restore begun while the vacuum ran. It looked likely to finish faster than the vacuum but was still disastrously slow. The Search and Url tables were then left out to speed it up; the post gives no estimate for that reduced dump.

Near: The dump and restore operation looked likely

What forced it

Mandrill by default deletes queued mail older than 48 hours, and as that limit approached more drastic solutions were considered.

Near: deletes queued mail older than 48 hours

Reasoning

By then the team had determined the app could run without those two tables. They were on the order of TB, where most other tables were in the MB range. The post says the team was lucky to have data it could delete at all, and luckier that it included the largest table holding up the vacuum.

Near: possible to run the app without the Search | Near: which were on the order of TB | Near: We were lucky that we had data

Outcome

It worked: the vacuum completed roughly an hour after the truncation.

Near: The vacuum completed roughly an hour after

Decision#d2

Move the job-queue tracking tables off the stuck shard to other live shards

mailchimp-2019-mandrill-xid-wraparound#d2 at corpus version 26a1b3a7e3dd
Chosen

The tables used to keep track of a few of the job queues, which shard4 held as part of Mandrill's operational data, were moved to other live shards to allow normal processing of jobs.

Near: Shard4 also holds some of the operational data

What forced it

Shard4 was no longer accepting writes.

Near: A secondary effect of shard4 no longer accepting

Outcome

It did not end up helping much, because jobs bound for the shard4 queues generally also needed to write other data to that same shard.

Near: This did not end up helping much

Review

Extracted by
Claude (feed 26)
Human review
Not started. Status recorded on 2026-12-02.