Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Make dual-write log failed v2 copies instead of returning HTTP 503

クローズ
#3,958 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

関連するプルリクエストがすでにマージされています。

  • #3959 @anth-volk による — マージ済み

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
fastapi, postgresql, python, supabase

調査の方向性

Start with mirror_policy_after_commit and the policy, saved-policy, and household mirroring services; trace how failures reach the API routes after the v1 commit. Check the Stage 10 and Stage 11 migration docs for their failure sections. Done means post-commit copy failures are logged and return the normal v1 response, invalid selectors still return HTTP 503, and the migration docs describe the behavior.

索引モデルが issue の本文から書いたものです。

説明

Problem

With DB_WRITE_POLICY or DB_WRITE_HOUSEHOLD set to dual_write, the Public API copies each committed v1 policy, saved policy and household into Supabase in the same request. If that copy fails, the route returns HTTP 503, even though the v1 write has already committed:

  • mirror_policy_after_commit raises on any failure, including a Supabase outage, a policy the v2 catalog cannot translate (PolicyCatalogValidationError, LegacyPolicyTranslationError) and a missing catalog version (MetadataCatalogVersionNotFoundError). A retry repeats a translation failure, so that reform can never be saved.
  • A failed household copy also returns 503, and a retried POST creates a second v1 household row.

Policy writes happen on every reform save and every report run, so turning dual-write on in production would let any copy failure block users.

Proposed change

Make dual-write fail open: when the copy fails after the v1 commit, log the failure and return the normal v1 response.

  • Keep the mirroring services' existing behavior: log the failure with its metric (v1_policy_mirror_operations, v1_user_policy_mirror_operations, v1_household_mirror_operations) and failure_category, and leave saved-policy and household events pending.
  • Log the cases the services never see (no snapshot, revision or event to copy, or an unexpected error outside the service) with the same metrics.
  • Keep HTTP 503 for invalid database selectors, which are rejected before anything is written.
  • Update the failure sections of the Stage 10 and Stage 11 migration docs.

This is needed before dual-write is turned on in production.

主要言語
Python
スター
18
フォーク
33
平均マージ
2日 18時間
マージ済み PR(30日)
36

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PolicyEngine/policyengine-api のほかの issue

PolicyEngine/policyengine-api の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。