Skip to main content
← Back to list
01Issue
BugOpenSwamp Club
AssigneesNone

Relationships

#958 feed_post_score_events queue grows unboundedly (no TTL, no delete-on-delivery)

Opened by keeb · 7/4/2026

Description

The `feed_post_score_events` queue collection (`lib/infrastructure/mongo-feed-post-score-queue.ts`) never removes terminal documents: `markDelivered` sets `status: "delivered"` and `markFailed` parks docs at `attempts >= 5`, but nothing deletes them and `ensureIndexes` creates no TTL index. Every approved feed post adds a doc that lives forever.

This is the same anti-pattern #925 fixed on the score-refresh queue (`swamp_club_events\ now deletes on delivery with a 7d TTL backstop, \mongo-event-queue.ts`), and PR #818's performance review caught and fixed it for the new `system_message_events` queue before it shipped. `feed_post_score_events` is now the only queue left with unbounded growth.

Steps to reproduce

  1. Approve feed posts over time (telemetry ScoringConsumer publishes one doc per approval).
  2. Observe `db.feed_post_score_events.countDocuments({status: "delivered"})` only ever grows; storage + `(status, createdAt)` index size grow without bound.

Expected

Terminal docs expire. Fix mirrors #925 / PR #818: add a 7d TTL index on `createdAt` in `ensureIndexes` (`expireAfterSeconds: 7 * 24 * 60 * 60`, name `ttl_7d`). Safe because delivery is idempotent downstream — the score contribution is the deterministic `content:feed-post:` grant, so expiring queue history loses nothing durable.

Environment

Prod (DOKS + Atlas), all versions since the queue was introduced.

02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED

Open

7/4/2026, 5:58:25 AM

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.