fix: prevent duplicate feed entries on repeated trail/list activities#1052
Open
Guacam-Ole wants to merge 1 commit into
Open
fix: prevent duplicate feed entries on repeated trail/list activities#1052Guacam-Ole wants to merge 1 commit into
Guacam-Ole wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
InsertIntoFeed(db/util/feed.go) inserts a newfeedrow on every call without checking whether the(actor, item)pair already exists.On current
mainthis is reachable through the inbox:processCreateOrUpdateTrailActivityandprocessCreateOrUpdateListActivitycallInsertIntoFeedunconditionally, so every inboundUpdateactivity 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.