---
name: sre-data-reliability
description: Use when designing, operating or reviewing data pipelines, scheduled/cron jobs, backups and restores, or data integrity protections — pipeline SLOs, idempotency, handling stragglers and hot spots, distributed cron, defense in depth against data loss, and recovery testing. Based on Google SRE practice.
title: sre-data-reliability
canonical_url: https://skilld.dev/gh/paulip114/sre-practice-skills/sre-data-reliability
last_updated: 2026-10-22T13:31:15.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install paulip114/sre-practice-skills/sre-data-reliability`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/sre-data-reliability`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/paulip114/sre-practice-skills/sre-data-reliability) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/sre-data-reliability`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/sre-data-reliability --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/sre-data-reliability --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Data Pipelines, Scheduled Jobs and Data Integrity

## Data integrity: what users need is restores, not backups

Users judge you by whether their data is there and correct when they ask for it. A backup that has never been restored is a hope, not a plan.

### Threat model

Data loss comes from many combinations of:
- **Root cause**: user error, application bugs, operator/automation error, infrastructure failure, malicious action, migration bugs.
- **Scope**: wide (many entities) vs. narrow (one user/object).
- **Rate**: sudden (big bang) vs. slow and creeping (a bug corrupting a little data each day for months).

Slow, creeping corruption is the most dangerous: by the time it's noticed, it's in every recent backup and replica.

### Defense in depth

1. **First layer — soft deletion / undo**: deleted data goes to a trash/tombstone state for a retention period (days to weeks) before purge; users and support can undo. Protects against user and application errors.
2. **Second layer — backups and recovery**: versioned backups with retention long enough to catch slow corruption, stored in a separate failure domain and administrative domain (so the same bug or operator mistake can't delete both). Replication is **not** a backup — it faithfully replicates corruption and deletes.
3. **Third layer — early detection**: continuous **out-of-band validation** that checks data invariants (referential integrity, counts, checksums, business rules) and alerts on drift. Detection time is what bounds how far back you need to restore.

### Recovery

- Define **RPO** (how much data loss is tolerable) and **RTO** (how fast you must recover) per dataset, and design backups to meet them.
- **Test restores continuously** and automatically, end to end, from real backups; measure time to restore. Alert when a restore test fails.
- Support **partial/point restores** (one user, one table, one time range), not just "restore everything".
- Keep tooling and runbooks for recovery as production-grade as serving code.

## Data pipelines

### Design

- Prefer **continuous/streaming or frequent small batches** over huge periodic batches when freshness matters; big periodic jobs create load spikes ("thundering herds") and long recovery after failure.
- Make every stage **idempotent** and re-runnable; write outputs atomically (write then rename/commit).
- Define pipeline SLOs: **freshness**, **correctness**, **coverage/completeness**, and end-to-end latency (`sre-slos-and-error-budgets`).
- Handle **stragglers and hot spots**: split work into many small shards, rebalance dynamically, avoid skewed keys.
- **Schema changes and migrations**: versioned schemas, backward/forward compatible readers, dual-writes and backfills staged and verified.
- Isolate pipelines by priority so a large low-priority backfill can't starve a critical job.
- Plan dependencies: know upstream sources, their SLOs, and what happens when they are late or bad; validate inputs and quarantine bad records instead of failing whole runs or silently passing garbage.

### Operating

- Monitor: freshness/lag at each stage, throughput, backlog, error/quarantine counts, data quality checks.
- Alert on SLO (e.g. "data older than X for > Y% of reads"), not on every task failure.
- Keep runbooks for: reprocessing a time range, skipping/quarantining poison inputs, backfills, and rolling back a bad output version.
- Canary pipeline code and config changes on a subset of data and compare output against the previous version before full rollout.

## Distributed cron / scheduled jobs

- Run the scheduler itself redundantly with leader election via a consensus system, so one machine's failure doesn't skip or double-run jobs.
- Persist launch state durably: record intent **before** launching and success **after**, so a new leader can tell whether a job ran.
- Make jobs **idempotent** or have them check for prior completion; decide explicitly whether a missed run should be skipped or run late, and whether a double run is acceptable.
- **Spread start times** (jitter, hashed minutes) to avoid everyone running at :00 and overloading shared systems.
- Monitor for missed runs, overruns (job still running at next start), and failures.

## Review checklist

- [ ] RPO/RTO defined per dataset; backups meet them?
- [ ] Backups in separate failure + administrative domain; retention covers slow corruption?
- [ ] Soft-delete / undo for user-facing deletions?
- [ ] Automated, end-to-end restore tests with alerting?
- [ ] Out-of-band data validation running?
- [ ] Pipeline stages idempotent, atomic outputs, freshness/correctness SLOs?
- [ ] Scheduled jobs survive scheduler failure without skipping or double-running?

## Sources

- SRE book ch. 24 Distributed Periodic Scheduling with Cron — https://sre.google/sre-book/distributed-periodic-scheduling/
- SRE book ch. 25 Data Processing Pipelines — https://sre.google/sre-book/data-processing-pipelines/
- SRE book ch. 26 Data Integrity — https://sre.google/sre-book/data-integrity/
- Workbook ch. 13 Data Processing Pipelines — https://sre.google/workbook/data-processing/
