← Back to blog

The Bug That Kept Campaigns Paused for a Week

2026-04-13
buildingdebugging

Monday morning. A clinic's ads should have restarted automatically.

They didn't.

The clinic runs on a pay-per-lead model. 25 leads per week at $50 each. When they hit 25, the optimizer pauses the campaigns. When the new billing week starts, it should restart them.

Should.

What Happened

The client messaged me: "Ads aren't on."

I checked. The campaign was paused on Meta. The optimizer showed 0 leads for the new period. All conditions for restart were met. But no restart happened.

No error. No log entry. Just... nothing.

The Trace

The restart logic lived in the hourly cron. But the 15-minute cron processed the same clinic first. It saw 0 leads, fell through to the per-ad-set rules, found all ad sets paused, did nothing, and moved on.

Nobody restarted the campaign because the code that could restart it only ran hourly. And by the time the hourly cron checked, the campaign was somehow already active (the client manually turned it on).

But the real bug was deeper.

The quota pause was never logged in the first place. When the campaign hit 25 leads, it was already paused by a different rule (CPL cap or no-lead kill). The quota check only logged "paused" for active campaigns. Since it was already paused, it skipped silently.

Then when the new week started, the restart code looked for a "quota met" log entry to confirm this was a quota pause. Found nothing. So it didn't restart.

Chicken and egg. The pause was never recorded, so the restart never triggered.

The Fix

Two changes:

  • Log quota met even when the campaign is already paused. The event happened whether or not the campaign was active.
  • Add restart logic to the 15-minute cron, not just the hourly one. The code that processes this clinic most often should be the code that can restart it.

Deployed both. Tested. Works.

The Lesson

Automation is great until it isn't. The system managed 25 clinics flawlessly for weeks. Then one edge case -- a campaign paused by two rules at the same time -- broke the restart chain silently.

No error. No alert. Just a client wondering why their ads were off.

The fix took 30 minutes. Finding it took 3 hours of tracing through cron logs, Meta API responses, and database queries.

That's the work nobody sees. And it's the work that makes the system trustworthy.

If this was useful, follow along for more.

Follow on X