Community研究&データ分析github.com

Unknown-333/designing-backfills-and-replays

安全なデータバックフィルとリプレイ(べき等な過去データの再処理、パーティションごとの実行、プロダクションとの分離、結果検証、二重計上や履歴変更の防止)を計画・実行します。新規モデルのバックフィル、バグ修正後の再処理、イベントリプレイ、既存データを破損させずに新しいパイプラインに履歴をロードする際に使用します。

designing-backfills-and-replays とは?

このスキルは、データエンジニアリングにおいて最もリスクの高い操作の一つであるバックフィル(過去データの再処理)とリプレイを、安全かつ反復可能な方法で計画・実行するためのガイドラインを提供します。バックフィルは非べき等な処理ではデータの重複や破損を引き起こすため、まず変換処理のべき等性を確認することが前提です。具体的なワークフローとして、適切なウィンドウとパーティション粒度の定義、1パーティションのドライランによる検証、パーティションごとのバウンド並列実行、プロダクションとのコンピュート分離、そして結果の検証と通常スケジュールへの復帰までの手順を示しています。特にAirflowやdbtといった一般的なツールでの実践パターンや、非べき等ジョブのバックフィル、巨大な単一ジョブ、プロダクションコンピュートの共有といった落とし穴についても詳しく解説しており、データパイプラインの信頼性を高めたい全てのデータエンジニアにとって有用なスキルです。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Unknown-333/awesome-data-engineering-skills/tree/main/skills/designing-backfills-and-replays

Installed? Explore more 研究&データ分析 skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

バックフィルとリプレイの設計

いつ使用するか

  • 新しいモデル/パイプラインの履歴をロードする場合。
  • 変換バグを修正した後、過去のウィンドウを再処理する場合。
  • イベントをリプレイしたり、生データからテーブルを再導出する場合。
  • 通常のインクリメンタル実行には使用しないでください(building-dbt-models / authoring-airflow-dags を使用してください)。

なぜ注意が必要か

バックフィルはデータエンジニアリングにおける最も危険な定期操作です。履歴を書き換えます。誤った方法で行うと、二重計上、昨日の数値の変更、プロダクションの過負荷を引き起こします。正しく行えば、退屈で反復可能な作業になります。前提条件はべき等性です(writing-idempotent-transformations を参照)。

ワークフロー

- [ ] バックフィル前に変換がべき等であることを確認する(再実行 == 1回の実行)
- [ ] 正確なウィンドウとパーティション粒度を定義する
- [ ] 1つのパーティションでドライランを実行し、カウント/合計をソースと検証する
- [ ] 一度に全てを実行するのではなく、パーティションごとに(バウンド並列性で)実行する
- [ ] バックフィルコンピュートをプロダクションワークロードから分離する
- [ ] 合計を検証して調整し、通常のスケジューリングを再開する
  1. まずべき等性を証明する。 ウィンドウの再実行で結果が変わる可能性がある場合は、履歴に触れる前にそれを修正してください。非べき等ジョブをバックフィルするとデータが増殖します。
  2. 範囲を正確に定義する。 正確な開始日/終了日とパーティション単位(日/時間/地域)を指定します。
  3. 1つのパーティションでドライランを実行し、スケールアウト前にソースと照合します。
  4. 実行をチャンクに分割する。 監視、一時停止、再開ができるように、パーティションをバウンドバッチで処理します。巨大な単一のバウンドなしジョブは避けてください。
  5. コンピュートを分離する。 別のウェアハウス/クラスター/プールを使用して、バックフィルがプロダクションのSLAを枯渇させないようにします。
  6. 検証して再開する。 バックフィル範囲全体の合計を調整し、通常のスケジュールに戻します。

パターン

べき等なパーティションごとのバックフィル — 各パーティションの上書きは独立しており、再試行しても安全です。

# バウンド並列性、1日ずつ処理。各日は自身のパーティションを上書きします。
for day in $(seq_dates 2026-01-01 2026-01-31); do
  run_transform --run-date "$day"   # その日のみの delete-insert / MERGE
done

Airflow — catchup/backfill はインターバルを再実行します。タスクがべき等でデータインターバルによってパラメータ化されている場合のみ安全です。dbt — インクリメンタルモデルを対象ウィンドウにフィルターするか、バウンドウィンドウで --full-refresh を実行します。

分離とスロットル — 専用のウェアハウス/クラスターと同時実行数の上限を設定し、バックフィルがライブダッシュボードを劣化させないようにします。

よくある落とし穴

  • 非べき等ジョブのバックフィル — 重複や合計値の変動を引き起こします。まずべき等にしてください。
  • 巨大な単一のバウンドなしジョブ — 監視や再開ができず、プロダクションを過負荷にします。パーティションごとに実行してください。
  • プロダクションコンピュートの共有 — バックフィルは負荷を急増させ、SLAを破綻させます。分離してください。
  • 検証なし — 成功を前提としないでください。範囲全体のカウント/合計を調整してください。
  • バックフィル途中でのロジック変更 — 履歴に不整合が生じます。実行全体でコードバージョンを固定してください。
  • ダウンストリームを忘れる — 基本テーブルをバックフィルしても、依存するマート/集計を更新しなければ、それらは不整合のまま残ります。

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

Unknown-333/authoring-airflow-dags

Write production-grade Apache Airflow DAGs using the TaskFlow API — idempotent tasks, correct scheduling and catchup, retries/SLAs, connections/variables, and avoiding top-level code. Use when creating or reviewing Airflow DAGs, scheduling pipelines, wiring task dependencies, configuring retries/backfills, or fixing non-idempotent tasks.

Unknown-333/building-dagster-assets

Build Dagster pipelines using software-defined assets — asset dependencies, partitions, resources and IO managers, asset checks, and schedules/sensors. Use when creating Dagster assets or jobs, modeling data as assets, adding partitions or backfills, wiring resources/IO managers, or migrating from task-based orchestration to assets.

Unknown-333/building-dbt-models

Build well-structured dbt models — staging/intermediate/marts layers, ref() and source(), materializations, and incremental models with the right strategy. Use when creating or refactoring dbt models, choosing table vs view vs incremental, structuring a dbt project, or writing incremental logic.

Unknown-333/building-feature-pipelines

Build ML feature pipelines and feature stores — point-in-time-correct joins to avoid label leakage, offline/online parity, feature freshness and backfills, and materialization with tools like Feast. Use when engineering features for ML, preventing train/serve skew or data leakage, building a feature store, or backfilling historical features for training.

Unknown-333/building-iceberg-tables

Design and operate Apache Iceberg tables — partitioning and hidden partitioning, partition/schema evolution, snapshots and time travel, compaction and small-file cleanup, and MERGE/upsert for lakehouse tables on Spark, Flink, Trino, or Snowflake. Use when creating or maintaining Iceberg tables, choosing partitioning, evolving schema/partitions, or fixing small-file and metadata bloat.

Unknown-333/building-ingestion-pipelines

Build batch and incremental data ingestion (extract-load) pipelines — full vs incremental extraction, change data capture (CDC), watermarks and high-water marks, API pagination and rate limits, and choosing managed EL tools (Fivetran, Airbyte) vs custom code. Use when ingesting data from databases, APIs, files, or SaaS into a warehouse/lake, or designing incremental extraction and CDC.

Unknown-333/building-kafka-consumers

Build reliable Apache Kafka consumers and producers — consumer groups and partition assignment, offset commit strategy, at-least-once vs exactly-once, idempotent/transactional producers, rebalancing, and dead-letter handling. Use when writing Kafka consumers/producers, configuring offset commits or consumer groups, tuning throughput, or handling rebalances and poison messages.

Unknown-333/debugging-data-pipelines

Systematically root-cause data pipeline failures and data incidents — job errors, wrong or missing data, duplicates, and freshness misses — by tracing lineage upstream, isolating the failing stage, reconciling against source, and planning a safe fix and backfill. Use when a pipeline fails, numbers look wrong, data is missing or duplicated, a dashboard is stale, or a stakeholder reports a data discrepancy.

Unknown-333/designing-data-contracts

Define and enforce data contracts between producers and consumers — explicit schema, semantics, ownership, SLAs, and versioning — to prevent silent upstream changes from breaking downstream pipelines. Use when a producer schema change could break consumers, defining an interface between teams/services and the warehouse, or adding schema enforcement at ingestion.

関連スキル