music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.31k stars 47 forks source link

Add-on won't start after 2.2.0b7 - Database migration error #2768

Closed harryfine closed 2 weeks ago

harryfine commented 3 weeks ago

What version of Music Assistant has the issue?

2.2.0b7

What version of the Home Assistant Integration have you got installed?

2024.8.0

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

The problem

Updated today to the newest add-on. Went to start music assistant and got the error in Screenshot_2024-08-16-17-48-04-903_io homeassistant companion android screenshot

How to reproduce

Every time I try to start music assistant it fails and this happens. I have tried shutting down and restarting the add-on. I have tried rebooting. The add-on shows as running.

Music Providers

Tidal and local library

Player Providers

Sonos

Full log output

Could not start music assistant so I could not go into the settings. The add-on log showed the following:

RuntimeError: Database migration failed 2024-08-16 17:15:39.679 WARNING (MainThread) [aiorun] Stopping the loop 2024-08-16 17:15:39.679 INFO (MainThread) [aiorun] Entering shutdown phase. 2024-08-16 17:15:39.679 INFO (MainThread) [aiorun] Executing provided shutdown_callback. 2024-08-16 17:15:39.680 INFO (MainThread) [root] shutdown requested! 2024-08-16 17:15:39.680 INFO (MainThread) [music_assistant] Stop called, cleaning up... 2024-08-16 17:15:39.680 INFO (MainThread) [aiorun] Waiting for executor shutdown. 2024-08-16 17:15:39.680 INFO (MainThread) [aiorun] Shutting down async generators 2024-08-16 17:15:39.681 INFO (MainThread) [aiorun] Closing the loop. 2024-08-16 17:15:39.682 INFO (MainThread) [aiorun] Leaving. Bye! 2024-08-16 17:15:39.682 INFO (MainThread) [aiorun] Reraising unhandled exception 2024-08-16 17:15:39.682 ERROR (MainThread) [root] Uncaught exception Traceback (most recent call last): File "/usr/local/bin/mass", line 8, in sys.exit(main()) ^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/main.py", line 214, in main run( File "/usr/local/lib/python3.12/site-packages/aiorun.py", line 370, in run raise pending_exception_to_raise File "/usr/local/lib/python3.12/site-packages/aiorun.py", line 272, in run shutdown_callback(loop) File "/usr/local/lib/python3.12/site-packages/music_assistant/main.py", line 204, in on_shutdown loop.run_until_complete(mass.stop()) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/server.py", line 177, in stop await self.streams.close() File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/streams.py", line 219, in close await self._server.close() File "/usr/local/lib/python3.12/site-packages/music_assistant/server/helpers/webserver.py", line 87, in close await self._tcp_site.stop() ^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'stop' 2024-08-16 17:15:50.618 INFO (MainThread) [music_assistant] Starting Music Assistant Server (22090b6ae192488d87efb96c0acacc83) version 2.2.0b7 - HA add-on: True - Safe mode: False 2024-08-16 17:15:50.624 INFO (MainThread) [music_assistant.cache] Initializing cache controller... 2024-08-16 17:15:50.650 INFO (MainThread) [music_assistant.music] Migrating database from version 5 to 6 2024-08-16 17:15:58.286 CRITICAL (MainThread) [music_assistant.music] Database migration failed - setup can not continue. Try restarting the server. If this issue persists, create an issue report on Github and/or re-install the server (or restore a backup). Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/music.py", line 959, in _setup_database await self.migrate_database(prev_version) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/music.py", line 1117, in migrate_database await ctrl.update_item_in_library(media_item.item_id, media_item, True) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 144, in update_item_in_library await self._update_library_item(item_id, update, overwrite=overwrite) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/albums.py", line 257, in _update_library_item await self._set_album_artists(db_id, artists, overwrite=overwrite) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/albums.py", line 346, in _set_album_artists mapping = await self._set_album_artist(db_id, artist=artist, overwrite=overwrite) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/albums.py", line 369, in _set_album_artist db_artist = await self.mass.music.artists.add_item_to_library( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 101, in add_item_to_library await self._update_library_item(library_id, item, overwrite=overwrite_existing) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/artists.py", line 339, in _update_library_item cur_item = await self.get_library_item(db_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 352, in get_library_item raise MediaNotFoundError(msg) music_assistant.common.models.errors.MediaNotFoundError: artist not found in library: 68 2024-08-16 17:15:58.306 ERROR (MainThread) [music_assistant] Error doing task: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/music.py", line 959, in _setup_database await self.migrate_database(prev_version) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/music.py", line 1117, in migrate_database await ctrl.update_item_in_library(media_item.item_id, media_item, True) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 144, in update_item_in_library await self._update_library_item(item_id, update, overwrite=overwrite) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/albums.py", line 257, in _update_library_item await self._set_album_artists(db_id, artists, overwrite=overwrite) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/albums.py", line 346, in _set_album_artists mapping = await self._set_album_artist(db_id, artist=artist, overwrite=overwrite) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/albums.py", line 369, in _set_album_artist db_artist = await self.mass.music.artists.add_item_to_library( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 101, in add_item_to_library await self._update_library_item(library_id, item, overwrite=overwrite_existing) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/artists.py", line 339, in _update_library_item cur_item = await self.get_library_item(db_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 352, in get_library_item raise MediaNotFoundError(msg) music_assistant.common.models.errors.MediaNotFoundError: artist not found in library: 68

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiorun.py", line 219, in new_coro await coro File "/usr/local/lib/python3.12/site-packages/music_assistant/main.py", line 212, in start_mass await mass.start() File "/usr/local/lib/python3.12/site-packages/music_assistant/server/server.py", line 146, in start await self.music.setup(await self.config.get_core_config("music")) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/music.py", line 156, in setup await self._setup_database() File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/music.py", line 969, in _setup_database raise RuntimeError("Database migration failed") from err RuntimeError: Database migration failed

Additional information

No response

What version of Home Assistant Core are your running

2024.8.3

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Generic x86-64 (e.g. Intel NUC)

marcelveldt commented 3 weeks ago

Looks like the entire database is damaged, the migration is failing. Only fix for now is a reinstall.

harryfine commented 3 weeks ago

Fair enough, that's easy enough. I'm wondering if it's widespread with the new beta, you might want to take a look.

collateral87 commented 3 weeks ago

i have the same issue. i restored my backup. is there no way around a reinstall?

txwindsurfer commented 3 weeks ago

FWIW, same issue and I use Spotify. Restored backup and back to working.

Vacationland105 commented 3 weeks ago

Same here for me. Same errors, with the same version and the resolution is the same (restore a backup) but with remote files and Spotify music providers.

dreimer1986 commented 3 weeks ago

And same here. Looks like this is a bit more widespread...

marcelveldt commented 3 weeks ago

What I can do is initiate a full db rebuild when we find unrecoverable issues like this. That saves the reinstall.

marcelveldt commented 3 weeks ago

I added a bit of forgiveness to the db migration - can you folks please give 2.2.0 beta 8 a try ?

lexam79 commented 3 weeks ago

Hello, just tried to upgrade to 2.2.0 beta 8, but facing the same problem.

marcelveldt commented 3 weeks ago

Hello, just tried to upgrade to 2.2.0 beta 8, but facing the same problem.

Can you send a log snippet of the errors ?

lexam79 commented 3 weeks ago

Sure, here it is:

2024-08-17 11:15:48.620 INFO (MainThread) [music_assistant] Starting Music Assistant Server (aa646972b0e14f12bad9c5e034691392) version 2.2.0b8 - HA add-on: False - Safe mode: False
2024-08-17 11:15:48.629 INFO (MainThread) [music_assistant.cache] Initializing cache controller...
2024-08-17 11:15:48.919 INFO (MainThread) [music_assistant.music] Migrating database from version 5 to 6
2024-08-17 11:16:14.020 WARNING (MainThread) [music_assistant.music] Error while migrating 14208: artist not found in library: 12285
2024-08-17 11:16:14.926 WARNING (MainThread) [music_assistant.music] Error while migrating 14468: artist not found in library: 12737
2024-08-17 11:16:15.352 WARNING (MainThread) [music_assistant.music] Error while migrating 13921: artist not found in library: 12285
2024-08-17 11:16:19.221 WARNING (MainThread) [music_assistant.music] Error while migrating 14742: artist not found in library: 12878
2024-08-17 11:16:19.697 WARNING (MainThread) [music_assistant.music] Error while migrating 13392: artist not found in library: 11852
2024-08-17 11:16:19.774 WARNING (MainThread) [music_assistant.music] Error while migrating 13420: artist not found in library: 11872
2024-08-17 11:16:20.929 WARNING (MainThread) [music_assistant.music] Error while migrating 14782: artist not found in library: 12983
2024-08-17 11:16:23.802 WARNING (MainThread) [music_assistant.music] Error while migrating 13777: artist not found in library: 12173
2024-08-17 11:16:26.877 WARNING (MainThread) [music_assistant.music] Error while migrating 13750: artist not found in library: 12152
2024-08-17 11:16:27.030 WARNING (MainThread) [music_assistant.music] Error while migrating 13800: artist not found in library: 11936
2024-08-17 11:16:27.081 WARNING (MainThread) [music_assistant.music] Error while migrating 14197: artist not found in library: 12339
2024-08-17 11:16:27.110 WARNING (MainThread) [music_assistant.music] Error while migrating 14580: artist not found in library: 11837
2024-08-17 11:16:27.160 WARNING (MainThread) [music_assistant.music] Error while migrating 13338: artist not found in library: 11802
2024-08-17 11:16:27.514 WARNING (MainThread) [music_assistant.music] Error while migrating 11956: artist not found in library: 10573
2024-08-17 11:16:28.931 WARNING (MainThread) [music_assistant.music] Error while migrating 13803: artist not found in library: 11828
2024-08-17 11:16:33.085 WARNING (MainThread) [music_assistant.music] Error while migrating 14202: artist not found in library: 12285
2024-08-17 11:16:33.337 WARNING (MainThread) [music_assistant.music] Error while migrating 14855: artist not found in library: 13031
2024-08-17 11:16:36.581 WARNING (MainThread) [music_assistant.music] Error while migrating 13544: artist not found in library: 11992
2024-08-17 11:16:37.534 WARNING (MainThread) [music_assistant.music] Error while migrating 13560: artist not found in library: 12001
2024-08-17 11:16:38.246 WARNING (MainThread) [music_assistant.music] Error while migrating 12262: artist not found in library: 11776
2024-08-17 11:16:38.323 WARNING (MainThread) [music_assistant.music] Error while migrating 13843: artist not found in library: 12230
2024-08-17 11:16:38.579 WARNING (MainThread) [music_assistant.music] Error while migrating 13836: artist not found in library: 11828
2024-08-17 11:16:38.704 WARNING (MainThread) [music_assistant.music] Error while migrating 13976: artist not found in library: 12285
2024-08-17 11:16:39.520 WARNING (MainThread) [music_assistant.music] Error while migrating 14260: artist not found in library: 12549
2024-08-17 11:16:39.635 WARNING (MainThread) [music_assistant.music] Error while migrating 14562: artist not found in library: 12825
2024-08-17 11:16:41.341 WARNING (MainThread) [music_assistant.music] Error while migrating 13856: artist not found in library: 12240
2024-08-17 11:16:43.351 WARNING (MainThread) [music_assistant.music] Error while migrating 15185: artist not found in library: 13281
2024-08-17 11:16:43.498 WARNING (MainThread) [music_assistant.music] Error while migrating 14546: artist not found in library: 11852
2024-08-17 11:16:44.309 WARNING (MainThread) [music_assistant.music] Error while migrating 14768: artist not found in library: 12972
2024-08-17 11:16:44.958 WARNING (MainThread) [music_assistant.music] Error while migrating 14320: artist not found in library: 12621
2024-08-17 11:16:45.214 WARNING (MainThread) [music_assistant.music] Error while migrating 14410: artist not found in library: 12230
2024-08-17 11:16:45.429 WARNING (MainThread) [music_assistant.music] Error while migrating 12469: artist not found in library: 11777
2024-08-17 11:16:45.929 WARNING (MainThread) [music_assistant.music] Error while migrating 14368: artist not found in library: 12285
2024-08-17 11:16:46.046 WARNING (MainThread) [music_assistant.music] Error while migrating 13925: artist not found in library: 12300
2024-08-17 11:16:46.107 WARNING (MainThread) [music_assistant.music] Error while migrating 13837: artist not found in library: 12224
2024-08-17 11:16:46.464 WARNING (MainThread) [music_assistant.music] Error while migrating 13975: artist not found in library: 12339
2024-08-17 11:16:47.103 WARNING (MainThread) [music_assistant.music] Error while migrating 14797: artist not found in library: 12993
2024-08-17 11:16:48.054 WARNING (MainThread) [music_assistant.music] Error while migrating 14428: artist not found in library: 12715
2024-08-17 11:16:48.593 WARNING (MainThread) [music_assistant.music] Error while migrating 12226: artist not found in library: 10573
2024-08-17 11:16:48.834 WARNING (MainThread) [music_assistant.music] Error while migrating 14947: artist not found in library: 13115
2024-08-17 11:16:48.952 WARNING (MainThread) [music_assistant.music] Error while migrating 14140: artist not found in library: 12445
2024-08-17 11:16:49.293 WARNING (MainThread) [music_assistant.music] Error while migrating 14599: artist not found in library: 12850
2024-08-17 11:16:49.639 WARNING (MainThread) [music_assistant.music] Error while migrating 14376: artist not found in library: 11811
2024-08-17 11:16:49.689 WARNING (MainThread) [music_assistant.music] Error while migrating 14188: artist not found in library: 12477
2024-08-17 11:16:50.133 WARNING (MainThread) [music_assistant.music] Error while migrating 14472: artist not found in library: 12240
2024-08-17 11:16:51.494 WARNING (MainThread) [music_assistant.music] Error while migrating 14999: artist not found in library: 13145
2024-08-17 11:16:51.523 WARNING (MainThread) [music_assistant.music] Error while migrating 13350: artist not found in library: 11811
2024-08-17 11:16:52.140 WARNING (MainThread) [music_assistant.music] Error while migrating 14532: artist not found in library: 12194
2024-08-17 11:16:52.862 WARNING (MainThread) [music_assistant.music] Error while migrating 15092: artist not found in library: 12339
2024-08-17 11:16:53.013 WARNING (MainThread) [music_assistant.music] Error while migrating 13379: artist not found in library: 11848
2024-08-17 11:16:54.530 WARNING (MainThread) [music_assistant.music] Error while migrating 15090: artist not found in library: 13221
2024-08-17 11:16:55.402 WARNING (MainThread) [music_assistant.music] Error while migrating 12730: artist not found in library: 10573
2024-08-17 11:16:56.309 WARNING (MainThread) [music_assistant.music] Error while migrating 15043: artist not found in library: 12813
2024-08-17 11:16:58.138 WARNING (MainThread) [music_assistant.music] Error while migrating 13497: artist not found in library: 11950
2024-08-17 11:16:58.349 WARNING (MainThread) [music_assistant.music] Error while migrating 13418: artist not found in library: 11866
2024-08-17 11:17:00.097 WARNING (MainThread) [music_assistant.music] Error while migrating 13460: artist not found in library: 11919
2024-08-17 11:17:00.460 WARNING (MainThread) [music_assistant.music] Error while migrating 13467: artist not found in library: 11928
2024-08-17 11:17:02.489 WARNING (MainThread) [music_assistant.music] Error while migrating 14412: artist not found in library: 11802
2024-08-17 11:17:03.215 WARNING (MainThread) [music_assistant.music] Error while migrating 13364: artist not found in library: 11828
2024-08-17 11:17:03.793 WARNING (MainThread) [music_assistant.music] Error while migrating 13543: artist not found in library: 11987
2024-08-17 11:17:06.494 WARNING (MainThread) [music_assistant.music] Error while migrating 13583: artist not found in library: 12025
2024-08-17 11:17:06.978 WARNING (MainThread) [music_assistant.music] Error while migrating 13660: artist not found in library: 12089
2024-08-17 11:17:07.726 WARNING (MainThread) [music_assistant.music] Error while migrating 13926: artist not found in library: 12089
2024-08-17 11:17:09.166 WARNING (MainThread) [music_assistant.music] Error while migrating 13827: artist not found in library: 12220
2024-08-17 11:17:09.350 WARNING (MainThread) [music_assistant.music] Error while migrating 14848: artist not found in library: 13029
2024-08-17 11:17:11.290 WARNING (MainThread) [music_assistant.music] Error while migrating 13518: artist not found in library: 11811
2024-08-17 11:17:12.231 WARNING (MainThread) [music_assistant.music] Error while migrating 14925: artist not found in library: 13097
2024-08-17 11:17:12.517 WARNING (MainThread) [music_assistant.music] Error while migrating 13352: artist not found in library: 11814
2024-08-17 11:17:12.677 WARNING (MainThread) [music_assistant.music] Error while migrating 13365: artist not found in library: 11830
2024-08-17 11:17:17.868 WARNING (MainThread) [music_assistant.music] Error while migrating 42730: artist not found in library: 11781
2024-08-17 11:17:21.664 WARNING (MainThread) [music_assistant.music] Error while migrating 42818: artist not found in library: 11837
2024-08-17 11:17:22.153 WARNING (MainThread) [music_assistant.music] Error while migrating 42830: artist not found in library: 11845
2024-08-17 11:17:22.948 WARNING (MainThread) [music_assistant.music] Error while migrating 42848: artist not found in library: 11851
2024-08-17 11:17:28.109 WARNING (MainThread) [music_assistant.music] Error while migrating 42959: artist not found in library: 11837
2024-08-17 11:17:29.720 WARNING (MainThread) [music_assistant.music] Error while migrating 48147: artist not found in library: 11811
2024-08-17 11:17:34.954 WARNING (MainThread) [music_assistant.music] Error while migrating 48833: artist not found in library: 13178
2024-08-17 11:17:35.144 WARNING (MainThread) [music_assistant.music] Error while migrating 43054: artist not found in library: 11936
2024-08-17 11:17:37.997 WARNING (MainThread) [music_assistant.music] Error while migrating 43113: artist not found in library: 11781
2024-08-17 11:17:40.102 WARNING (MainThread) [music_assistant.music] Error while migrating 43176: artist not found in library: 11974
2024-08-17 11:17:42.800 WARNING (MainThread) [music_assistant.music] Error while migrating 43242: artist not found in library: 11996
2024-08-17 11:17:47.484 WARNING (MainThread) [music_assistant.music] Error while migrating 43360: artist not found in library: 11996
2024-08-17 11:17:47.947 WARNING (MainThread) [music_assistant.music] Error while migrating 43372: artist not found in library: 12044
2024-08-17 11:17:49.244 WARNING (MainThread) [music_assistant.music] Error while migrating 43411: artist not found in library: 11837
2024-08-17 11:17:51.283 WARNING (MainThread) [music_assistant.music] Error while migrating 43434: artist not found in library: 11837
2024-08-17 11:17:55.022 WARNING (MainThread) [music_assistant.music] Error while migrating 43453: artist not found in library: 11781
2024-08-17 11:17:55.079 WARNING (MainThread) [music_assistant.music] Error while migrating 43455: artist not found in library: 11781
2024-08-17 11:17:56.632 WARNING (MainThread) [music_assistant.music] Error while migrating 43506: artist not found in library: 11996
2024-08-17 11:17:56.754 WARNING (MainThread) [music_assistant.music] Error while migrating 43509: artist not found in library: 11996
2024-08-17 11:17:56.761 WARNING (MainThread) [music_assistant.music] Error while migrating 43509: track not found in library: 43509
2024-08-17 11:17:56.763 CRITICAL (MainThread) [music_assistant.music] Database migration failed - setup can not continue. Try restarting the server. If this issue persists, create an issue report  on Github and/or re-install the server (or restore a backup).
2024-08-17 11:17:57.058 ERROR (MainThread) [music_assistant] Error doing task: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/music.py", line 1136, in __migrate_database
    await ctrl.update_item_in_library(media_item.item_id, media_item, True)
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 144, in update_item_in_library
    await self._update_library_item(item_id, update, overwrite=overwrite)
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/tracks.py", line 377, in _update_library_item
    cur_item = await self.get_library_item(db_id)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 352, in get_library_item
    raise MediaNotFoundError(msg)
music_assistant.common.models.errors.MediaNotFoundError: track not found in library: 43509
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/music.py", line 967, in _setup_database
    await self.__migrate_database(prev_version)
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/music.py", line 1144, in __migrate_database
    await ctrl.remove_item_from_library(media_item.item_id)
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/tracks.py", line 215, in remove_item_from_library
    await super().remove_item_from_library(db_id)
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 157, in remove_item_from_library
    library_item = await self.get_library_item(db_id)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 352, in get_library_item
    raise MediaNotFoundError(msg)
music_assistant.common.models.errors.MediaNotFoundError: track not found in library: 43509
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiorun.py", line 219, in new_coro
    await coro
  File "/usr/local/lib/python3.12/site-packages/music_assistant/__main__.py", line 212, in start_mass
    await mass.start()
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/server.py", line 146, in start
    await self.music.setup(await self.config.get_core_config("music"))
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/music.py", line 156, in setup
    await self._setup_database()
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/music.py", line 977, in _setup_database
    raise RuntimeError("Database migration failed") from err
RuntimeError: Database migration failed
lexam79 commented 3 weeks ago

I'm having intermittent internet connectivity issues during the last few days; could it be related to that? Maybe it's looking for information from Apple (my main music provider, I also have Samba share and Tunein) and it can't properly get it (because of my internet connection issues) and fails?

marcelveldt commented 3 weeks ago

I'm having intermittent internet connectivity issues during the last few days; could it be related to that? Maybe it's looking for information from Apple (my main music provider, I also have Samba share and Tunein) and it can't properly get it (because of my internet connection issues) and fails?

No, it should handle that - well, at least startup and your local files should play when there is no internet. The streaming providers and/or metadata providers will give errors (but retry at a later interval).

I have adjusted some more to the migration logic. Publishing yet another beta in a few minutes

Vacationland105 commented 3 weeks ago

I'm getting the same type of "artist not found" errors as @lexam79 with b9. While the migration does finish and MA will launch, the MA database is a mess where many many artists (remote share) cannot be found and a music provider sync doesn't seem to rectify the problem. A mix of different procedures doesn't help either (like removing Spotify prior to going from b6 to b9), the db always ends up in a bad way after updating. Restoring everything back to 2.2.0b6 and restoring the db, settings, etc. back to that point int time does make everything work again. The db migration is seemingly causing some issues. Most (but not all) favorite artists seem to be missing after updating.

dreimer1986 commented 3 weeks ago

Mine was fixed by now. I am on B9 now. All working fine again.

OzGav commented 3 weeks ago

@Vacationland105 the working theory at the moment is that there is a db problem which is not apparent on beta 6. You can wait longer to see if Marcel has any other ideas or update to beta 9 then go to MA SETTINGS>>CORE>>MUSIC CONTROLLER>>ADVANCED SETTINGS and reset the database.

collateral87 commented 3 weeks ago

B9 solved it for me too

Vacationland105 commented 3 weeks ago

Thanks @OzGav. I had reverted my instance back to b6 and it is working as it had previously with the Spotify connect method. I have played around with various things (I utilize a docker instance and do not have it installed on HA) but I am always hesitant to straight up reset/clear my database as it takes MA such a long time to populate all the local artist images (the "thumbs.jpg" that show on the artist page of the library). I spent some serious time fixing the tagging to meet the MA recommendations and even though the vast majority of my music collection has the needed meta files locally and in the correct location (thumbs.jpg, fanart.jpg, etc.), it is still a slow process that doesn't ever seem to finish. Even a manual call for the "filesystem (remote share)" music provider to sync doesn't seem to get those missing images any more. It just stays looking like this in b9 image

This is what it looks like in b6, even though many of the artist images shown are not the images that are locally in the artist folders (not sure why it still goes and downloads that content however). image

OzGav commented 3 weeks ago

Yes I noticed something similar although I think the images are loading slowly and do respond to a refresh item but this is not practical with a large collection (which I have also). So just wait until Marcel has a further look at it.

marcelveldt commented 3 weeks ago

@Vacationland105 the only way to recover from this is to reset the db. We had a number of unfortunate data integrity issues in the past betas which we tried to fix with db migration but that only worked for a number of people. We have a button to reset the db in settings --> Core --> Core modules --> Music controller (advanced section).

A full scan will be issued which will take some time (but should be faster than previous versions as we optimized it a bit). Due to the speed optimization to scan the filesystem, the images will be loaded in a second step. That is why you dont see images at first but they will be picked up slowly in the background. I'll do my best to speed-up that part as well for local files.

Vacationland105 commented 3 weeks ago

Thanks for the insight @marcelveldt. I have setup a clean and minimally configured (just remote share local music) b9 instance and I am just going to let it do its thing for a couple day and see what happens.

marcelveldt commented 3 weeks ago

I discovered the issue with the local metadata retrieval so that will be fixed in the next beta

OzGav commented 3 weeks ago

This should be fixed in 2.2.0rc1

OzGav commented 2 weeks ago

Database errrors require a db reset. The reported problem with image loading is confirmed fixed. Closing.