Skip to content

fix: prevent duplicate feed entries on repeated trail/list activities#1052

Open
Guacam-Ole wants to merge 1 commit into
open-wanderer:mainfrom
Guacam-Ole:fix/feed-duplicate-entries
Open

fix: prevent duplicate feed entries on repeated trail/list activities#1052
Guacam-Ole wants to merge 1 commit into
open-wanderer:mainfrom
Guacam-Ole:fix/feed-duplicate-entries

Conversation

@Guacam-Ole

@Guacam-Ole Guacam-Ole commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Problem

InsertIntoFeed (db/util/feed.go) inserts a new feed row on every call without checking whether the (actor, item) pair already exists.

On current main this is reachable through the inbox: processCreateOrUpdateTrailActivity and processCreateOrUpdateListActivity call InsertIntoFeed unconditionally, so every inbound Update activity for an already-known remote trail/list appends another copy of the same feed entry for each local follower. Long-running instances following active remote authors accumulate duplicates steadily; the feed endpoint then has to page over them on every home-page load.

This is a followup to the fixed #1044 fixed issue. The fix works, but we still have a single duplicate each time. (#1044 fixes the main issue of an infinite loop. this PR just takes care of the rest)

Fix

If a feed entry for the same (actor, item) pair already exists, return the existing record instead of inserting a duplicate. One file changed, no behaviour change for first-time inserts.

InsertIntoFeed inserted a new feed row on every call. Inbound Update
activities for an already-known item (and, before the IsLocalIRI guard,
the self-delivery loop) therefore filled the feed table with duplicates
— on one affected instance 2.89M duplicate rows, which made the feed
endpoint time out and slowed the start page noticeably.

Skip the insert when the (actor, item) pair already has a feed entry
and return the existing record instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Guacam-Ole Guacam-Ole closed this Jun 7, 2026
@Guacam-Ole Guacam-Ole reopened this Jun 7, 2026
@Guacam-Ole Guacam-Ole marked this pull request as ready for review June 8, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant