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

OrchardCore.OpenId.Tasks.OpenIdBackgroundTask[0], An error occurred while pruning tokens from the database. Object does not match target type #14539

Closed
hieucd04 opened this issue Oct 18, 2023 · 14 comments
Labels
Milestone

Comments

@hieucd04
Copy link

Environment

  • Orchard Core: 1.7.2
  • Database: MySQL (mariadb inside Docker)
  • OS: My app runs inside Docker which runs inside windows 11

To Reproduce

I'm just using Orchard Core normally then suddenly, these exceptions appear in my Docker logs stream.

Expected behavior

No exception thrown.

Logs

2023-10-18 08:00:56 fail: OrchardCore.OpenId.Tasks.OpenIdBackgroundTask[0]
2023-10-18 08:00:56       An error occurred while pruning tokens from the database.
2023-10-18 08:00:56       System.Reflection.TargetException: Object does not match target type.
2023-10-18 08:00:56          at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.Evaluate(Expression expression)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.ConvertFragment(IStringBuilder builder, Expression expression)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.ConvertFragment(IStringBuilder builder, Expression expression)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.ConvertComparisonBinaryExpression(IStringBuilder builder, BinaryExpression expression, String operation)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.ConvertFragment(IStringBuilder builder, Expression expression)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.ConvertEqualityBinaryExpression(IStringBuilder builder, BinaryExpression expression, String operation)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.ConvertFragment(IStringBuilder builder, Expression expression)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.Filter[TIndex](Expression`1 predicate)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.Query`1.YesSql.IQuery<T>.With[TIndex](Expression`1 predicate)
2023-10-18 08:00:56          at YesSql.QueryExtensions.Query[T,TIndex](ISession session, Expression`1 predicate, Boolean filterType, String collection)
2023-10-18 08:00:56          at YesSql.QueryExtensions.Query[T,TIndex](ISession session, Expression`1 predicate, String collection)
2023-10-18 08:00:56          at OrchardCore.OpenId.YesSql.Stores.OpenIdTokenStore`1.PruneAsync(DateTimeOffset threshold, CancellationToken cancellationToken)
2023-10-18 08:00:56          at OrchardCore.OpenId.Tasks.OpenIdBackgroundTask.DoWorkAsync(IServiceProvider serviceProvider, CancellationToken cancellationToken)
2023-10-18 08:00:56 fail: OrchardCore.OpenId.Tasks.OpenIdBackgroundTask[0]
2023-10-18 08:00:56       An error occurred while pruning authorizations from the database.
2023-10-18 08:00:56       System.Reflection.TargetException: Object does not match target type.
2023-10-18 08:00:56          at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.Evaluate(Expression expression)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.ConvertFragment(IStringBuilder builder, Expression expression)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.ConvertFragment(IStringBuilder builder, Expression expression)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.ConvertComparisonBinaryExpression(IStringBuilder builder, BinaryExpression expression, String operation)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.ConvertFragment(IStringBuilder builder, Expression expression)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.ConvertEqualityBinaryExpression(IStringBuilder builder, BinaryExpression expression, String operation)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.ConvertFragment(IStringBuilder builder, Expression expression)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.Filter[TIndex](Expression`1 predicate)
2023-10-18 08:00:56          at YesSql.Services.DefaultQuery.Query`1.YesSql.IQuery<T>.With[TIndex](Expression`1 predicate)
2023-10-18 08:00:56          at YesSql.QueryExtensions.Query[T,TIndex](ISession session, Expression`1 predicate, Boolean filterType, String collection)
2023-10-18 08:00:56          at YesSql.QueryExtensions.Query[T,TIndex](ISession session, Expression`1 predicate, String collection)
2023-10-18 08:00:56          at OrchardCore.OpenId.YesSql.Stores.OpenIdAuthorizationStore`1.PruneAsync(DateTimeOffset threshold, CancellationToken cancellationToken)
2023-10-18 08:00:56          at OrchardCore.OpenId.Tasks.OpenIdBackgroundTask.DoWorkAsync(IServiceProvider serviceProvider, CancellationToken cancellationToken)

@jtkech
Copy link
Member

jtkech commented Oct 18, 2023

Can't repro by just enabling these 2 features (see below) but there is nothing to prune, but I can see the query well executed in the background task (I set the period to 1 minute for testing).

"OrchardCore.OpenId.Server",
"OrchardCore.OpenId.Validation",

@jtkech
Copy link
Member

jtkech commented Oct 18, 2023

Can you check what you have in the OpenIdAuthorizationIndex table

@hieucd04
Copy link
Author

Unfortunately, I factory reset my Docker several times during testing my code base with 1.7.2.
I no longer have the DB from when those exceptions were thrown. I'm sorry!

@jtkech
Copy link
Member

jtkech commented Oct 18, 2023

No problem

@jtkech
Copy link
Member

jtkech commented Oct 18, 2023

In some model classes we changed a field Id from int to long but normally should not be a problem.

Are you starting nodes that use an existing database that were created from a previous version?

@hieucd04
Copy link
Author

We start with a blank database and:

  • We wrote an Orchard Core module which creates Content Type Definitions using IContentDefinitionManager.AlterTypeDefinition, IContentDefinitionManager.AlterPartDefinition, etc.
  • We import our previously exported content data via Deployment Plan.

@jtkech
Copy link
Member

jtkech commented Oct 18, 2023

We start with a blank database and:

Okay I will try to repro tomorrow

@jtkech
Copy link
Member

jtkech commented Oct 18, 2023

Which database are you using?

As a reminder I noticed that with Sqlite the Id primary key of the Index Tables are still an integer, not a bigint (by default), but normally should still work, but still an issue to fix.

@hieucd04
Copy link
Author

I'm using MySQL 8

@jtkech
Copy link
Member

jtkech commented Oct 19, 2023

By code I created and saved some OpenIdAuthorization in the OpenId_Document table, then the related OpenId_OpenIdAuthorizationIndex was well populated, and then the authorisations that was not valid was well pruned by the background task. So I was not able to repro.

Can you check if you have any error but before importing your contents or only partially?

And if you have time, check your OpenId tables, all prefixed with the OpenId_ collection name, particularly the values of the Type column in the OpenId_Document table.

OpenId Tables

Otherwise try to clean and rebuild your app, maybe some bad package restores.


I confirm, at least for Sqlite an autoincrement key can't be a bigint, only an integer.

@sebastienros sebastienros added this to the backlog milestone Oct 19, 2023
@sebastienros
Copy link
Member

2023-10-18 08:00:56 at YesSql.Services.DefaultQuery.Evaluate(Expression expression)

Looks like a reflection issue, since you are now using 1.7.2 I would assume that you have old versions of yessql around and now they are conflicting with the new one. Try to do a deep clean of your repository to get rid of older versions of yessql.

@hieucd04
Copy link
Author

During the last 2 or 3 days, I have been attempting to reproduce this issue but without any success.
So, maybe you guys are right, this is probably a phantom issue caused by an unclean workspace.

Since this issue cannot be reproduced, there are nothing which can be done here.
I'm closing this one!

@jtkech
Copy link
Member

jtkech commented Oct 21, 2023

Cool then, thanks for having tried it again

@Kees-Schouten
Copy link

Kees-Schouten commented Sep 21, 2024

I still have the same issue with Postgresql. I also added a comment with the reproduction steps for Orchard Core on the issue in the yessql repository, see:

sebastienros/yessql#531

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants