[bug] user_follows_hashtag_hashtag_id_fkey error on running prune_objects tasks #868

Closed
opened 2025-01-08 18:22:05 +00:00 by SukinoVerse · 2 comments

Your setup

OTP

Extra details

Debian 12

Version

2025.01,7cc6c35

PostgreSQL version

14

What were you trying to do?

I'm running database maintenance tasks with

su akkoma -s $SHELL -lc "./bin/pleroma_ctl database prune_objects"

What did you expect to happen?

The tasks should be success without any error

What actually happened?

I've got this error

18:18:50.222 [debug] QUERY ERROR db=8783.8ms queue=3.6ms idle=34.0ms
DELETE FROM hashtags AS ht
WHERE NOT EXISTS (
  SELECT 1 FROM hashtags_objects hto
  WHERE ht.id = hto.hashtag_id)
 []
** (Postgrex.Error) ERROR 23503 (foreign_key_violation) update or delete on table "hashtags" violates foreign key constraint "user_follows_hashtag_hashtag_id_fkey" on table "user_follows_hashtag"

    table: user_follows_hashtag
    constraint: user_follows_hashtag_hashtag_id_fkey

Key (id)=(1515945) is still referenced from table "user_follows_hashtag".
    lib/ecto/adapters/sql.ex:1047: Ecto.Adapters.SQL.raise_sql_call_error/1
    lib/mix/tasks/pleroma/database.ex:351: Mix.Tasks.Pleroma.Database.run/1
    nofile:1: (file)
    (stdlib 5.0.2) erl_eval.erl:750: :erl_eval.do_apply/7
    (elixir 1.15.4) lib/code.ex:543: Code.validated_eval_string/3

Logs

No response

Severity

I can manage

Have you searched for this issue?

  • I have double-checked and have not found this issue mentioned anywhere.
### Your setup OTP ### Extra details Debian 12 ### Version 2025.01,7cc6c35 ### PostgreSQL version 14 ### What were you trying to do? I'm running database maintenance tasks with ``` su akkoma -s $SHELL -lc "./bin/pleroma_ctl database prune_objects" ``` ### What did you expect to happen? The tasks should be success without any error ### What actually happened? I've got this error ``` 18:18:50.222 [debug] QUERY ERROR db=8783.8ms queue=3.6ms idle=34.0ms DELETE FROM hashtags AS ht WHERE NOT EXISTS ( SELECT 1 FROM hashtags_objects hto WHERE ht.id = hto.hashtag_id) [] ** (Postgrex.Error) ERROR 23503 (foreign_key_violation) update or delete on table "hashtags" violates foreign key constraint "user_follows_hashtag_hashtag_id_fkey" on table "user_follows_hashtag" table: user_follows_hashtag constraint: user_follows_hashtag_hashtag_id_fkey Key (id)=(1515945) is still referenced from table "user_follows_hashtag". lib/ecto/adapters/sql.ex:1047: Ecto.Adapters.SQL.raise_sql_call_error/1 lib/mix/tasks/pleroma/database.ex:351: Mix.Tasks.Pleroma.Database.run/1 nofile:1: (file) (stdlib 5.0.2) erl_eval.erl:750: :erl_eval.do_apply/7 (elixir 1.15.4) lib/code.ex:543: Code.validated_eval_string/3 ``` ### Logs _No response_ ### Severity I can manage ### Have you searched for this issue? - [x] I have double-checked and have not found this issue mentioned anywhere.
SukinoVerse added the
bug
label 2025-01-08 18:22:05 +00:00
Member

Version: 2025.01,7cc6c35

The indicated commit does not exist in upstream.
The bug was already fixed in upstream 2025.01 and the failing query no longer exists in this version; please ensure you actually use the upstream release and no interfering local patches. While at it, best also upgrade to 2025.01.01.

The current query is:

DELETE FROM hashtags
USING hashtags AS ht
LEFT JOIN hashtags_objects hto
ON ht.id = hto.hashtag_id
LEFT JOIN user_follows_hashtag ufht
ON ht.id = ufht.hashtag_id
WHERE
hashtags.id = ht.id
AND hto.hashtag_id is NULL
AND ufht.hashtag_id is NULL

> Version: 2025.01,7cc6c35 The indicated commit does not exist in upstream. The bug was already fixed in upstream 2025.01 and the failing query no longer exists in this version; please ensure you actually use the upstream release and no interfering local patches. While at it, best also upgrade to 2025.01.01. The current query is: https://akkoma.dev/AkkomaGang/akkoma/src/commit/ad92e504d773e6bbeaee5a2ed47154a021ec66ed/lib/mix/tasks/pleroma/database.ex#L346-L355
Author

@Oneric Thank you~ I didn't notice that there is a newer version released. just updated and it work fine 🙏

@Oneric Thank you~ I didn't notice that there is a newer version released. just updated and it work fine 🙏
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: AkkomaGang/akkoma#868
No description provided.