Skip to content

Resolve activity feed inconsistency

What does this MR do?

Currently in some cases there is an inconsistency between the HTML version of the activity page (https://your.gitlab.tld/dashboard/activity) and the ATOM feed of the latest activities of a given user, which is provided under https://your.gitlab.tld/dashboard/projects.atom?feed_token=secret. The ATOM feed does not contain the top 20 latest activties. It is possible that the feed will not contain any latest events of certain projects.

The MR fixes this bug by skipping a LIMIT clause in a subquery when collecting the 20 latest activities for a given user. This guarantees that all non-public projects of the current user are considered when collection the latest events.

The generated SQL statement to get the latest activties (in EventCollection, method relation_with_join_lateral) is:

SELECT  "events".* 
FROM 
   (SELECT  "projects"."id" 
    FROM "projects" INNER JOIN "project_authorizations" ON "projects"."id" = "project_authorizations"."project_id" 
    WHERE "project_authorizations"."user_id" = 32 AND "projects"."archived" = 'f' 
    LIMIT 20
    OFFSET 0) projects_for_lateral
JOIN LATERAL 
    (SELECT  "events".* FROM "events" WHERE (events.project_id = projects_for_lateral.id)  ORDER BY "events"."id" DESC LIMIT 20) AS events 
ON true
ORDER BY "events"."id"  DESC
LIMIT 20
OFFSET 0

Due to the first LIMIT clause (in the first subselect) some projects might not be considered when collecting the latest events. The MR removes this LIMIT clause. Maybe even the OFFSET clause can be removed, but I'm not sure if there are any side effects since EventCollection is used in other contexts as well.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/52113

Edited by Rémy Coutable

Merge request reports