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

Can't cleanup Plex Users #4812

Closed
Navino16 opened this issue Nov 25, 2022 · 5 comments
Closed

Can't cleanup Plex Users #4812

Navino16 opened this issue Nov 25, 2022 · 5 comments

Comments

@Navino16
Copy link

Describe the bug
When I purge my old plex users, there are still there and I have some errors on logs

To Reproduce
Steps to reproduce the behavior:

  1. Have users that are not on Plex anymore
  2. Enable "Cleanup Plex Users"
  3. Save configuration
  4. Run importer
  5. Go check users, old users are still there and there is some errors in logs

Expected behavior
When importer run with "Cleanup Plex Users" enabled, users that are not in plex should be deleted

Logs (Logs directory where Ombi is located)

Application logs
2022-11-25 09:39:32.349 +01:00 [ERR] Job Plex.IPlexUserImporter threw an exception.
Quartz.SchedulerException: Job threw an unhandled exception.
---> Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
---> MySqlConnector.MySqlException (0x80004005): Cannot delete or update a parent row: a foreign key constraint fails (`ombi`.`UserQualityProfiles`, CONSTRAINT `FK_UserQualityProfiles_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `AspNetUsers` (`Id`))
 at MySqlConnector.Core.ServerSession.ReceiveReplyAsyncAwaited(ValueTask`1 task) in /_/src/MySqlConnector/Core/ServerSession.cs:line 956
 at MySqlConnector.Core.ResultSet.ReadResultSetHeaderAsync(IOBehavior ioBehavior) in /_/src/MySqlConnector/Core/ResultSet.cs:line 44
 at MySqlConnector.MySqlDataReader.ActivateResultSet(CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 108
 at MySqlConnector.MySqlDataReader.CreateAsync(CommandListPosition commandListPosition, ICommandPayloadCreator payloadCreator, IDictionary`2 cachedProcedures, IMySqlCommand command, CommandBehavior behavior, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 456
 at MySqlConnector.Core.CommandExecutor.ExecuteReaderAsync(IReadOnlyList`1 commands, ICommandPayloadCreator payloadCreator, CommandBehavior behavior, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/CommandExecutor.cs:line 56
 at MySqlConnector.MySqlCommand.ExecuteReaderAsync(CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlCommand.cs:line 331
 at MySqlConnector.MySqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlCommand.cs:line 323
 at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
 --- End of inner exception stack trace ---
 at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.<>c__DisplayClass33_0`2.<<ExecuteAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
 at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementationAsync[TState,TResult](Func`4 operation, Func`4 verifySucceeded, TState state, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementationAsync[TState,TResult](Func`4 operation, Func`4 verifySucceeded, TState state, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
 at Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`9.DeleteAsync(TUser user, CancellationToken cancellationToken)
 at Ombi.Schedule.Jobs.Plex.PlexUserImporter.Execute(IJobExecutionContext job) in /home/runner/work/Ombi/Ombi/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs:line 93
 at Ombi.Schedule.QuartzJobRunner.Execute(IJobExecutionContext context) in /home/runner/work/Ombi/Ombi/src/Ombi.Schedule/QuartzJobRunner.cs:line 25
 at Quartz.Core.JobRunShell.Run(CancellationToken cancellationToken)
 --- End of inner exception stack trace --- [See nested exception: Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
---> MySqlConnector.MySqlException (0x80004005): Cannot delete or update a parent row: a foreign key constraint fails (`ombi`.`UserQualityProfiles`, CONSTRAINT `FK_UserQualityProfiles_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `AspNetUsers` (`Id`))
 at MySqlConnector.Core.ServerSession.ReceiveReplyAsyncAwaited(ValueTask`1 task) in /_/src/MySqlConnector/Core/ServerSession.cs:line 956
 at MySqlConnector.Core.ResultSet.ReadResultSetHeaderAsync(IOBehavior ioBehavior) in /_/src/MySqlConnector/Core/ResultSet.cs:line 44
 at MySqlConnector.MySqlDataReader.ActivateResultSet(CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 108
 at MySqlConnector.MySqlDataReader.CreateAsync(CommandListPosition commandListPosition, ICommandPayloadCreator payloadCreator, IDictionary`2 cachedProcedures, IMySqlCommand command, CommandBehavior behavior, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 456
 at MySqlConnector.Core.CommandExecutor.ExecuteReaderAsync(IReadOnlyList`1 commands, ICommandPayloadCreator payloadCreator, CommandBehavior behavior, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/CommandExecutor.cs:line 56
 at MySqlConnector.MySqlCommand.ExecuteReaderAsync(CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlCommand.cs:line 331
 at MySqlConnector.MySqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlCommand.cs:line 323
 at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
 --- End of inner exception stack trace ---
 at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.<>c__DisplayClass33_0`2.<<ExecuteAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
 at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementationAsync[TState,TResult](Func`4 operation, Func`4 verifySucceeded, TState state, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementationAsync[TState,TResult](Func`4 operation, Func`4 verifySucceeded, TState state, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
 at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
 at Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`9.DeleteAsync(TUser user, CancellationToken cancellationToken)
 at Ombi.Schedule.Jobs.Plex.PlexUserImporter.Execute(IJobExecutionContext job) in /home/runner/work/Ombi/Ombi/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs:line 93
 at Ombi.Schedule.QuartzJobRunner.Execute(IJobExecutionContext context) in /home/runner/work/Ombi/Ombi/src/Ombi.Schedule/QuartzJobRunner.cs:line 25
 at Quartz.Core.JobRunShell.Run(CancellationToken cancellationToken)]

Desktop (please complete the following information):

  • OS: Docker image (linuxserver/ombi:development)

Ombi Version (please complete the following information):

  • Version: 4.32.3
  • Media Server: Plex
  • Database Type: Mariadb 10.6

Additional context
Add any other context about the problem here.

@github-actions
Copy link

Hi!

Thanks for the issue report. Before a real human comes by, please make sure you used our bug report format.

Have you looked at the wiki yet? https://docs.ombi.app/

Before posting make sure you also read our FAQ.

Make the title describe your issue. Having 'not working' or 'I get this bug' for 100 issues, isn't really helpful.

If we need more information or there is some progress we tag the issue or update the tag and keep you updated.

Thanks!

Ombi Bot.

@Shadow229
Copy link

Not sure if this is related or requires its own bug, but the user import doesn't seem to be working anymore at all - not just for cleanup.

I've added 2 new users to Plex in the last few days and their ombi accounts haven't generated. Manually running the importer says it ran successfully, but no new users are created.

@tidusjar
Copy link
Member

tidusjar commented Dec 19, 2022 via email

@Shadow229
Copy link

Looks like my issue was due to it not being able to connect to plex at all in the logs. I updated the authorization token in the server config and the connection was successful and users have synced. Guessing my resolution isn't going to help OP.

@Navino16
Copy link
Author

Navino16 commented Jan 4, 2023

Any new about this issue ?

@Navino16 Navino16 closed this as completed Jan 4, 2023
@Navino16 Navino16 reopened this Jan 4, 2023
tidusjar added a commit that referenced this issue Jul 3, 2023
* fix(tv-requests): 🐛 Fixed a small bug where an exception can get thrown when attempting to view TV Requests

* fix(user-importer): 🐛 Fixed an issue where the cleanup wouldn't delete users #4812
@tidusjar tidusjar closed this as completed Jul 3, 2023
tidusjar added a commit that referenced this issue Jul 22, 2024
Co-authored-by: tidusjar <[email protected]>
Co-authored-by: sephrat <[email protected]>
Co-authored-by: Conventional Changelog Action <[email protected]>
Co-authored-by: Teifun2 <[email protected]>
Co-authored-by: contrib-readme-bot <[email protected]>
Co-authored-by: dr3amer <[email protected]>
Co-authored-by: echel0n <[email protected]>
Co-authored-by: Marley <[email protected]>
Co-authored-by: Igor Borges <[email protected]>
Co-authored-by: Lucane <[email protected]>
Co-authored-by: mkgeeky <[email protected]>
Co-authored-by: Miguel A Vico Moya <[email protected]>
Co-authored-by: Hadrien <[email protected]>
Co-authored-by: Victor Usoltsev <[email protected]>
Co-authored-by: Wesley King <[email protected]>
Co-authored-by: Lea <[email protected]>
Co-authored-by: snyk-bot <[email protected]>
Co-authored-by: snyk-bot <[email protected]> [skip ci]
Co-authored-by: Jamie <[email protected]>
Co-authored-by: Drew <[email protected]> [skip ci]
Co-authored-by: ryan-c44 <[email protected]>
Co-authored-by: Alexander Russell <[email protected]>
Co-authored-by: Grygon <[email protected]>
Co-authored-by: phildups7 <[email protected]>
Co-authored-by: Avi <[email protected]>
Co-authored-by: Antonin <[email protected]>
Co-authored-by: Drew <[email protected]>
Co-authored-by: Joel Samson <[email protected]>
Co-authored-by: David Benson <[email protected]>
fix: Consistently reset loading flag when requesting movies on discover page. (#4777)
fix(sonarr): 🐛 Fixed an issue where the language list didn't correctly load for power users in the advanced options #4782
fix: Only log error messages from Microsoft (#4787)
fix(notifications): Fixed the Partially TV notifications going to the admin #4797 (#4799)
fix(translations): 🌐 New translations from Crowdin [skip ci] (#4801)
fix(sonarr): 🐛 Sonarr V4 should work now (#4810)
fixed (#4833)
fix(plex-watchlist): Lookup the ID from different sources when Plex doesn't contain the metadata (#4843)
fix(#4847): Invalid Discord request fixed, also fixed an issue where App Only users would not show as logged in on the user management page (#4848)
fix(discover): 🐛 Fixed the default poster not taking into account the base url in some scenarios #4845
fix(wizard): 🐛 Stop access to the wizard when you have already setup ombi (#4866)
fix(plex-oauth): 🐛 Fixed an issue where using OAuth you could log in as a Ombi Local user #4835
fix: Some minor tweaks to the movie info panel (#4883)
fix(sonarr): 🐛 Stop the sonarr version endpoint from breaking when Sonarr is down #4895
fix: Support duplicates in Emby/JF collections (#4902)
fix(discover): Fix denied requests displayed as approved (#4901)
fix: Fix denied movie shown as 'processing request' in details view (#4900)
fix(#4906): 🐛 Fixed an issue with power users and permissions
fix: Cron Validation (#4842)
fix(lidarr): Change monitor to Existing to properly add artist #3597
fix(API): Allow RequestOnBehalf rights if requested from the API (#4919)
Fixes #4610
fix: added media type tag to media type text (#4638)
fix(sickrage): Fixed issue with incorrect handling of SiCKRAGE episode results returned during episode status changes, now expects array of objects from data path if present (#4648)
fix: Missing Poster broken link fix (#4637)
fix: Improve Swagger documentation (#4652)
fix(API): Fix pagination in some edge cases (#4649)
fix(discover): Carousel touch not working when scrolling page and recommendations and similar movie navigation (#4633)
fix: 🐛 Fixed the Request on Behalf of having blanks (#4667)
fix(images): Retry images with a backoff when we get a Too Many requests from TheMovieDb #4685
fix: Landing and Login page improvements (#4690)
fix(discover): 🐛 Created new Image component to handle 429's from TMDB (#4698) and fixed #4635 (#4699)
fix: Override Sonarr V3 Profiles endpoint (#4678)
fix(4K) :4K request fixes (#4702)
fix(translations): 🌐 New translations from Crowdin [skip ci] (#4713)
fix: fixed trakt image not loading when base url present (#4711)
fix: 🐛 Fixed missing externals (#4712)
fix: Log Microsoft warnings to log file (#4723)
fix: Localize recently requested on discover page (#4729)
Fix: Ombi.Api.Lidarr: Remove unused fields from ArtistAdd (#4727)
fix: Fix conflicting property name for Swagger (#4733)
fix: fixed stats controller (#4742)
fix(webhook): Remove added trailing slash from webhook URL #4710
fix(sonarr): 🐛 Cleaned up and removed Sonarr v3 option, sonarr v3 is now the default. This allows us to get ready for the upcoming Sonarr v4 (#4764)
fix: Fixes default image for recently requested items. (#4767)
Fixes build warnings. (#4769)
fix: Reworked the version check (#4719) (#4781)
fix: Unable to Delete Jellyfin Server (#4705) (#4780)
fix: Partially Available prevents further TV requests (#4768) (#4779)
fix(emby): Fix Emby played sync running a full sync during recently added sync (#4932)
Fixes #4947
fix: Fix various styling issues (#4935)
fix(translations): 🌐 New translations from Crowdin [skip ci] (#4926)
fix: upgrade @microsoft/signalr from 6.0.11 to 6.0.16 (#4964) [skip ci]
fix: upgrade primeng from 15.0.0-rc.1 to 15.4.1 (#4962) [skip ci]
fix: src/Ombi.Notifications/Ombi.Notifications.csproj to reduce vulnerabilities (#4969) [skip ci]
fix: upgrade @fortawesome/fontawesome-free from 6.1.2 to 6.4.0 (#4965) [skip ci]
fix: upgrade multiple dependencies with Snyk (#4963) [skip ci]
fix flaky tests (#4970) [skip ci]
fix: More automation tests mainly around the Plex Settings page (#4821)
fix: upgrade cypress-real-events from 1.7.4 to 1.8.1 (#4968) [skip ci]
fix: Remove Angular TSLint (#4973)
fix: upgrade zone.js from 0.11.8 to 0.13.0 (#4975)
fix: upgrade jquery from 3.6.1 to 3.7.0 (#4974)
fix: upgrade multiple dependencies with Snyk (#4961)
fixes (#4978)
fix(user-importer): 🐛 Fixed an issue where the cleanup wouldn't delete users #4812
fix(user-importer): Do not delete the Plex Admin as part of the user Importer cleanup #4870 (#4981)
Fixes #4957
fix: Remove old trending source (#4987)
fix(plex-api): Switch over to the new API to avoid deprecation & save… (#4986)
fix: switch back to the old plex friends API #4989
fix(user-importer): Fixed not importing all correct users #4989
fix: upgrade cypress-real-events from 1.8.1 to 1.9.1 (#5000) [skip ci]
fix: upgrade @microsoft/signalr from 6.0.18 to 6.0.20 (#4999) [skip ci]
fix: upgrade @fortawesome/fontawesome-free from 6.4.0 to 6.4.2 (#5005) [skip ci]
fix: upgrade @types/jquery from 3.5.16 to 3.5.17 (#5011) [skip ci]
fix: src/Ombi/ClientApp/package.json & src/Ombi/ClientApp/yarn.lock to reduce vulnerabilities (#5010) [skip ci]
fix: upgrade @microsoft/signalr from 6.0.21 to 6.0.22 (#5020)
fix: upgrade @types/jquery from 3.5.18 to 3.5.19 (#5022)
fix: upgrade zone.js from 0.13.1 to 0.13.2 (#5019)
fix: upgrade multiple dependencies with Snyk (#5030)
fix: upgrade cypress-real-events from 1.10.0 to 1.10.1 (#5014)
fix: upgrade jquery from 3.7.0 to 3.7.1 (#5015)
Fix: Linkify logo in newsletter (#5036)
fix: upgrade @types/jquery from 3.5.22 to 3.5.23 (#5034) [skip ci]
fix: upgrade @microsoft/signalr from 6.0.22 to 6.0.23 (#5032) [skip ci]
Fix(mutliple servers): attempting to cache the Plex Content in server (#5018)
fix(radarr-4k): 🐛 Fixed an issue when using Radarr 4k with user set quality profiles. There are now user quality profiles for 4k profile #5025
fix: src/Ombi/ClientApp/package.json & src/Ombi/ClientApp/yarn.lock to reduce vulnerabilities (#5072) [skip ci]
fix: src/Ombi/Ombi.csproj to reduce vulnerabilities (#5066) [skip ci]
fix: upgrade @fortawesome/fontawesome-free from 6.4.2 to 6.5.0 (#5053)  [skip ci]
fix: upgrade @types/jquery from 3.5.27 to 3.5.28 (#5049)  [skip ci]
fix: src/Ombi/ClientApp/package.json & src/Ombi/ClientApp/yarn.lock to reduce vulnerabilities (#5040)  [skip ci]
fix: upgrade moment from 2.29.4 to 2.30.1 (#5075) [skip ci]
fix: upgrade multiple dependencies with Snyk (#5073) [skip ci]
fix: upgrade multiple dependencies with Snyk (#5104) [skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants