Jump to content

User login causes Emby to stop working


Recommended Posts

petergallagher
Posted (edited)

Recently Emby has stopped working when logging in as certain users and I can't figure out why.

I have 3 users on the system (admin, parent and child accounts). After switching to (or logging in as) the 'child' account Emby becomes unresponsive and doesn't load the libraries on the home screen. This affects all users at this point (no libraries can be displayed or media played for any user) until the system is restarted.

I have tried deleting the 'child' account and creating new accounts, but these new accounts continue to display the same symptoms as the 'child' account.

I have recently migrated Emby to a new server and changed the library paths. But I have successfully updated all the library paths within Emby and these are working fine under the parent account (and had been working for a day with the 'child' account as well), so it doesn't seem to be related to this.

I have attached the debug log showing a login with a new account I created during testing, which causes Emby to become unresponsive. This doesn't display any errors, so I'm not sure what to attempt next. Any help would be greatly appreciated.

embyserver.txt

Edited by petergallagher
Posted

Hi there, can you please attach the complete emby server log file? Thanks.

petergallagher
Posted

So it turns out that if I leave it running for long enough that it does eventually load, but the system is basically unusable as it constantly hangs. Here is an excerpt of a query taking 284290ms (or 4mins 44secs). Is there something I can do to improve the performance of this? Why does it only affect some users?

Quote

2022-11-16 20:53:24.920 Debug SqliteItemRepository: GetItems query time (slow): 284290ms. Query: select A.type,A.Id,A.IndexNumber,A.Name,A.Path,A.ParentIndexNumber,A.ProductionYear,A.RunTimeTicks,A.Container,A.ParentId,A.IsVirtualItem,A.SeriesName,A.Album,A.AlbumId,A.SeriesId,A.PresentationUniqueKey,A.Images,A.ExternalId,A.SortIndexNumber,A.SortParentIndexNumber,A.IndexNumberEnd,UserDatas.IsFavorite,UserDatas.Played,UserDatas.PlayCount,UserDatas.PlaybackPositionTicks,UserDatas.LastPlayedDateInt,UserDatas.AudioStreamIndex,UserDatas.SubtitleStreamIndex,case when InheritedParentalRatingValue > 0 Then InheritedParentalRatingValue Else coalesce((select InheritedParentalRatingValue from MediaItems where Coalesce(InheritedParentalRatingValue,0) > 0 and Id in (select A.AlbumId union all Select AncestorId from AncestorIds2 where ItemId=A.Id) limit 1), 0) End as QueriedInheritedParentalRatingValue,((Coalesce(SortParentIndexNumber,ParentIndexNumber, 1) * 1000000) + Coalesce(SortIndexNumber, IndexNumber, 0) + (Select Case When Coalesce(ParentIndexNumber,1)=0 Then 0 Else 0.5 End) + (Select Case When Coalesce(ParentIndexNumber,1)=0 Then (Cast(Coalesce(IndexNumber, 0) as REAL) / 100000) Else 0 End)) EpisodeAbsoluteIndexNumber from MediaItems A left join (Select N.SeriesPresentationUniqueKey,((Coalesce(N.SortParentIndexNumber,N.ParentIndexNumber, 1) * 1000000) + Coalesce(N.SortIndexNumber, N.IndexNumber, 0) + (Select Case When Coalesce(N.ParentIndexNumber,1)=0 Then 0 Else 0.5 End) + (Select Case When Coalesce(N.ParentIndexNumber,1)=0 Then (Cast(Coalesce(N.IndexNumber, 0) as REAL) / 100000) Else 0 End)) AbsoluteIndexNumber,UserDatas_N.LastPlayedDateInt LastPlayedDateInt,UserDatas_N.playbackPositionTicks playbackPositionTicks from MediaItems N join UserDatas UserDatas_N on N.UserDataKeyId=UserDatas_N.UserDataKeyId And (UserDatas_N.UserId=@UserId) where Type=8 and (UserDatas_N.Played=1 or UserDatas_N.playbackPositionTicks > 0) Group By N.SeriesPresentationUniqueKey ORDER BY MAX(UserDatas_N.LastPlayedDateInt) desc, Coalesce(SortParentIndexNumber,ParentIndexNumber) desc, Coalesce(SortIndexNumber,IndexNumber) desc) LastWatchedEpisodes on LastWatchedEpisodes.SeriesPresentationUniqueKey=A.SeriesPresentationUniqueKey left join UserDatas on A.UserDataKeyId=UserDatas.UserDataKeyId And (UserDatas.UserId=@UserId) where ((UserDatas.playbackPositionTicks > 0) OR (A.Type=8 and Coalesce(UserDatas.Played,0)=0 and EpisodeAbsoluteIndexNumber > LastWatchedEpisodes.AbsoluteIndexNumber and LastWatchedEpisodes.LastPlayedDateInt not null)) AND (A.Type <> 8 or UserDatas.playbackPositionTicks > 0 or Coalesce(A.SortParentIndexNumber, A.ParentIndexNumber, -1) <> 0) AND QueriedInheritedParentalRatingValue<=@MaxParentalRating AND (QueriedInheritedParentalRatingValue > 0 or UnratedType not in (5,4,8,6,0,3,1,2)) AND IsVirtualItem=@IsVirtualItem AND Coalesce(HideFromResume,0)=@HideFromResume AND Coalesce((select HideFromResume from UserDatas where UserDataKeyId=(Select UserDataKeyId from MediaItems MediaItemsHideFromResumeInner where MediaItemsHideFromResumeInner.Id=A.SeriesId) and UserId=@UserId),0)=@HideFromResume AND MediaType=@MediaTypes AND TopParentId in (12,3,6,4) Group by coalesce(A.SeriesPresentationUniqueKey, A.PresentationUniqueKey) ORDER BY coalesce(LastWatchedEpisodes.LastPlayedDateInt, Max(UserDatas.LastPlayedDateInt)) DESC,Max(UserDatas.LastPlayedDateInt) DESC,Min(EpisodeAbsoluteIndexNumber) ASC LIMIT 12

 

embyserver(1).txt

petergallagher
Posted

So it seems like running a vacuum on the database has resolved the issue (Server > Database > Vacuum the database on the next Emby Server startup) and everything is back to normal. Don't really understand why this would only affect some users though.

Posted

Hi, i actually caught this earlier today. There is something in the database query related to the parental rating that is sometimes causing it to be a little slower than it should. We'll look at backporting this fix into a new 4.7.X release if we can. Thanks.

  • Like 1
petergallagher
Posted

Hi Luke, thanks for your quick response. Look forward to a new release for this issue. Do you think the database vacuum had any impact or was this just a coincidence?

Posted

Running the vacuum from time to time can definitely give you a performance boost, so yes.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...