[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use EF Core for Activity database #452

Merged
merged 5 commits into from
Jan 25, 2019
Merged

Conversation

Bond-009
Copy link
Member
@Bond-009 Bond-009 commented Jan 6, 2019

Start moving databases to Entity Framework core.

@Bond-009 Bond-009 changed the title WIP: Use EF Core for Activity database Use EF Core for Activity database Jan 12, 2019
@ploughpuff
Copy link
Contributor

Testing branch activitydb with virgin install (clean config, data, logs). Started ok, managed to add second user, logged out, and quite quickly program crashed out with:

Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such table: ActivityLogs'.

Full log below:

16:29:28] [INF] HTTP GET http://localhost:8096/emby/System/ActivityLog/Entries?startIndex=0&limit=4&minDate=2019-01-07T16%3A29%3A28.451Z&hasUserId=false. UserAgent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0
[16:29:28] [ERR] Error processing request
FailFast:
A callback was made on a garbage collected delegate of type 'SQLitePCLRaw.provider.e_sqlite3!SQLitePCL.SQLite3Provider_e_sqlite3+NativeMethods+callback_trace::Invoke'.

   at SQLitePCL.SQLite3Provider_e_sqlite3+NativeMethods.sqlite3_step(IntPtr)
   at SQLitePCL.SQLite3Provider_e_sqlite3+NativeMethods.sqlite3_step(IntPtr)
   at SQLitePCL.SQLite3Provider_e_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_step(IntPtr)
   at SQLitePCL.pretty.StatementImpl.MoveNext()
   at SQLitePCL.pretty.DatabaseConnection.Execute(SQLitePCL.pretty.IDatabaseConnection, System.String)
   at SQLitePCL.pretty.DatabaseConnection.RunInTransaction[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](SQLitePCL.pretty.IDatabaseConnection, System.Func`2<SQLitePCL.pretty.IDatabaseConnection,System.__Canon>, SQLitePCL.pretty.TransactionMode)
   at Emby.Server.Implementations.Security.AuthenticationRepository.Get(MediaBrowser.Controller.Security.AuthenticationInfoQuery)
   at Emby.Server.Implementations.HttpServer.Security.AuthorizationContext.GetAuthorization(MediaBrowser.Model.Services.IRequest)
   at Emby.Server.Implementations.HttpServer.Security.AuthorizationContext.GetAuthorizationInfo(MediaBrowser.Model.Services.IRequest)
   at Emby.Server.Implementations.HttpServer.Security.AuthService.ValidateUser(MediaBrowser.Model.Services.IRequest, MediaBrowser.Controller.Net.IAuthenticationAttributes)
   at Emby.Server.Implementations.HttpServer.HttpListenerHost.ApplyRequestFilters(MediaBrowser.Model.Services.IRequest, MediaBrowser.Model.Services.IResponse, System.Object)
   at Emby.Server.Implementations.Services.ServiceHandler+<ProcessRequestAsync>d__13.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Emby.Server.Implementations.Services.ServiceHandler+<ProcessRequestAsync>d__13, Emby.Server.Implementations, Version=10.0.0.0, Culture=neutral, PublicKeyToken=null]](<ProcessRequestAsync>d__13 ByRef)
   at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(Emby.Server.Implementations.HttpServer.HttpListenerHost, MediaBrowser.Model.Services.IRequest, MediaBrowser.Model.Services.IResponse, Microsoft.Extensions.Logging.ILogger, System.String, System.Threading.CancellationToken)
   at Emby.Server.Implementations.HttpServer.HttpListenerHost+<RequestHandler>d__60.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Emby.Server.Implementations.HttpServer.HttpListenerHost+<RequestHandler>d__60, Emby.Server.Implementations, Version=10.0.0.0, Culture=neutral, PublicKeyToken=null]](<RequestHandler>d__60 ByRef)
   at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(MediaBrowser.Model.Services.IHttpRequest, System.String, System.String, System.String, System.Threading.CancellationToken)
   at Jellyfin.SocketSharp.WebSocketSharpListener.InitTask(SocketHttpListener.Net.HttpListenerContext, System.Threading.CancellationToken)
   at System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such table: ActivityLogs'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()
   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider._TrackEntities[TOut,TIn](IEnumerable`1 results, QueryContext queryContext, IList`1 entityTrackingInfos, IList`1 entityAccessors)+MoveNext()
   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
   at Emby.Server.Implementations.Activity.ActivityManager.GetActivityLogEntries(Nullable`1 minDate, Nullable`1 hasUserId, Nullable`1 startIndex, Nullable`1 limit) in /home/ploughpuff/jellyfin/Emby.Server.Implementations/Activity/ActivityManager.cs:line 59
   at MediaBrowser.Api.System.ActivityLogService.Get(GetActivityLogs request) in /home/ploughpuff/jellyfin/MediaBrowser.Api/System/ActivityLogService.cs:line 49
Aborted
ploughpuff@vb-deb-jelly:~/jellyfin$ 

@Bond-009
Copy link
Member Author

@ploughpuff Should be fixed.

@Bond-009 Bond-009 force-pushed the activitydb branch 2 times, most recently from e24ee15 to fde82bb Compare January 14, 2019 17:37
@ploughpuff
Copy link
Contributor

Struggling to build this now. The following package reference is causing me problems:
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.0" />

Receive 18 errors like this:

/home/ploughpuff/jellyfin/Emby.Server.Implementations/Emby.Server.Implementations.csproj : error NU1605: Detected package downgrade: System.Collections from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version.  [/home/ploughpuff/jellyfin/Jellyfin.Server/Jellyfin.Server.csproj]
/home/ploughpuff/jellyfin/Emby.Server.Implementations/Emby.Server.Implementations.csproj : error NU1605:  Emby.Server.Implementations -> Microsoft.EntityFrameworkCore.Sqlite 2.2.0 -> Microsoft.EntityFrameworkCore.Sqlite.Core 2.2.0 -> Microsoft.Extensions.DependencyModel 2.1.0 -> Microsoft.DotNet.PlatformAbstractions 2.1.0 -> System.IO.FileSystem 4.0.1 -> runtime.unix.System.IO.FileSystem 4.3.0 -> System.Collections (>= 4.3.0)  [/home/ploughpuff/jellyfin/Jellyfin.Server/Jellyfin.Server.csproj]
/home/ploughpuff/jellyfin/Emby.Server.Implementations/Emby.Server.Implementations.csproj : error NU1605:  Emby.Server.Implementations -> Microsoft.EntityFrameworkCore.Sqlite 2.2.0 -> Microsoft.EntityFrameworkCore.Sqlite.Core 2.2.0 -> Microsoft.Extensions.DependencyModel 2.1.0 -> Microsoft.DotNet.PlatformAbstractions 2.1.0 -> System.Collections (>= 4.0.11) [/home/ploughpuff/jellyfin/Jellyfin.Server/Jellyfin.Server.csproj]
<snip>

This post is exactly what I'm experiencing:
dotnet/efcore#14354

Copy link
Contributor
@JustAMan JustAMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if that works

@joshuaboniface
Copy link
Member

@Bond-009 Some conflicts. However, do we want to get this one into 10.1.0, or wait for the next release and do them all?

@@ -92,28 +93,28 @@ public void Run()
_appHost.ApplicationUpdated += _appHost_ApplicationUpdated;
}

void _deviceManager_CameraImageUploaded(object sender, GenericEventArgs<CameraImageUploadInfo> e)
async void _deviceManager_CameraImageUploaded(object sender, GenericEventArgs<CameraImageUploadInfo> e)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these method names come from emby? I would rename them to OnDeviceManagerCameraImageUpload to respect language best practices.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes there come from Emby

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO they should/could be mass renamed in one big PR.

@nvllsvm nvllsvm merged commit 3328511 into jellyfin:dev Jan 25, 2019
Bond-009 pushed a commit that referenced this pull request Jan 25, 2019
This reverts commit 48ad18d, reversing
changes made to fe19741.
@Bond-009 Bond-009 deleted the activitydb branch January 26, 2019 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants