owncloud / music

:notes: Music app for ownCloud
GNU Affero General Public License v3.0
570 stars 199 forks source link

duplicate key value violates unique constraint "music_cache_index" #1135

Closed slimshizn closed 7 months ago

slimshizn commented 8 months ago

Trying out the app, need some assistance to fix. Thank you.

Postgres logs:

2024-03-14 23:56:13.743 GMT [7092] ERROR: duplicate key value violates unique constraint "music_cache_index"

2024-03-14 23:56:13.743 GMT [7092] DETAIL: Key (user_id, key)=(myusername, cover_access_token) already exists.

2024-03-14 23:56:13.743 GMT [7092] STATEMENT: INSERT INTO "oc_music_cache"

                ("user_id", "key", "data") VALUES ($1, $2, $3)

Nextcloud Music app error screenshot

firefox_2024-03-14_20-00-57

Nextcloud Logs

{"reqId":"JbJDkdwsa5N6o4E7fKNb","level":3,"time":"2024-03-15T00:00:09+00:00","remoteAddr":"37.120.157.148","user":"myusername","app":"PHP","method":"GET","url":"/index.phpc/api/scanstate","message":"Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) at /var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Result.php#119","userAgent":"Mozilla/5.0 (Windows NT 10.0; rv:123.0) Gecko/20100101 Firefox/123.0","version":"28.0.3.2","data":{"app":"PHP"},"id":"65f38f9983b3e"}

paulijar commented 8 months ago

My best guess is that the error in the Postgres log is not related to your actual problem of failing to check for new audio files. The oc_music_cache table is intentionally used so that we first try to insert a new entry with some key, and if that fails because the entry already exists, then we update the existing entry instead. Apparently pgsql now logs this first failed attempt as an error.

What's shown in the Nextcloud log is that the PHP memory quota of 512 MB runs out while trying to check if there are unscanned audio files. You could try to increase the quota in php.ini, but 512 MB is already rather large allocation so it's a surprise that this isn't enough. Do you have a humongous amount of audio files on your Nextcloud account and are all of those such that you wish to see them in the Music app? If some of your audio files are not intended to be shown in Music, then you should set the music library path and/or excluded paths in the Settings view so that they will not be scanned.

Also, please specify the versions of Music and Nextcloud used.

paulijar commented 8 months ago

So were you able to test, if increasing the memory limit would help? The name of the setting within php.ini is memory_limit.

paulijar commented 7 months ago

With no more information, I assume that this could be fixed by increasing the memory quota. Closing.