Learning center

How long must the errors stay away before the fix is proven?

Zero errors since a fix means something only if the old failure rate would have produced some by now. If the failure arrived at a steady rate, the chance that an unfixed system shows none in a watch of t hours is e^(-rate × t), so a watch of about three average gaps between failures leaves a 5% chance of a quiet watch by luck. When the failure needs a particular input, count the triggering requests that arrived since the fix instead of the hours.

The symptom and two explanations#

The example is illustrative. A fictional invoice-render worker failed nine times in the four days before Tuesday 10:00 UTC, each time with a timeout while writing a PDF. A fix that raised a buffer size shipped at 10:00. At 16:00 there had been no failures, and the incident lead asked whether the incident could be closed.

  • The fix worked. The failure cannot happen on the new build, and the quiet afternoon is the first part of a quiet month.
  • The failure is rare and simply has not recurred. Nine failures in 96 hours is one every 10.7 hours on average. Six quiet hours is what that rate produces more often than not.

Both explanations predict zero failures since 10:00. They part only over a watch long enough that the old rate would almost certainly have produced one. Choose the observation where explanations disagree

What each explanation predicts#

ObservationThe fix workedNot fixed, rare failure
Failures from 10:00 to 16:00nonenone in 57% of such watches
Failures expected at the old rate in the watchnone0.56
Failures in a 32-hour watchnonenone in 5% of such watches
Failures among the triggering requests since the fixnoneabout one per 40 triggering requests, if the trigger is a request type

The first row is the observation the incident lead had, and the unfixed system produces it more often than not. The third row separates the two: at the old rate, 32 hours hold three failures on average, and the chance of none is e^(-3), about 5%.

The general rule follows from the same formula. For a chance α that an unfixed system stays quiet, watch t = -ln(α) / rate. For α = 5%, -ln(0.05) is about 3, so t is about three mean gaps; this is the "rule of three". For α = 1%, it is about 4.6 mean gaps.

The lab: how often an unfixed system looks fixed#

The script simulates 20,000 unfixed systems for each watch length and counts how many show zero failures. The first part uses the pre-fix rate of 9 failures in 4 days. The second assumes the failure needs a bulk import request from one customer, and that each such request fails with probability 1/40; there it counts triggering requests instead of hours. It needs Python 3.8 or later.

import math, random, sys

rng = random.Random(int(sys.argv[1]) if len(sys.argv) > 1 else 5)
RATE = 9 / (4 * 24)        # before the fix: 9 failures in 4 days, per hour
TRIALS = 20000

def zero_in(hours):
    """Fraction of not-fixed systems that show zero failures in a watch of this length."""
    quiet = 0
    for _ in range(TRIALS):
        if rng.expovariate(RATE) > hours:   # time to the first failure
            quiet += 1
    return quiet / TRIALS

print(f"pre-fix rate {RATE:.3f}/hour, mean gap {1 / RATE:.1f} h")
print("watch   expected   zero failures, not fixed")
print("hours   failures   simulated   e^(-rate*t)")
for hours in (2, 6, 12, 24, 32, 48):
    print(f"{hours:5d} {RATE * hours:9.2f} {zero_in(hours):10.1%} {math.exp(-RATE * hours):12.1%}")
print(f"hours for a 5% chance of zero by luck: {-math.log(0.05) / RATE:.0f}")

# The trigger is one customer's bulk import; each import request fails with p = 1/40.
P = 1 / 40
print("\ntriggering requests   zero failures, not fixed")
for n in (10, 40, 80, 120, 200):
    sims = sum(all(rng.random() >= P for _ in range(n)) for _ in range(TRIALS)) / TRIALS
    print(f"{n:19d} {sims:12.1%}")
print(f"requests for a 5% chance of zero by luck: {math.log(0.05) / math.log(1 - P):.0f}")

Save it as watch.py. Before running it, write down your guess for the share of unfixed systems that look fixed after 6 hours and after 24 hours. The prediction from the formula is that the simulated share matches e^(-rate × t) within a percentage point at every length, and that it falls to about 5% near 32 hours.

python3 watch.py

Python 3.11 printed:

pre-fix rate 0.094/hour, mean gap 10.7 h
watch   expected   zero failures, not fixed
hours   failures   simulated   e^(-rate*t)
    2      0.19      83.0%        82.9%
    6      0.56      57.2%        57.0%
   12      1.12      31.8%        32.5%
   24      2.25      10.2%        10.5%
   32      3.00       5.2%         5.0%
   48      4.50       1.1%         1.1%
hours for a 5% chance of zero by luck: 32

triggering requests   zero failures, not fixed
                 10        77.6%
                 40        35.8%
                 80        13.6%
                120         4.7%
                200         0.5%
requests for a 5% chance of zero by luck: 118

After 6 hours, 57% of unfixed systems showed no failure. After a full day, one in ten still did. The quiet afternoon at 16:00 was weak evidence; a quiet period until Wednesday 18:00 would be decent evidence. The second table makes the same point in requests: an unfixed import path gets through 40 triggering requests without a failure about a third of the time, and needs about 120, three times 1/p, before a clean run is unlikely.

The prediction would have failed if the simulated column had drifted away from e^(-rate × t), which would mean the failures in the simulation were not independent. Run python3 watch.py 11 to repeat it with another seed; the shares move by a few tenths of a percent.

Count exposures when the trigger is intermittent#

Hours work as the unit only if the failure's opportunities arrive at a steady rate. Many do not. A failure triggered by one customer's bulk import, a nightly batch or a rare payload shape gets its chances only when that input arrives. If the customer imports on weekdays and the fix shipped on Friday afternoon, a quiet weekend tests nothing.

Count the triggering events since the fix and compare them with the pre-fix failure rate per event. Nine failures among 360 imports is 1 in 40, so the fix has a meaningful test after about 120 imports, whether that takes six hours or two weeks. If you do not know the trigger, you do not know what to count, and the hours are the best you have. Did the fix work, or did the trigger stop?

Read it on a real system#

The pre-fix rate comes from a failure counter over a window that ends at the fix. With Prometheus, the @ modifier pins the evaluation time to a Unix timestamp, and increase counts across counter resets. @ modifier · increase

# failures in the 96 hours before the fix at 2026-11-24 10:00 UTC
sum(increase(invoice_render_failures_total[96h] @ 1795514400))

# failures since the fix, and triggering requests since the fix
sum(increase(invoice_render_failures_total[30h]))
sum(increase(http_server_request_duration_seconds_count{service="invoice", route="/imports"}[30h]))

Without a counter, count failures and triggering requests from the logs. CloudWatch Logs Insights groups matches by time with stats count(*) by bin(1h), and start-query takes the window as epoch seconds. stats · start-query

aws logs start-query --profile PROFILE --region REGION \
  --log-group-name /ecs/invoice-render \
  --start-time 1795168800 --end-time 1795622400 \
  --query-string 'filter msg like /render timeout/ | stats count(*) by bin(1h)'
aws logs get-query-results --profile PROFILE --region REGION --query-id QUERY_ID

On Google Cloud, gcloud logging read takes the same kind of filter with a timestamp range. gcloud logging read

Where the arithmetic misleads#

The pre-fix rate is itself an estimate. Nine failures are consistent with a true rate about half as high, and at that rate the 5% watch is about 61 hours, not 32. Use the low end of the plausible rate when the cost of a wrong "fixed" is high.

A fix that lowers the rate without removing the failure looks like a fix for longer. If the new build fails a tenth as often, a 32-hour watch shows zero about 74% of the time. The watch length tells you the rate is lower than before, which is not the same as zero.

Zero failures also requires that a failure would still be recorded. A fix that changes the error path can stop the log line or the counter, and the failure goes on unseen. A log line is missing

Questions#

How long should I wait after a fix before closing the incident?

At least three times the average gap between failures before the fix, or three times 1/p triggering requests if the failure needs a specific input. That leaves about a 5% chance that an unfixed system would have looked fixed. Replaying the trigger against the new build can answer sooner.

What is the rule of three?

If an event has not occurred in n independent trials, the upper end of a 95% confidence interval for its rate is about 3/n. Read the other way, it says how many trials, or how many hours at a known rate, are needed before zero occurrences becomes unlikely for an unfixed system.

The failure happened once a week. Do I have to wait three weeks?

To rely on silence alone, yes. A faster answer comes from reproducing the trigger: send the input that failed to the old build and the new one, and see whether only the old one fails.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading