Skip to content

[Worker] 外部API・DB操作にリトライロジックを追加 #175

Description

@wisteriahuman

Tracked by #173

優先度: 中

※ 2重実行問題(#178)の解消により優先度を「高→中」に変更。API/DB呼び出し2倍による過負荷が主因だったため、根本原因解消後はリトライの緊急性が低下。

概要

Gemini API呼び出しやDB操作が一時的なエラーで失敗した場合、リトライせずに即座に失敗扱いとなる。

発生したエラー

00:10:05 ERROR Failed to process user { userProfileId: "94239ca7-..." }
  └─ Error: exception TypeError: fetch failed sending request
     at generateImage (apps/worker/src/tasks/daily-update.ts:118)

00:10:52 ERROR Failed to process user { userProfileId: "a17faf67-..." }
  └─ Error: Failed query: insert into "weekly_worlds" ...
     at PostgresJsPreparedQuery.queryWithCache

対応案

  1. 指数バックオフによるリトライ(最大3回、初回1秒→2秒→4秒)
  2. リトライ対象:
    • Gemini API呼び出し (generateImage)
    • OpenAI API呼び出し (generateSceneDescription)
    • DB INSERT/UPDATE操作

関連ファイル

  • apps/worker/src/tasks/daily-update.ts
  • apps/worker/src/tasks/weekly-reset.ts
  • apps/worker/src/lib/infra/weekly-world.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend(worker)apps/worker の実装chore開発環境の改善、依存関係の更新

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions