🐛 Bug Report: Jobs worker stores its dedupe markers (`jobs-event-*`) in Redis without TTL

オープン 初心者向け
#15,746 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php, redis
領域
backend, databases

調査の方向性

src/Appwrite/Platform/Modules/Functions/Workers/Jobs.phpを読み、特に180、255、296行目付近のマーカーの確認と保存を確認してください。両方のマーカーを保存するときに既存のDEDUPE_TTLを渡し、その後、3600秒後にRedisがそれらを削除することを確認してください。issueには、古いマーカーキーが残る可能性も記されています。テストファイルは指定されていないため、近くにあるworkerまたはcacheのテストを調べ、適切な確認箇所を見つけてください。

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

説明

In short: The jobs worker reads its dedupe markers with a 3600 s TTL but writes them without one, so Redis keeps every marker forever.

Impact:

  • One Redis hash per build callback that is never removed: about 360 000 after five weeks on our instance.
  • With the default allkeys-lru they compete with the cache and queued jobs for memory (see #14084).
👟 Reproduction steps
  1. Self-hosted Appwrite 2.7.2, deploy functions or sites for a while.

  2. Count the markers and check their TTL:

    docker exec appwrite-redis redis-cli --scan --pattern 'jobs-event-*' | wc -l
    docker exec appwrite-redis redis-cli ttl "$(docker exec appwrite-redis redis-cli --scan --pattern 'jobs-event-*' | head -1)"
    
👍 Expected behavior

A marker is removed by Redis after DEDUPE_TTL (3600 s), the window in which the worker uses it.

👎 Actual Behavior

The count only grows, every marker has TTL -1.

Cause: the worker checks a marker with $cache->load($key, self::DEDUPE_TTL) (Jobs.php L180) but stores it with $cache->save($key, true) (L255, L296). The Redis cache adapter only sets EXPIRE when save() gets a TTL; otherwise the envelope only expires logically when it is read. Keys in the format before 2.6.2 (jobs-event-<eventId>, without the project sequence) are never read again and stay as well.

Why it matters: each marker is a small hash (≈ 400 B), but there is one per log, artifact, exit and complete callback of every build. They are never read after an hour, yet they count against maxmemory like the cache and the queues that share the same Redis.

We found no open issue or PR about this.

🎲 Appwrite version

2.7.3 (measured on 2.7.2, code unchanged in 2.7.3)

💻 Operating system

Linux (Ubuntu 26.04), Docker

🧱 Your Environment

Self-hosted, Redis 7.4 with --maxmemory-policy allkeys-lru, shared by cache and queues as in the official compose file.

💡 Suggested fix
  • Pass the TTL when saving: $cache->save($key, true, ttl: self::DEDUPE_TTL) at both places.
  • Existing installations keep their old markers; a note in the release (or a one-off cleanup in the migration) would help.
👀 Have you spent some time to check if this issue has been raised before?
  • I checked and didn't find a similar issue
🏢 Have you read the Code of Conduct?
  • I have read the Code of Conduct
主要言語
TypeScript
スター
57.9k
フォーク
5.8k
平均マージ
16時間 1分
マージ済み PR(30日)
768

環境構築

はじめの一歩

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

appwrite/appwrite のほかの issue

appwrite/appwrite の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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