While logged-in if I browse my profile, It will causes a request to be made to /api/v1/accounts/1/statuses?with_muted=true&exclude_replies=1&limit=20
which ends up failing in 502 because akkoma took too long to reply (I did add a few proxy_*_timeout
to 2400 to nginx and same problem).
However, if I do that call while using private mode in firefox, or curl, it works and returns in 2/3s !
When the request fails while logged-in, I get the following in my postgresql log:
2022-12-05 20:17:32.181 CET [4137675] pleroma@pleroma ERROR: canceling statement due to user request
2022-12-05 20:17:32.181 CET [4137675] pleroma@pleroma CONTEXT: SQL statement "SELECT array_agg(following.follower_address) FROM following_relationships
JOIN users ON users.id = following_relationships.follower_id
JOIN users AS following ON following.id = following_relationships.following_id
WHERE users.ap_id = actor"
PL/pgSQL function thread_visibility(character varying,character varying,character varying) line 11 at SQL statement
2022-12-05 20:17:32.181 CET [4137675] pleroma@pleroma STATEMENT: SELECT a0."id", a0."data", a0."local", a0."actor", a0."recipients", a0."inserted_at", a0."updated_at", b2."id", b2."user_id", b2."activity_id", b2."inserted_at", b2."updated_at", o1."id", o1."data", o1."inserted_at", o1."updated_at", NOT (t3."id" IS NULL) FROM "activities" AS a0 INNER JOIN "objects" AS o1 ON (o1."data"->>'id') = COALESCE(a0."data"->'object'->>'id', a0."data"->>'object') LEFT OUTER JOIN "bookmarks" AS b2 ON (b2."user_id" = $1) AND (b2."activity_id" = a0."id") LEFT OUTER JOIN "thread_mutes" AS t3 ON (t3."user_id" = $2) AND (t3."context" = a0."data"->>'context') INNER JOIN LATERAL (SELECT is_active from users WHERE ap_id = a0."actor" AND is_active = TRUE) AS f4 ON TRUE WHERE ((($3 && a0."recipients")) OR (a0."actor" = $4)) AND (o1."data"->>'inReplyTo' is null) AND (a0."actor" = $5) AND (a0."data"->>'type' = ANY($6)) AND (not (a0."actor" = ANY($7))) AND (((not (a0."recipients" && $8)) or a0."actor" = $9)) AND ((recipients_contain_blocked_domains(a0."recipients", $10) = false) or a0."actor" = $11) AND (not (a0."data"->>'type' = 'Announce' and a0."data"->'to' ?| $12)) AND ((not (split_part(a0."actor", '/', 3) = ANY($13))) or a0."actor" = ANY($14)) AND ((not (split_part(o1."data"->>'actor', '/', 3) = ANY($15))) or (o1."data"->>'actor') = ANY($16)) AND (thread_visibility($17, (a0."data")->>'id', $18) = true) AND (not ( a0."data"->>'type' = 'Announce' and a0."actor" = ANY($19))) AND (not(o1."data"->>'type' = 'Answer')) AND (NOT (a0."actor" = ANY($20))) ORDER BY a0."id" desc nulls last LIMIT $21
Idk if useful, but in my akkoma config for postgres I have:
pool_size: 50,
queue_target: 5000,
timeout: 120000,
prepare: :named,
parameters: [
plan_cache_mode: "force_custom_plan"
]
First two ones are from the pleroma era and db issues, the timeout has been added in hope to “fix” the long response, without success. The whole DB has been reimported a few days ago so indexes are “fresh”.
Any ideas how to debug that ? I am on latest stable, and that was previously a pleroma I’ve been using since 2018 for an idea of the mess the database contains.