Skip to content

[Bug]: store: unable to cleanup entries: pq: deadlock detected #3853

@michaelkuhn

Description

@michaelkuhn

Bug Summary

Cleaning up removed entries failed during normal operation

Description

I noticed the following log entries today while updating to 2.2.14 (the entries are from before the update):

Oct 25 12:13:34 host miniflux[1534]: level=ERROR msg="Unable to cleanup removed entries" user_id=1 feed_id=209 error="store: unable to cleanup entries: pq: deadlock detected"
Oct 25 12:13:34 host miniflux[1534]: level=INFO msg="Clearing content from removed entries completed" removed_entries_content_cleared=2420

The PostgreSQL log during the same timeframe contains the following:

2025-10-25 12:13:34.019 CEST [163325] ERROR:  deadlock detected
2025-10-25 12:13:34.019 CEST [163325] DETAIL:  Process 163325 waits for ShareLock on transaction 468296164; blocked by process 163310.
        Process 163310 waits for ShareLock on transaction 468296234; blocked by process 163325.
        Process 163325: 
                        DELETE FROM
                                entries
                        WHERE
                                feed_id=$1 AND
                                status=$2 AND
                                NOT (hash=ANY($3))
                
        Process 163310: 
                        UPDATE
                                entries
                        SET
                                title='',
                                content=NULL,
                                url='',
                                author=NULL,
                                comments_url=NULL,
                                document_vectors=NULL
                        WHERE id IN (
                                SELECT id
                                FROM entries
                                WHERE status = $1 AND content IS NOT NULL
                                ORDER BY id ASC
                                LIMIT $2
                        )
                
2025-10-25 12:13:34.019 CEST [163325] HINT:  See server log for query details.
2025-10-25 12:13:34.019 CEST [163325] CONTEXT:  while deleting tuple (2467,6) in relation "entries"
2025-10-25 12:13:34.019 CEST [163325] STATEMENT:  
                        DELETE FROM
                                entries
                        WHERE
                                feed_id=$1 AND
                                status=$2 AND
                                NOT (hash=ANY($3))
                

Steps to Reproduce

No idea, sorry

Expected Behavior

No deadlock should occur

Actual Behavior

A deadlock occurs

Version

2.2.13

Browser

No response

Relevant Logs or Error Output

Additional Context

No response

Checklist

  • I have searched existing issues to ensure this bug hasn't been reported before.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions