Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction - Can't import data. #4270

@ioogithub

Description

@ioogithub

Description

Getting database deadlocks when trying to import a catalog.

Describe the bug

To reproduce

Steps to reproduce the behavior:

  1. Go to /var/www/bin/cli run:updateCatalog -a
  2. wait and watch the debg log

Expected behavior

Environment

  • Ampache version: 7.7.1 (docker image)
  • Server operating system: ubuntu 24.04
  • Client operating system: ubuntu 24.04

Client type

  • Web
  • Ampache

Logs

2025-09-12T15:47:47+00:00 [admin] (Ampache\Module\System\Dba) -> Error_query SQL: UPDATE `album_disk`, (SELECT COUNT(DISTINCT `id`) AS `song_count`, `album`, `disk` FROM `song` WHERE `song`.`album` = ? GROUP BY `album`, `disk`) AS `song` SET `album_disk`.`song_count` = `song`.`song_count` WHERE `album_disk`.`song_count` != `song`.`song_count` AND `album_disk`.`album_id` = `song`.`album` AND `album_disk`.`disk` = `song`.`disk`; [0]
2025-09-12T15:47:47+00:00 [admin] (Ampache\Module\System\Dba) -> Error_query MSG: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

Notes

At first I tried creating a catalog using the UI but I immediately got deadlocks. The end result is a butchered database, many items duplicated- the same track up to 50x, albums split, some albums with hundreds of tracks etc. Many albums with 1 track.

I found this unresolved issue: #3905. It looks like the UI is currently not able to create new cataogs. The work around was to use the CLI tools but unfortunately I get the same errors: /var/www/bin/cli run:updateCatalog -a quickly results in the same deadlock issues. Unlike the previous bug report "/var/www/bin/cli run:updateCatalog -t" does not fix the situation. Once the deadlock issues start pouring into the log it is basically game over. lachlan-00 or any active or new users, is there any work around for this issue? Do you know the root cause of why the catalog is deadlocking the database?

If I can't get my data into the database I can't se Ampache. I have run into so many major issues over the past week, searching is not working, writing is not working, corner cases where the catalog is deleting id3 frames (currently running without write_tags due to this issue), is Ampache currently in a state where new users can import their data and start using it? How can I get past this deaklock issue and actually get the data into Ampache. Please advise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions